本文整理汇总了Java中com.android.ddmlib.AndroidDebugBridge.addDeviceChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidDebugBridge.addDeviceChangeListener方法的具体用法?Java AndroidDebugBridge.addDeviceChangeListener怎么用?Java AndroidDebugBridge.addDeviceChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.ddmlib.AndroidDebugBridge
的用法示例。
在下文中一共展示了AndroidDebugBridge.addDeviceChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: observeForDeviceChange
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* Observe for deviec state changes
*/
private void observeForDeviceChange() {
deviceSelectionListener =
new DeviceContext.DeviceSelectionListener() {
@Override
public void deviceSelected(@Nullable IDevice device) {
notifyDeviceUpdated(device);
}
@Override
public void deviceChanged(@NotNull IDevice device, int changeMask) {
if ((changeMask & IDevice.CHANGE_STATE) == IDevice.CHANGE_STATE) {
notifyDeviceUpdated(device);
}
}
@Override
public void clientSelected(@Nullable final Client c) {
}
};
deviceContext.addListener(deviceSelectionListener, this);
AndroidDebugBridge.addClientChangeListener(this);
AndroidDebugBridge.addDeviceChangeListener(this);
AndroidDebugBridge.addDebugBridgeChangeListener(this);
}
示例2: waitForDeviceConnected
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public IDevice waitForDeviceConnected(final String serialNumber, final long timeout) throws InterruptedException {
id = serialNumber;
Console.printLogMessage(serialNumber, "waitForDeviceConnected(" + serialNumber + " to be connected start");
IDevice [] devices = AndroidDebugBridge.getBridge().getDevices();
if (devices != null) {
for (IDevice device : devices) {
if (device.getSerialNumber() == serialNumber) {
Console.printLogMessage("", device.getSerialNumber());
return device;
}
}
}
AndroidDebugBridge.addDebugBridgeChangeListener(DeviceConnectHelper.this);
AndroidDebugBridge.addDeviceChangeListener(DeviceConnectHelper.this);
synchronized (this) {
while (getConnecedDevice(serialNumber) == null) {
Console.printLogMessage("", "wait");
wait(60000);
}
}
Console.printLogMessage(serialNumber, "waitForDeviceConnected(" + serialNumber + " to be connected end");
return getConnecedDevice(serialNumber);
}
示例3: 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();
}
}
示例4: 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;
}
示例5: EmulatorLauncher
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public EmulatorLauncher(AndroidSdk sdk) {
this.sdk = sdk;
listener = new AdbListener();
// AndroidDebugBridge.addDebugBridgeChangeListener(listener);
AndroidDebugBridge.addDeviceChangeListener(listener);
// AndroidDebugBridge.addClientChangeListener(listener);
}
示例6: LogDevicesComboBoxSupport
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
protected LogDevicesComboBoxSupport(LogReader reader) {
this.reader = reader;
// get notification for logged devices
reader.addPropertyChangeListener(WeakListeners.propertyChange(this, reader));
// get notifications for attached and detached devices
AndroidDebugBridge.addDeviceChangeListener(this);
Lookup lookup = Utilities.actionsGlobalContext();
deviceLookup = lookup.lookupResult(IDevice.class);
deviceLookup.addLookupListener(this);
update();
}
示例7: EmulatorManager
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private EmulatorManager() {
sdkToolCommandSender = new SdkToolCommandSender();
// Register the EmulatorManager for device change events so it can keep track of running emulators.
AndroidDebugBridge.addDeviceChangeListener(this);
// Get initial device list
androidDebugBridge = AndroidDebugBridge.getBridge();
List<IDevice> registeredDevices = getDeviceList();
for (IDevice device : registeredDevices) {
deviceConnected(device);
}
}
示例8: registerDeviceListener
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private void registerDeviceListener() {
AndroidDebugBridge.addDeviceChangeListener(myDeviceListener);
Disposer.register(this, new Disposable() {
@Override
public void dispose() {
AndroidDebugBridge.removeDeviceChangeListener(myDeviceListener);
}
});
}
示例9: DevicePanel
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public DevicePanel(@NotNull Project project, @NotNull DeviceContext context) {
myProject = project;
myDeviceContext = context;
myPreferredClients = Maps.newHashMap();
myCandidateClientName = getApplicationName();
Disposer.register(myProject, this);
initializeDeviceCombo();
initializeClientCombo();
AndroidDebugBridge.addDeviceChangeListener(this);
AndroidDebugBridge.addClientChangeListener(this);
AndroidDebugBridge.addDebugBridgeChangeListener(this);
}
示例10: postCreation
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
@Override
protected void postCreation() {
// ask for notification of changes in AndroidDebugBridge (a new one is created when
// adb is restarted from a different location), IDevice and Client objects.
AndroidDebugBridge.addDebugBridgeChangeListener(this);
AndroidDebugBridge.addDeviceChangeListener(this);
AndroidDebugBridge.addClientChangeListener(this);
}
示例11: LogCatPidToNameMapper
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public LogCatPidToNameMapper(IDevice device) {
mDevice = device;
mClientChangeListener = constructClientChangeListener();
AndroidDebugBridge.addClientChangeListener(mClientChangeListener);
mDeviceChangeListener = constructDeviceChangeListener();
AndroidDebugBridge.addDeviceChangeListener(mDeviceChangeListener);
mPidToName = new HashMap<String, String>();
updateClientList(device);
}
示例12: ServerConnectionManager
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
*
*/
private ServerConnectionManager() {
devices = new HashMap<String, AndroidDevice>();
AndroidDebugBridge
.addDeviceChangeListener(ServerConnectionManager.this);
AndroidDebugBridge.init(false);
}
示例13: windowOpened
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
@Override
public void windowOpened(WindowEvent e) {
AndroidDebugBridge.addDeviceChangeListener(this);
updateDeviceList();
System.out.println("device number:" + mDevices.size());
}
示例14: initializeADBConnection
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
* Initializes the AndroidDebugBridge and registers the TestDeviceManager
* with the AndroidDebugBridge device change listener. It is recommended
* that addConnectionListener(TestDeviceConnectionListener) be called with
* all listeners before calling this method.
*/
public void initializeADBConnection() {
// Get a device bridge instance. Initialize, create and restart.
try {
AndroidDebugBridge.initIfNeeded(false);
} catch (IllegalStateException ise) {
ise.printStackTrace();
System.out.println("The IllegalStateException is not a show " +
"stopper. It has been handled. This is just debug spew." +
" Please proceed.");
}
bridge = AndroidDebugBridge.getBridge();
if (bridge == null) {
bridge = AndroidDebugBridge.createBridge(
adbPath,
false);
}
// Add the existing devices to the list of devices we are tracking.
if (bridge.isConnected() && bridge.hasInitialDeviceList()) {
IDevice[] connectedDevices = bridge.getDevices();
for (int i = 0; i < connectedDevices.length; i++) {
TestDevice tDevice = new TestDevice(connectedDevices[i]);
devices.add(tDevice);
notifyListenersAddedDevice(tDevice);
}
}
AndroidDebugBridge.addDeviceChangeListener(this);
}
示例15: addNotify
import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
@Override
protected void addNotify() {
AndroidDebugBridge.addDeviceChangeListener(this);
updateKeys();
}