com.android.ddmlib.AndroidDebugBridge Java Examples

The following examples show how to use com.android.ddmlib.AndroidDebugBridge. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdbDevice.java    From AndroidRobot with Apache License 2.0 6 votes vote down vote up
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);
	}
}
 
Example #2
Source File: AdbNode.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public PropertySet[] getPropertySets() {
    final Sheet.Set set = Sheet.createPropertiesSet();
    set.put(new PropertySupport.ReadOnly<Boolean>(
            "PROP_DebugBridgeConnected",
            Boolean.class,
            NbBundle.getMessage(DevicesNode.class, "PROP_DebugBridgeConnected"),
            NbBundle.getMessage(DevicesNode.class, "DESC_DebugBridgeConnected")) {
        @Override
        public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
            final AndroidDebugBridge jp = AndroidSdkProvider.getAdb();
            return jp == null ? Boolean.FALSE : jp.isConnected();
        }
    });
    return new PropertySet[]{
        set
    };
}
 
Example #3
Source File: DevicesNode.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public PropertySet[] getPropertySets() {
    final Sheet.Set set = Sheet.createPropertiesSet();
    set.put(new PropertySupport.ReadOnly<Boolean>(
            "PROP_DebugBridgeConnected",
            Boolean.class,
            NbBundle.getMessage(DevicesNode.class, "PROP_DebugBridgeConnected"),
            NbBundle.getMessage(DevicesNode.class, "DESC_DebugBridgeConnected")) {
        @Override
        public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
            final AndroidDebugBridge jp = AndroidSdkProvider.getAdb();
            return jp == null ? Boolean.FALSE : jp.isConnected();
        }
    });
    return new PropertySet[]{
        set
    };
}
 
Example #4
Source File: AndroidSdkProvider.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #5
Source File: MyDeviceChooser.java    From ADB-Duang with MIT License 6 votes vote down vote up
@NotNull
public IDevice[] getSelectedDevices() {
  int[] rows = mySelectedRows != null ? mySelectedRows : myDeviceTable.getSelectedRows();
  List<IDevice> result = new ArrayList<IDevice>();
  for (int row : rows) {
    if (row >= 0) {
      Object serial = myDeviceTable.getValueAt(row, SERIAL_COLUMN_INDEX);
      final AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
      if (bridge == null) {
        return EMPTY_DEVICE_ARRAY;
      }
      IDevice[] devices = getFilteredDevices(bridge);
      for (IDevice device : devices) {
        if (device.getSerialNumber().equals(serial.toString())) {
          result.add(device);
          break;
        }
      }
    }
  }
  return result.toArray(new IDevice[result.size()]);
}
 
Example #6
Source File: RestartADBAction.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    final AndroidDebugBridge debugBridge = AndroidSdkProvider.getAdb();
    if (debugBridge != null) {
        RequestProcessor.getDefault().post(new Runnable() {

            @Override
            public void run() {
                StatusDisplayer.getDefault().setStatusText(
                        NbBundle.getMessage(MobileDeviceNode.class, "MSG_restarting_ADB"));
                boolean status = debugBridge.restart();
                StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
                        MobileDeviceNode.class,
                        status ? "MSG_ADB_restart_success" : "MSG_ADB_restart_fail"));
            }
        });
    } else {
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(MobileDeviceNode.class, "ERR_cannot_restart_ADB"));
    }
}
 
Example #7
Source File: MyDeviceChooser.java    From ADBWIFI with Apache License 2.0 6 votes vote down vote up
@NotNull
public IDevice[] getSelectedDevices() {
  int[] rows = mySelectedRows != null ? mySelectedRows : myDeviceTable.getSelectedRows();
  List<IDevice> result = new ArrayList<IDevice>();
  for (int row : rows) {
    if (row >= 0) {
      Object serial = myDeviceTable.getValueAt(row, SERIAL_COLUMN_INDEX);
      final AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
      if (bridge == null) {
        return EMPTY_DEVICE_ARRAY;
      }
      IDevice[] devices = getFilteredDevices(bridge);
      for (IDevice device : devices) {
        if (device.getSerialNumber().equals(serial.toString())) {
          result.add(device);
          break;
        }
      }
    }
  }
  return result.toArray(new IDevice[result.size()]);
}
 
