Java Code Examples for android.os.Debug#waitForDebugger()

The following examples show how to use android.os.Debug#waitForDebugger() . 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: AndroidTestOrchestrator.java    From android-test with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle arguments) {
  // Wait for debugger if debug argument is passed
  if (debugOrchestrator(arguments)) {
    Log.i(TAG, "Waiting for debugger to connect to ATO...");
    Debug.waitForDebugger();
    Log.i(TAG, "Debugger connected.");
  }

  if (null == arguments.getString(TARGET_INSTRUMENTATION_ARGUMENT)) {
    throw new IllegalArgumentException("You must provide a target instrumentation.");
  }

  this.arguments = arguments;
  this.arguments.putString(ORCHESTRATOR_SERVICE_ARGUMENT, ORCHESTRATOR_SERVICE_LOCATION);

  super.onCreate(arguments);
  start();
}
 
Example 2
Source File: AwShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    AwShellResourceProvider.registerResources(this);

    CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");

    if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGGER)) {
       Log.e(TAG, "Waiting for Java debugger to connect...");
       Debug.waitForDebugger();
       Log.e(TAG, "Java debugger connected. Resuming execution.");
    }

    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAKS);
    ResourceExtractor.setExtractImplicitLocaleForTesting(false);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
    AwBrowserProcess.loadLibrary();
    AwBrowserProcess.start(this);
}
 
Example 3
Source File: AwShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    AwShellResourceProvider.registerResources(this);

    CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");

    if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGGER)) {
       Log.e(TAG, "Waiting for Java debugger to connect...");
       Debug.waitForDebugger();
       Log.e(TAG, "Java debugger connected. Resuming execution.");
    }

    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAKS);
    ResourceExtractor.setExtractImplicitLocaleForTesting(false);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
    AwBrowserProcess.loadLibrary();
    AwBrowserProcess.start(this);
}
 
Example 4
Source File: AwShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    AwShellResourceProvider.registerResources(this);

    CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");

    if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGGER)) {
       Log.e(TAG, "Waiting for Java debugger to connect...");
       Debug.waitForDebugger();
       Log.e(TAG, "Java debugger connected. Resuming execution.");
    }

    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAKS);
    ResourceExtractor.setExtractImplicitLocaleForTesting(false);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
    AwBrowserProcess.loadLibrary();
    AwBrowserProcess.start(this);
}
 
Example 5
Source File: AwShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    AwShellResourceProvider.registerResources(this);

    CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");

    if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGGER)) {
       Log.e(TAG, "Waiting for Java debugger to connect...");
       Debug.waitForDebugger();
       Log.e(TAG, "Java debugger connected. Resuming execution.");
    }

    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAKS);
    ResourceExtractor.setExtractImplicitLocaleForTesting(false);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
    AwBrowserProcess.loadLibrary();
    AwBrowserProcess.start(this);
}
 
Example 6
Source File: CameraApp.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate()
{
    super.onCreate();

    if (WAIT_FOR_DEBUGGER_ON_START)
    {
        Debug.waitForDebugger();
    }

    // Android context must be the first item initialized.
    Context context = getApplicationContext();
    AndroidContext.initialize(context);

    // This will measure and write to the exception handler if
    // the time between any two calls or the total time from
    // start to stop is over 10ms.
    Profile guard = Profilers.instance().guard("CameraApp onCreate()");

    // It is important that this gets called early in execution before the
    // app has had the opportunity to touch shared preferences.
    FirstRunDetector.instance().initializeTimeOfFirstRun(context);
    guard.mark("initializeTimeOfFirstRun");

    UsageStatistics.instance().initialize(this);
    guard.mark("UsageStatistics.initialize");

    clearNotifications();
    guard.stop("clearNotifications");
}
 
