本文整理汇总了Java中com.android.ddmlib.IDevice.executeShellCommand方法的典型用法代码示例。如果您正苦于以下问题:Java IDevice.executeShellCommand方法的具体用法?Java IDevice.executeShellCommand怎么用?Java IDevice.executeShellCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.ddmlib.IDevice
的用法示例。
在下文中一共展示了IDevice.executeShellCommand方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onData
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public void onData(SocketIOClient arg0, String data, AckRequest arg2) throws Exception {
if (data!=null) {
List<String> list=JsonUtil.jsonTobean(data=data.trim(), List.class);
if (list!=null) {
for (String sernum :list) {
DeviceEntity deviceEntity=DeviceContainerHandler.getDevice(sernum);
IDevice idevice=deviceEntity.getIdevice();
idevice.executeShellCommand(startActivity, receiver);
}
}else {
logger.info("json to bean 失败!!");
}
}
}
示例2: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String shellCmd = String.format("am start -n %s/.%s", packageName, activityName);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.START_ACTIVITY, String.format("started activity %s/%s", packageName, activityName));
} catch (Exception e) {
LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, String.format("not able to start activity %s/%s: ", packageName, activityName, e.getMessage()));
e.printStackTrace();
}
return null;
}
示例3: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String shellCmd = String.format("am startservice --es \"task\" \"addContact\" -n %s/%s",
packageName, UtilInstrumenter.COMPONENT_CALLER_SERVICE_HELPER);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), "contact added..."));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例4: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String numberToCall = "";
for(int i = 0; i < 8; i++)
numberToCall += ThreadLocalRandom.current().nextInt(0, 9 + 1);
String shellCmd = String.format("am broadcast -a android.intent.action.NEW_OUTGOING_CALL --es PHONE_NUMBER %s", numberToCall);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), shellCmd));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例5: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String shellCmd = String.format("am broadcast %s -a %s %s", prepareExtras(extras), action, prepareMimeType(mimeType));
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), shellCmd));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例6: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String shellCmd = prepareStartService();
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), shellCmd));
} catch (Exception e) {
// LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, "not able to send a broadcast: " + e.getMessage());
e.printStackTrace();
}
return null;
}
示例7: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String shellCmd = String.format("am startservice --es \"className\" \"%s\""
+ " --es \"task\" \"onClick\" -n %s/%s",
onClickListenerClass, packageName, UtilInstrumenter.COMPONENT_CALLER_SERVICE_HELPER);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), onClickListenerClass));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例8: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
//just start the onCreate for now; we do not care whether the bundle is null
String shellCmd = String.format("am startservice %s/%s", packageName, servicePath);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), shellCmd));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例9: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
// String shellCmd = String.format("am start -n %s/.%s", packageName, launchableActivity);
String shellCmd = String.format("monkey -p %s -c android.intent.category.LAUNCHER 1", packageName);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.OPEN_APK, "APK opened");
} catch (Exception e) {
LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, "not able to start apk: " + e.getMessage());
e.printStackTrace();
}
return null;
}
示例10: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
//just start the onCreate for now; we do not care whether the bundle is null
String shellCmd = String.format("am start -W -n %s/%s", packageName, activityPath);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
LoggerHelper.logEvent(MyLevel.ADB_EVENT, adbEventFormat(toString(), shellCmd));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例11: onEventReceived
import com.android.ddmlib.IDevice; //导入方法依赖的package包/类
@Override
public Object onEventReceived(IDevice device) {
String shellCmd = String.format("am force-stop %s", packageName);
try {
device.executeShellCommand(shellCmd, new GenericReceiver(), 10000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, "not able to kill app: " + e.getMessage());
e.printStackTrace();
}
return null;
}