Example #8
Source File: LogSourceManager.java    From logviewer with Apache License 2.0 6 votes vote down vote up
@Override
public void dispose() {
    AndroidDebugBridge.removeClientChangeListener(this);
    for (DeviceLogSource deviceLogSource : deviceLogSourcesMap.values()) {
        deviceLogSource.getLogProvider().dispose();
    }
    for (LogSource fileLogSource : fileLogSourcesMap.values()) {
        fileLogSource.getLogProvider().dispose();
    }
    if (myBridge != null) {
        AndroidDebugBridge.removeDeviceChangeListener(this);
        AndroidDebugBridge.removeDebugBridgeChangeListener(this);
        myBridge = null;
    }

    deviceLogSourcesMap.clear();
}
 
Example #9
Source File: LogSourceManager.java    From logviewer with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: AwoInstaller.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Wait for the Android Debug Bridge to return an initial device list.
 */
protected static void waitForInitialDeviceList(final AndroidDebugBridge androidDebugBridge, Logger logger) {
    if (!androidDebugBridge.hasInitialDeviceList()) {
        logger.info("Waiting for initial device list from the Android Debug Bridge");
        long limitTime = System.currentTimeMillis() + ADB_TIMEOUT_MS;
        while (!androidDebugBridge.hasInitialDeviceList() && (System.currentTimeMillis() < limitTime)) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException("Interrupted waiting for initial device list from Android Debug Bridge");
            }
        }
        if (!androidDebugBridge.hasInitialDeviceList()) {
            logger.error("Did not receive initial device list from the Android Debug Bridge.");
        }
    }
}
 
Example #11
Source File: DeviceConnectHelper.java    From Android-Monkey-Adapter with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #12
Source File: HJAdb.java    From HJMirror with MIT License 6 votes vote down vote up
/**
 * Start and find Devices.
 */
public IDevice[] startAndFind() throws Exception {
    if (adb == null) {
        AndroidDebugBridge.init(false);
        DdmPreferences.setTimeOut(20000);
        adb = AndroidDebugBridge.createBridge(getAdbExec(), true);
        if (adb == null) {
            throw new Exception("Adb initilized failed!");
        }
    }
    if (adb.hasInitialDeviceList()) {
        IDevice[] devices = adb.getDevices();
        if (devices != null) {
            return devices;
        } else {
            return new IDevice[]{};
        }
    }
    return new IDevice[]{};
}
 
Example #13
Source File: DdmlibAdbServer.java    From bundletool with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes ADB server, optionally restarting it if it points at a different location.
 *
 * <p>Can be called multiple times.
 *
 * @param pathToAdb location of the ADB server to start.
 */
@Override
public synchronized void init(Path pathToAdb) {
  checkState(state != State.CLOSED, "Android Debug Bridge has been closed.");
  if (state.equals(State.INITIALIZED)) {
    checkState(
        pathToAdb.equals(this.pathToAdb),
        "Re-initializing DdmlibAdbServer with a different ADB path. Expected: '%s', got '%s'.",
        this.pathToAdb,
        pathToAdb);
    return;
  }
  AndroidDebugBridge.initIfNeeded(/* clientSupport= */ false);
  this.adb = AndroidDebugBridge.createBridge(pathToAdb.toString(), /* forceNewBridge= */ false);

  if (adb == null) {
    throw CommandExecutionException.builder()
        .withInternalMessage("Failed to start ADB server.")
        .build();
  }

  this.pathToAdb = pathToAdb;
  this.state = State.INITIALIZED;
}
 
Example #14
Source File: InstrumentationTestRunner.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: FrameworkEventManager.java    From FuzzDroid with Apache License 2.0 6 votes vote down vote up
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...");		
}
 
Example #16
Source File: InstrumentationTestRunner.java    From buck with Apache License 2.0 6 votes vote down vote up
@Nullable
private IDevice getDevice(String serial) throws InterruptedException {
  AndroidDebugBridge adb = createAdb();

  if (adb == null) {
    System.err.println("Unable to set up adb.");
    System.exit(1);
  }

  IDevice[] allDevices = adb.getDevices();
  for (IDevice device : allDevices) {
    if (device.getSerialNumber().equals(serial)) {
      return device;
    }
  }
  return null;
}
 
