本文整理汇总了Java中com.android.ddmlib.AndroidDebugBridge.init方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidDebugBridge.init方法的具体用法?Java AndroidDebugBridge.init怎么用?Java AndroidDebugBridge.init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.ddmlib.AndroidDebugBridge
的用法示例。
在下文中一共展示了AndroidDebugBridge.init方法的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: 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;
}
示例3: 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);
}
}
示例4: 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();
}
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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;
}
}
示例8: 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 */);
}
示例9: 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);
}
}
示例10: ServerConnectionManager
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
*
*/
private ServerConnectionManager() {
devices = new HashMap<String, AndroidDevice>();
AndroidDebugBridge
.addDeviceChangeListener(ServerConnectionManager.this);
AndroidDebugBridge.init(false);
}
示例11: 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();
}
示例12: 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;
}
示例13: AdbBackend
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public AdbBackend() {
// [try to] ensure ADB is running
String adbLocation = findAdb();
AndroidDebugBridge.init(false /* debugger support */);
bridge = AndroidDebugBridge.createBridge(
adbLocation, true /* forceNewBridge */);
}
示例14: 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 static AndroidDebugBridge createAdb(
AndroidPlatformTarget androidPlatformTarget, ExecutionContext context)
throws InterruptedException {
DdmPreferences.setTimeOut(60000);
try {
AndroidDebugBridge.init(/* clientSupport */ false);
} catch (IllegalStateException ex) {
// ADB was already initialized, we're fine, so just ignore.
}
AndroidDebugBridge adb =
AndroidDebugBridge.createBridge(androidPlatformTarget.getAdbExecutable().toString(), false);
if (adb == null) {
context
.getConsole()
.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;
}
示例15: init
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private void init() {
if (bridge == null || !bridge.isConnected()) {
AndroidDebugBridge.init(false);
bridge = AndroidDebugBridge.createBridge();
}
}