Search in sources :

Example 1 with AndroidDebuggerContext

use of com.android.tools.idea.run.editor.AndroidDebuggerContext in project android by JetBrains.

the class AndroidLaunchTasksProvider method getConnectDebuggerTask.

@Nullable
@Override
public DebugConnectorTask getConnectDebuggerTask(@NotNull LaunchStatus launchStatus, @Nullable AndroidVersion version) {
    if (!myLaunchOptions.isDebug()) {
        return null;
    }
    Logger logger = Logger.getInstance(AndroidLaunchTasksProvider.class);
    Set<String> packageIds = Sets.newHashSet();
    try {
        String packageName = myApplicationIdProvider.getPackageName();
        packageIds.add(packageName);
    } catch (ApkProvisionException e) {
        logger.error(e);
    }
    try {
        String packageName = myApplicationIdProvider.getTestPackageName();
        if (packageName != null) {
            packageIds.add(packageName);
        }
    } catch (ApkProvisionException e) {
        // not as severe as failing to obtain package id for main application
        logger.warn("Unable to obtain test package name, will not connect debugger if tests don't instantiate main application");
    }
    AndroidDebuggerContext androidDebuggerContext = myRunConfig.getAndroidDebuggerContext();
    AndroidDebugger debugger = androidDebuggerContext.getAndroidDebugger();
    if (debugger == null) {
        logger.warn("Unable to determine debugger to use for this launch");
        return null;
    }
    logger.info("Using debugger: " + debugger.getId());
    AndroidDebuggerState androidDebuggerState = androidDebuggerContext.getAndroidDebuggerState();
    if (androidDebuggerState != null) {
        //noinspection unchecked
        return debugger.getConnectDebuggerTask(myEnv, version, packageIds, myFacet, androidDebuggerState, myRunConfig.getType().getId(), monitorRemoteProcess());
    }
    return null;
}
Also used : AndroidDebugger(com.android.tools.idea.run.editor.AndroidDebugger) AndroidDebuggerState(com.android.tools.idea.run.editor.AndroidDebuggerState) AndroidDebuggerContext(com.android.tools.idea.run.editor.AndroidDebuggerContext) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AndroidDebugger (com.android.tools.idea.run.editor.AndroidDebugger)1 AndroidDebuggerContext (com.android.tools.idea.run.editor.AndroidDebuggerContext)1 AndroidDebuggerState (com.android.tools.idea.run.editor.AndroidDebuggerState)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Nullable (org.jetbrains.annotations.Nullable)1