Example #17
Source File: AdbWifiConnect.java    From ADBWIFI with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: MyDeviceChooser.java    From ADBWIFI with Apache License 2.0 5 votes vote down vote up
@NotNull
private IDevice[] getFilteredDevices(AndroidDebugBridge bridge) {
  final List<IDevice> filteredDevices = new ArrayList<IDevice>();
  for (IDevice device : bridge.getDevices()) {
    if (myFilter == null || myFilter.value(device)) {
      filteredDevices.add(device);
    }
  }
  // Do not filter launching cloud devices as they are just unselectable progress markers
  // that are replaced with the actual cloud devices as soon as they are up and the actual cloud devices will be filtered above.
  return filteredDevices.toArray(new IDevice[filteredDevices.size()]);
}
 
Example #19
Source File: ADB.java    From MiniCapAndMiniTouch with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化adb连接
 * @return
 */
private boolean init() {
    boolean success = false;
    if (!hasInitAdb){
        String adbPath = getADBPath();
        if (adbPath != null) {
            AndroidDebugBridge.init(false);
            mAndroidDebugBridge = AndroidDebugBridge.createBridge(adbPath, true);
            if (mAndroidDebugBridge != null) {
                success = true;
                hasInitAdb = true;
            }
            // 延时处理adb获取设备信息
            if (success) {
                int loopCount = 0;
                while (mAndroidDebugBridge.hasInitialDeviceList() == false) {
                    try {
                        Thread.sleep(100);
                        loopCount++;
                    } catch (InterruptedException e) {
                    }
                    if (loopCount > 100) {
                        success = false;
                        break;
                    }
                }
            }
        }
    }

    return success;
}
 
Example #20
Source File: ConnectBlazeTestDebuggerTask.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Wires up listeners to automatically reconnect the debugger for each test method. When you
 * `blaze test` an android_test in debug mode, it kills the instrumentation process between each
 * test method, disconnecting the debugger. We listen for the start of a new method waiting for a
 * debugger, and reconnect. TODO: Support stopping Blaze from the UI. This is hard because we have
 * no way to distinguish process handler termination/debug session ending initiated by the user.
 */
private void setUpForReattachingDebugger(
    String targetPackage,
    LaunchInfo launchInfo,
    ProcessHandlerLaunchStatus launchStatus,
    ProcessHandlerConsolePrinter printer) {
  final AndroidDebugBridge.IClientChangeListener reattachingListener =
      new AndroidDebugBridge.IClientChangeListener() {
        // The target application can either
        // 1. Match our target name, and become available for debugging.
        // 2. Be available for debugging, and suddenly have its name changed to match.
        static final int CHANGE_MASK = Client.CHANGE_DEBUGGER_STATUS | Client.CHANGE_NAME;

        @Override
        public void clientChanged(@NotNull Client client, int changeMask) {
          ClientData data = client.getClientData();
          String clientDescription = data.getClientDescription();
          if (clientDescription != null
              && clientDescription.equals(targetPackage)
              && (changeMask & CHANGE_MASK) != 0
              && data.getDebuggerConnectionStatus().equals(ClientData.DebuggerStatus.WAITING)) {
            reattachDebugger(launchInfo, client, launchStatus, printer);
          }
        }
      };

  AndroidDebugBridge.addClientChangeListener(reattachingListener);
  runContext.addLaunchTaskCompleteListener(
      () -> {
        AndroidDebugBridge.removeClientChangeListener(reattachingListener);
        launchStatus.terminateLaunch("Test run completed.\n", true);
      });
}
 
Example #21
Source File: MyDeviceChooser.java    From ADB-Duang with MIT License 5 votes vote down vote up
@NotNull
private IDevice[] getFilteredDevices(AndroidDebugBridge bridge) {
  final List<IDevice> filteredDevices = new ArrayList<IDevice>();
  for (IDevice device : bridge.getDevices()) {
    if (myFilter == null || myFilter.value(device)) {
      filteredDevices.add(device);
    }
  }
  // Do not filter launching cloud device as they are just unselectable progress markers
  // that are replaced with the actual cloud device as soon as they are up and the actual cloud device will be filtered above.
  return filteredDevices.toArray(new IDevice[filteredDevices.size()]);
}
 
