本文整理汇总了Java中com.android.ddmlib.AndroidDebugBridge.createBridge方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidDebugBridge.createBridge方法的具体用法?Java AndroidDebugBridge.createBridge怎么用?Java AndroidDebugBridge.createBridge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.ddmlib.AndroidDebugBridge
的用法示例。
在下文中一共展示了AndroidDebugBridge.createBridge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectToAndroidDevice
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public void connectToAndroidDevice() {
LoggerHelper.logEvent(MyLevel.RUNTIME, "Connecting to ADB...");
if(adb == null) {
AndroidDebugBridge.init(false);
// AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
// FrameworkOptions.PLATFORM_TOOLS + File.separator + "adb", true);
adb = AndroidDebugBridge.createBridge();
}
waitForDevice();
this.device = getDevice(FrameworkOptions.devicePort);
if(this.device == null) {
LoggerHelper.logEvent(MyLevel.EXCEPTION_RUNTIME, String.format("Device with port %s not found! -- retry it", FrameworkOptions.devicePort));
connectToAndroidDevice();
}
LoggerHelper.logEvent(MyLevel.RUNTIME, "Successfully connected to ADB...");
}
示例2: updateAdb
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
protected void updateAdb() {
AndroidSdk sdk = defaultSdk.get();
if (sdk != null) {
final FileObject path = sdk.findTool(ADB_TOOL);
if (path != null) {
ClientData.class.getClassLoader().clearAssertionStatus(); //qattern
DebugPortManager.setProvider(DebugPortProvider.getDefault());
AndroidDebugBridge.initIfNeeded(true);
String adbLocation = FileUtil.toFile(path).getAbsolutePath();
String lastLocation = adbPath.getAndSet(adbLocation);
pcs.firePropertyChange(PROP_DEFAULT_ADB_PATH, lastLocation, adbLocation);
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(adbLocation, false);
AndroidDebugBridge lastAdb = adb.getAndSet(bridge);
pcs.firePropertyChange(PROP_DEFAULT_ADB, lastAdb, bridge);
}
}
}
示例3: getADBInstance
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* 获取ADB连接实例
*
* @return AndroidDebugBridge
*/
public static AndroidDebugBridge getADBInstance() {
if (bridge == null) {
AndroidDebugBridge.init(false);
String os = System.getProperty("os.name").toLowerCase();
if (os.startsWith("win")) {
// 如果是win系统
bridge = AndroidDebugBridge.createBridge(DirConfig.ADB_DIR + "adb.exe", true);
} else if(os.startsWith("mac")) {
// 如果是osx系统
bridge = AndroidDebugBridge.createBridge(DirConfig.MAC_ADB_DIR + "adb", true);
} else {
bridge = AndroidDebugBridge.createBridge("adb",true);
}
}
return bridge;
}
示例4: initDebugBridge
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private void initDebugBridge() {
if (bridge == null) {
AndroidDebugBridge.init(false);
}
if ((bridge == null) || (!bridge.isConnected())) {
String adbLocation = System.getProperty("user.dir");
System.out.println(adbLocation);
if ((adbLocation != null) && (adbLocation.length() != 0)) {
adbLocation = adbLocation + File.separator + "adb";
File file= new File(adbLocation);
if(!file.exists())
adbLocation = "adb";
}else{
adbLocation = "adb";
}
bridge = AndroidDebugBridge.createBridge(adbLocation, false);
}
}
示例5: getDevice
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* 获取得到device对象
*
* @param index
* 设备序号
* @return 指定设备device对象
*/
private IDevice getDevice(int index) {
IDevice device = null;
// 如果代码有问题请查看API,修改此处的参数值试一下
// AndroidDebugBridge bridge = AndroidDebugBridge.createBridge("adb",
// true);
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge();
waitDevicesList(bridge);
IDevice devices[] = bridge.getDevices();
for (int i = 0; i < devices.length; i++) {
System.out.println(devices[i].toString());
}
if (devices.length < index) {
System.err.print("没有检测到第" + index + "个设备");
} else {
if (devices.length - 1 >= index) {
device = devices[index];
} else {
device = devices[0];
}
}
return device;
}
示例6: main
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* Runs main program.
*/
public static void main(String[] args) {
try {
Display display = new Display();
FileViewer application = new FileViewer();
Shell shell = application.open(display);
AndroidDebugBridge.init(true);
AndroidDebugBridge.createBridge("adb", true);
AndroidDebugBridge.addDeviceChangeListener(application);
application.showConnectDialog();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
application.close();
display.dispose();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: connect
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
*
* @param adbFilePath
* @param listener
* @return
*/
public boolean connect(String adbFilePath, DeviceConnectionListener listener) {
if (!checkPath(adbFilePath)) {
Util.DbgLog("Error occured in setting adb binary file path");
return false;
}
if (mIsAdbInitialized) {
Util.DbgLog("Already connected..");
return false;
}
mDeviceStateListener = listener;
AndroidDebugBridge.init(false /* no need to support debug*/);
AndroidDebugBridge.addClientChangeListener(mClientChangeListener);
AndroidDebugBridge.addDeviceChangeListener(mDeviceChangeListener);
AndroidDebugBridge.createBridge(adbFilePath, true /* forceNewBridge */);
mIsAdbInitialized = true;
return true;
}
示例8: createAdb
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* Creates connection to adb and waits for this connection to be initialized and receive initial
* list of devices.
*/
@Nullable
@SuppressWarnings("PMD.EmptyCatchBlock")
private AndroidDebugBridge createAdb() throws InterruptedException {
AndroidDebugBridge.initIfNeeded(/* clientSupport */ false);
AndroidDebugBridge adb = AndroidDebugBridge.createBridge(this.adbExecutablePath, false);
if (adb == null) {
System.err.println("Failed to connect to adb. Make sure adb server is running.");
return null;
}
long start = System.currentTimeMillis();
while (!isAdbInitialized(adb)) {
long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
if (timeLeft <= 0) {
break;
}
Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
}
return isAdbInitialized(adb) ? adb : null;
}
示例9: init
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public static void init() throws InterruptedException {
if (AndroidDebugBridge.getBridge() == null
|| !isAdbInitialized(AndroidDebugBridge.getBridge())) {
AndroidDebugBridge.initIfNeeded(/* clientSupport */ true);
AndroidDebugBridge.createBridge(
BuckSettingsProvider.getInstance().resolveAdbExecutable(), false);
}
long start = System.currentTimeMillis();
while (!isAdbInitialized(AndroidDebugBridge.getBridge())) {
long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
if (timeLeft <= 0) {
break;
}
Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
}
}
示例10: init
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public static void init() {
String adbLocation = getAdbLocation();
if (adbLocation != null) {
AndroidDebugBridge.init(false /* debugger support */);
sDebugBridge = AndroidDebugBridge.createBridge(adbLocation, false);
}
}
示例11: initAndroidDebugBridge
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
protected static AndroidDebugBridge initAndroidDebugBridge(AndroidBuilder androidBuilder) {
synchronized (ADB_LOCK) {
if (!adbInitialized) {
DdmPreferences.setTimeOut(adbConnectionTimeout);
AndroidDebugBridge.init(false);
adbInitialized = true;
}
AndroidDebugBridge androidDebugBridge = AndroidDebugBridge.createBridge(
androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), false);
waitUntilConnected(androidDebugBridge);
return androidDebugBridge;
}
}
示例12: AdbBackend
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public AdbBackend() {
// [try to] ensure ADB is running
String adbLocation = findAdb();
AndroidDebugBridge.init(true/* debugger support */);
bridge = AndroidDebugBridge.createBridge(
adbLocation, true /* forceNewBridge */);
}
示例13: initDebugBridge
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* Creates an {@link AndroidDebugBridge} connected to adb at the given location.
*
* If a bridge is already running, this disconnects it and creates a new one.
*
* @param adbLocation the location to adb.
*/
public static void initDebugBridge(String adbLocation) {
if (sBridge == null) {
AndroidDebugBridge.init(false /* debugger support */);
}
if (sBridge == null || !sBridge.isConnected()) {
sBridge = AndroidDebugBridge.createBridge(adbLocation, true);
}
}
示例14: initApp
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
void initApp() {
UIManager.put("ScrollBar.width", new Integer(Config.SCROLLBAR_WIDTH));
mMainFrame.initFrame();
mMainFrame.addPanel();
String adbPath = Utils.findAdb();
AndroidDebugBridge.init(false /* debugger support */);
mAdb = AndroidDebugBridge
.createBridge(adbPath, false /* forceNewBridge */);
mDeviceChannel = new DeviceMsgChannel();
mDeviceChannel.start();
}
示例15: createAdb
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* Creates connection to adb and waits for this connection to be initialized
* and receive initial list of devices.
*/
@Nullable
@SuppressWarnings("PMD.EmptyCatchBlock")
private AndroidDebugBridge createAdb(ExecutionContext context) throws InterruptedException {
try {
AndroidDebugBridge.init(/* clientSupport */ false);
} catch (IllegalStateException ex) {
// ADB was already initialized, we're fine, so just ignore.
}
AndroidDebugBridge adb = null;
if (context != null) {
adb = AndroidDebugBridge.createBridge(context.getPathToAdbExecutable(), false);
} else {
adb = AndroidDebugBridge.createBridge();
}
if (adb == null) {
console.printBuildFailure("Failed to connect to adb. Make sure adb server is running.");
return null;
}
long start = System.currentTimeMillis();
while (!isAdbInitialized(adb)) {
long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
if (timeLeft <= 0) {
break;
}
Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
}
return isAdbInitialized(adb) ? adb : null;
}