Example 7
Source File: AndroidJUnitRunner.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle arguments) {
  super.onCreate(arguments);
  this.arguments = arguments;
  parseRunnerArgs(this.arguments);

  if (waitForDebugger(runnerArgs)) {
    Log.i(LOG_TAG, "Waiting for debugger to connect...");
    Debug.waitForDebugger();
    Log.i(LOG_TAG, "Debugger connected.");
  }

  // We are only interested in tracking usage of the primary process.
  if (isPrimaryInstrProcess(runnerArgs.targetProcess)) {
    usageTrackerFacilitator = new UsageTrackerFacilitator(runnerArgs);
  } else {
    usageTrackerFacilitator = new UsageTrackerFacilitator(false);
  }


  for (ApplicationLifecycleCallback listener : runnerArgs.appListeners) {
    ApplicationLifecycleMonitorRegistry.getInstance().addLifecycleCallback(listener);
  }

  addScreenCaptureProcessors(runnerArgs);

  if (runnerArgs.orchestratorService != null && isPrimaryInstrProcess(runnerArgs.targetProcess)) {
    // If orchestratorService is provided, and we are the primary process
    // we await onOrchestratorConnect() before we start().
    orchestratorListener = new OrchestratedInstrumentationListener(this);
    orchestratorListener.connect(getContext());
  } else {
    // If no orchestration service is given, or we are not the primary process we can
    // start() immediately.
    start();
  }
}
 
Example 8
Source File: MyUiAutomatorTestRunner.java    From PUMA with Apache License 2.0 4 votes vote down vote up
/**
 * Called after all test classes are in place, ready to test
 */
protected void start() {
	TestCaseCollector collector = getTestCaseCollector(this.getClass().getClassLoader());
	try {
		collector.addTestClasses(mTestClasses);
	} catch (ClassNotFoundException e) {
		// will be caught by uncaught handler
		throw new RuntimeException(e.getMessage(), e);
	}
	if (mDebug) {
		Debug.waitForDebugger();
	}
	mHandlerThread = new HandlerThread(HANDLER_THREAD_NAME);
	mHandlerThread.setDaemon(true);
	mHandlerThread.start();
	UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
	automationWrapper.connect();

	long startTime = SystemClock.uptimeMillis();
	TestResult testRunResult = new TestResult();
	ResultReporter resultPrinter;
	String outputFormat = mParams.getString("outputFormat");
	List<TestCase> testCases = collector.getTestCases();
	Bundle testRunOutput = new Bundle();
	if ("simple".equals(outputFormat)) {
		resultPrinter = new SimpleResultPrinter(System.out, true);
	} else {
		resultPrinter = new WatcherResultPrinter(testCases.size());
	}
	try {
		automationWrapper.setRunAsMonkey(mMonkey);
		mUiDevice = MyUiDevice.getInstance();
		UiAutomation uiAutomation = automationWrapper.getUiAutomation();
		mUiDevice.initialize(new ShellUiAutomatorBridge(uiAutomation));
		mUiDevice.setUiAutomation(uiAutomation);

		String traceType = mParams.getString("traceOutputMode");
		if (traceType != null) {
			Tracer.Mode mode = Tracer.Mode.valueOf(Tracer.Mode.class, traceType);
			if (mode == Tracer.Mode.FILE || mode == Tracer.Mode.ALL) {
				String filename = mParams.getString("traceLogFilename");
				if (filename == null) {
					throw new RuntimeException("Name of log file not specified. " + "Please specify it using traceLogFilename parameter");
				}
				Tracer.getInstance().setOutputFilename(filename);
			}
			Tracer.getInstance().setOutputMode(mode);
		}

		// add test listeners
		testRunResult.addListener(resultPrinter);
		// add all custom listeners
		for (TestListener listener : mTestListeners) {
			testRunResult.addListener(listener);
		}

		// run tests for realz!
		for (TestCase testCase : testCases) {
			prepareTestCase(testCase);
			testCase.run(testRunResult);
		}
	} catch (Throwable t) {
		// catch all exceptions so a more verbose error message can be outputted
		resultPrinter.printUnexpectedError(t);
	} finally {
		long runTime = SystemClock.uptimeMillis() - startTime;
		resultPrinter.print(testRunResult, runTime, testRunOutput);
		automationWrapper.disconnect();
		automationWrapper.setRunAsMonkey(false);
		mHandlerThread.quit();
	}
}