Java Code Examples for com.android.ddmlib.AndroidDebugBridge#terminate()

The following examples show how to use com.android.ddmlib.AndroidDebugBridge#terminate() . 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: 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;
}
 
Example 2
Source File: Main.java    From FuzzDroid with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {		
	Timer timer = new Timer();
       timer.schedule(new TimerTask() {        	
           @Override
           public void run() {
           	LoggerHelper.logEvent(MyLevel.TIMEOUT, "-1 | Complete analysis stopped due to timeout of 40 minutes");
               System.exit(0);
           }
       }, 40 * 60000);
	
	
	try{
		Main.v().run(args);
		AndroidDebugBridge.terminate();
	}catch(Exception ex) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		ex.printStackTrace(pw);			
		LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, sw.toString());
		UtilMain.writeToFile("mainException.txt", FrameworkOptions.apkPath + "\n");
	}
	LoggerHelper.logEvent(MyLevel.EXECUTION_STOP, "Analysis successfully terminated");
	//this is necessary otherwise we will wait for a max of 20 minutes for the TimerTask
	System.exit(0);
}
 
Example 3
Source File: FrameworkEventManager.java    From FuzzDroid with Apache License 2.0 5 votes vote down vote up
private void waitForDevice() {
	long start = System.currentTimeMillis();
	while (adb.hasInitialDeviceList() == false) {
		long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
		
		if (timeLeft <= 0) {
			break;
		}
		
		try{
			Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
		}catch(Exception ex) {
			LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, ex.getMessage());
			ex.printStackTrace();
		}
	}
	
	if(!adb.hasInitialDeviceList()) {
		LoggerHelper.logEvent(MyLevel.EXCEPTION_RUNTIME, "NOT POSSIBLE TO CONNECT TO ADB -- giving up and close program!");
		System.exit(-1);
	}
	
	int count = 0;		
	while (adb.getDevices().length == 0) {
		try {
			Thread.sleep(5000);
			LoggerHelper.logEvent(MyLevel.RUNTIME, "not possible to find a device...");
			count++;
		} catch (InterruptedException e) {
			LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, e.getMessage());
			e.printStackTrace();
			AndroidDebugBridge.terminate();
		}
		if (count > 50) {
			LoggerHelper
					.logEvent(MyLevel.RUNTIME, "After 100 seconds not able to find an Android device. Shutting down...");
			AndroidDebugBridge.terminate();				
		}
	}
}
 
Example 4
Source File: ADB.java    From android-screen-monitor with Apache License 2.0 4 votes vote down vote up
public void terminate() {
	AndroidDebugBridge.terminate();
}