本文整理汇总了Java中com.android.ddmlib.AndroidDebugBridge.isConnected方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidDebugBridge.isConnected方法的具体用法?Java AndroidDebugBridge.isConnected怎么用?Java AndroidDebugBridge.isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.ddmlib.AndroidDebugBridge
的用法示例。
在下文中一共展示了AndroidDebugBridge.isConnected方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDevices
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private IDevice[] getDevices(Project project) {
List<AndroidFacet> facets = getApplicationFacets(project);
if (!facets.isEmpty()) {
AndroidFacet facet;
if (facets.size() > 1) {
facet = ModuleChooserDialogHelper.showDialogForFacets(project, facets);
if (facet == null) {
return null;
}
} else {
facet = facets.get(0);
}
AndroidDebugBridge bridge = facet.getDebugBridge();
if (bridge == null) {
log.error("No platform configured");
return null;
}
if (bridge.isConnected() && bridge.hasInitialDeviceList()) {
return bridge.getDevices();
}
}
return null;
}
示例2: waitUntilConnected
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private static void waitUntilConnected(AndroidDebugBridge adb) {
int trials = 10;
final int connectionWaitTime = 50;
while (trials > 0) {
try {
Thread.sleep(connectionWaitTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (adb.isConnected()) {
break;
}
trials--;
}
}
示例3: close
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
@Override
public void close() {
// TODO(radim): if we really need it then it belongs to core where ADBfactory lives
AndroidDebugBridge adb = AndroidSdkProvider.getAdb();
if (adb != null && adb.isConnected()) {
AndroidDebugBridge.disconnectBridge();
}
}
示例4: getDevice
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private static DeviceResult getDevice(Project project) {
List<AndroidFacet> facets = getApplicationFacets(project);
if (!facets.isEmpty()) {
AndroidFacet facet = facets.get(0);
String packageName = AdbUtil.computePackageName(facet);
AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(project);
if (bridge == null) {
error("No platform configured");
return null;
}
int count = 0;
while (!bridge.isConnected() || !bridge.hasInitialDeviceList()) {
try {
Thread.sleep(100);
count++;
} catch (InterruptedException e) {
// pass
}
// let's not wait > 10 sec.
if (count > 100) {
error("Timeout getting device list!");
return null;
}
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 1) {
return new DeviceResult(devices, facet, packageName);
} else if (devices.length > 1) {
return askUserForDevice(facet, packageName);
} else {
return null;
}
}
error("No devices found");
return null;
}
示例5: installPatchIfDeviceConnected
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* no device or too many device make install fail
*
* @param name
* @param patch
* @return
*/
private static boolean installPatchIfDeviceConnected(AndroidBuilder androidBuilder, File patch, String patchPkg,
Logger logger, String name) {
final AndroidDebugBridge androidDebugBridge = initAndroidDebugBridge(androidBuilder);
if (!androidDebugBridge.isConnected()) {
throw new RuntimeException("Android Debug Bridge is not connected.");
}
waitForInitialDeviceList(androidDebugBridge, logger);
List<IDevice> devices = Arrays.asList(androidDebugBridge.getDevices());
String PATCH_INSTALL_DIRECTORY = String.format("%s%s%s", PATCH_INSTALL_DIRECTORY_PREFIX, patchPkg,
PATCH_INSTALL_DIRECTORY_SUFFIX);
if (devices.size() == 0) {
throw new RuntimeException(String.format("%s%s%s%s%s",
"no device connected,please check whether the connection is "
+ "successful or copy ", patch,
" in build/outputs/awbs/libxxx.so ", PATCH_INSTALL_DIRECTORY,
" and restart you app"));
}
if (devices.size() > 1) {
throw new RuntimeException("too much devices be connected,please disconnect the others and try again");
}
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(logger);
executor.setCaptureStdOut(true);
executor.setCaptureStdErr(true);
List<String> cmd = Arrays.asList("push", patch.getAbsolutePath(), PATCH_INSTALL_DIRECTORY + name);
try {
executor.executeCommand(androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), cmd, false);
return true;
} catch (ExecutionException e) {
throw new RuntimeException("Error while trying to push patch to device ", e);
} finally {
String errout = executor.getStandardError();
if ((errout != null) && (errout.trim().length() > 0)) {
logger.error(errout);
}
}
}
示例6: getDevice
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private DeviceResult getDevice(AnActionEvent anActionEvent) {
List<AndroidFacet> facets = getApplicationFacets(anActionEvent.getProject());
if (!facets.isEmpty()) {
AndroidFacet facet = null;
String androidFacetName = getAndroidFacetName(anActionEvent);
if (androidFacetName != null) {
for (AndroidFacet androidFacet : facets) {
if (androidFacet.getModule().getName().equals(androidFacetName)) {
facet = androidFacet;
}
}
if (facet == null) {
return null;
}
} else {
if (facets.size() > 1) {
facet = ModuleChooserDialogHelper.showDialogForFacets(anActionEvent.getProject(), facets);
if (facet == null) {
return null;
}
} else {
facet = facets.get(0);
}
}
String packageName =facet.getAndroidModuleInfo().getPackage();
AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(anActionEvent.getProject());
if (bridge == null) {
error("No platform configured");
return null;
}
if (bridge.isConnected() && bridge.hasInitialDeviceList()) {
IDevice[] devices = bridge.getDevices();
if (devices.length == 1) {
return new DeviceResult(anActionEvent, devices[0], facet, packageName);
} else if (devices.length > 1) {
return askUserForDevice(anActionEvent, facet, packageName);
} else {
return new DeviceResult(anActionEvent, null, facet, null);
}
}
}
return new DeviceResult(anActionEvent, null, null, null);
}
示例7: isAdbInitialized
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private boolean isAdbInitialized(AndroidDebugBridge adb) {
return adb.isConnected() && adb.hasInitialDeviceList();
}
示例8: isAdbInitialized
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private static boolean isAdbInitialized(AndroidDebugBridge adb) {
return adb.isConnected() && adb.hasInitialDeviceList();
}