当前位置: 首页>>代码示例>>Java>>正文


Java AndroidDebugBridge.createBridge方法代码示例

本文整理汇总了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...");		
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:18,代码来源:FrameworkEventManager.java

示例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);
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:18,代码来源:AndroidSdkProvider.java

示例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;
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:22,代码来源:AdbUtil.java

示例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);
	}
}
 
开发者ID:hoozheng,项目名称:AndroidRobot,代码行数:20,代码来源:AdbDevice.java

示例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;
}
 
开发者ID:androiddevelop,项目名称:AndroidScreenshot,代码行数:32,代码来源:ScreenShot.java

示例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();
    }
}
 
开发者ID:lrscp,项目名称:AndroidFileExplorer,代码行数:24,代码来源:FileViewer.java

示例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;
}
 
开发者ID:felixb,项目名称:logcat-gui,代码行数:27,代码来源:AdbWrapper.java

示例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;
}
 
开发者ID:facebook,项目名称:buck,代码行数:25,代码来源:InstrumentationTestRunner.java

示例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);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:18,代码来源:AndroidDebugger.java

示例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);
  }
}
 
开发者ID:DroidTesting,项目名称:android-uiautomatorviewer,代码行数:8,代码来源:DebugBridge.java

示例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;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:14,代码来源:AwoInstaller.java

示例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 */);
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:10,代码来源:AdbBackend.java

示例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);
    }
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:16,代码来源:DeviceBridge.java

示例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();
}
 
开发者ID:HoneyFish,项目名称:SmartTools,代码行数:15,代码来源:SmartToolsApp.java

示例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;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:35,代码来源:AdbHelper.java


注:本文中的com.android.ddmlib.AndroidDebugBridge.createBridge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。