Example #22
Source File: AdbHelper.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * 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, int adbTimeout)
    throws InterruptedException {
  DdmPreferences.setTimeOut(adbTimeout);

  try {
    AndroidDebugBridge.init(/* clientSupport */ false);
  } catch (IllegalStateException ex) {
    // ADB was already initialized, we're fine, so just ignore.
  }

  String adbExecutable = androidPlatformTarget.getAdbExecutable().toString();
  log.debug("Using %s to create AndroidDebugBridge", adbExecutable);
  AndroidDebugBridge adb = AndroidDebugBridge.createBridge(adbExecutable, 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;
}
 
Example #23
Source File: LogDevicesComboBoxSupport.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #24
Source File: Installer.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example #25
Source File: MonkeyTestDevice.java    From Android-Monkey-Adapter with Apache License 2.0 5 votes vote down vote up
public boolean connect() {
    boolean result = false;
    for (IDevice device : AndroidDebugBridge.getBridge().getDevices()) {
        if (mDevice.getSerialNumber().equals(device.getSerialNumber())
                && mDevice.getState() == DeviceState.ONLINE) {
            mDevice = device;
            result = true;
            break;
        }
    }
    return result;
}
 
Example #26
Source File: DeviceConnectHelper.java    From Android-Monkey-Adapter with Apache License 2.0 5 votes vote down vote up
public IDevice getConnecedDevice(final String serialNumber) {
    for (IDevice device : AndroidDebugBridge.getBridge().getDevices()) {
        if (serialNumber.equals(device.getSerialNumber())
                && device.getState() == DeviceState.ONLINE) {
            return device;
        }
    }
    return null;
}
 
Example #27
Source File: AdbNode.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void updateDescription() {
    setName(NAME);
    setDisplayName(NAME);
    final AndroidDebugBridge debugBridge = AndroidSdkProvider.getAdb();
    broken = debugBridge == null;
    String description = broken ? "Debugbridge broken! Please restart ADB!" : NAME;
    setShortDescription(description);
}
 
Example #28
Source File: RealAndroidDevice.java    From buck with Apache License 2.0 5 votes vote down vote up
private SocketChannel getSyncService() throws Exception {
  // Create a socket and send the necessary requests to adb daemon
  SocketChannel chan = SocketChannel.open(AndroidDebugBridge.getSocketAddress());

  // Set a timeout for the blocking channel
  chan.socket().setSoTimeout(DEFAULT_TIMEOUT);

  // Set the channel to be blocking
  chan.configureBlocking(true);

  String msg = "host:transport:" + device.getSerialNumber();
  byte[] device_query = formAdbRequest(msg); // req = length + command

  writeAllToChannel(chan, ByteBuffer.wrap(device_query));
  byte[] resp = readResp(chan, 4);

  if (!isOkay(resp)) {
    throw new HumanReadableException(
        "ADB daemon rejected switching connection to " + device.getSerialNumber());
  }

  byte[] sync_req = formAdbRequest("sync:");

  ByteBuffer b = ByteBuffer.wrap(sync_req);
  writeAllToChannel(chan, b);

  if (!isOkay(readResp(chan, 4))) {
    throw new HumanReadableException(
        "ADB daemon rejected starting sync service to " + device.getSerialNumber());
  }

  return chan;
}
 
Example #29
Source File: DevicesNode.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void updateDescription() {
    setName(NAME);
    setDisplayName(NAME);
    final AndroidDebugBridge debugBridge = AndroidSdkProvider.getAdb();
    broken = debugBridge == null;
    String description = broken ? "Debugbridge broken! Please restart ADB!" : NAME;
    setShortDescription(description);
}
 
Example #30
Source File: DdmlibAdbServer.java    From bundletool with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void close() {
  if (state.equals(State.INITIALIZED)) {
    AndroidDebugBridge.terminate();
  }
  state = State.CLOSED;
}