synchronized boolean startAdb(){
  if (mAdbOsLocation == null) {
    Log.e(ADB,"Cannot start adb when AndroidDebugBridge is created without the location of adb.");
    return false;
  }
  if (sAdbServerPort == 0) {
    Log.w(ADB,"ADB server port for starting AndroidDebugBridge is not set.");
    return false;
  }
  Process proc;
  int status=-1;
  String[] command=getAdbLaunchCommand("start-server");
  String commandString=join(command,",");
  try {
    Log.d(DDMS,String.format("Launching '%1$s' to ensure ADB is running.",commandString));
    ProcessBuilder processBuilder=new ProcessBuilder(command);
    if (DdmPreferences.getUseAdbHost()) {
      String adbHostValue=DdmPreferences.getAdbHostValue();
      if (adbHostValue != null && !adbHostValue.isEmpty()) {
        Map<String,String> env=processBuilder.environment();
        env.put("ADBHOST",adbHostValue);
      }
    }
    proc=processBuilder.start();
    ArrayList<String> errorOutput=new ArrayList<>();
    ArrayList<String> stdOutput=new ArrayList<>();
    status=grabProcessOutput(proc,errorOutput,stdOutput,false);
  }
 catch (  IOException|InterruptedException ioe) {
    Log.e(DDMS,"Unable to run 'adb': " + ioe.getMessage());
  }
  if (status != 0) {
    Log.e(DDMS,String.format("'%1$s' failed -- run manually if necessary",commandString));
    return false;
  }
 else {
    Log.d(DDMS,String.format("'%1$s' succeeded",commandString));
    return true;
  }
}

synchronized boolean startAdb ( ) { if ( mAdbOsLocation == null ) { Log . e ( ADB , "Cannot start adb when AndroidDebugBridge is created without the location of adb." ) ; return false ; } if ( sAdbServerPort == 0 ) { Log . w ( ADB , "ADB server port for starting AndroidDebugBridge is not set." ) ; return false ; } Process proc ; int status = - 1 ; String [ ] command = getAdbLaunchCommand ( "start-server" ) ; String commandString = join ( command , "," ) ; try { Log . d ( DDMS , String . format ( "Launching '%1$s' to ensure ADB is running." , commandString ) ) ; ProcessBuilder processBuilder = new ProcessBuilder ( command ) ; if ( DdmPreferences . getUseAdbHost ( ) ) { String adbHostValue = DdmPreferences . getAdbHostValue ( ) ; if ( adbHostValue != null && ! adbHostValue . isEmpty ( ) ) { Map < String , String > env = processBuilder . environment ( ) ; env . put ( "ADBHOST" , adbHostValue ) ; } } proc = processBuilder . start ( ) ; ArrayList < String > errorOutput = new ArrayList < > ( ) ; ArrayList < String > stdOutput = new ArrayList < > ( ) ; status = grabProcessOutput ( proc , errorOutput , stdOutput , false ) ; } catch ( IOException | InterruptedException ioe ) { Log . e ( DDMS , "Unable to run 'adb': " + ioe . getMessage ( ) ) ; } if ( status != 0 ) { Log . e ( DDMS , String . format ( "'%1$s' failed -- run manually if necessary" , commandString ) ) ; return false ; } else { Log . d ( DDMS , String . format ( "'%1$s' succeeded" , commandString ) ) ; return true ; } }
starts the adb host side server .
