Search in sources :

Example 1 with BlazeAndroidDeployInfo

use of com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo in project intellij by bazelbuild.

the class BlazeAndroidBinaryApplicationIdProvider method getPackageName.

@Override
public String getPackageName() throws ApkProvisionException {
    BlazeAndroidDeployInfo deployInfo = buildStep.getDeployInfo();
    Manifest manifest = deployInfo.getMergedManifest();
    if (manifest == null) {
        throw new ApkProvisionException("Could not find merged manifest: " + deployInfo.getMergedManifestFile());
    }
    String applicationId = ApplicationManager.getApplication().runReadAction((Computable<String>) () -> manifest.getPackage().getValue());
    if (applicationId == null) {
        throw new ApkProvisionException("No application id in merged manifest: " + deployInfo.getMergedManifestFile());
    }
    return applicationId;
}
Also used : ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) Manifest(org.jetbrains.android.dom.manifest.Manifest)

Example 2 with BlazeAndroidDeployInfo

use of com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo in project intellij by bazelbuild.

the class BlazeAndroidBinaryNormalBuildRunContext method getApplicationLaunchTask.

@Override
public LaunchTask getApplicationLaunchTask(LaunchOptions launchOptions, @Nullable Integer userId, AndroidDebugger androidDebugger, AndroidDebuggerState androidDebuggerState, ProcessHandlerLaunchStatus processHandlerLaunchStatus) throws ExecutionException {
    final StartActivityFlagsProvider startActivityFlagsProvider = new DefaultStartActivityFlagsProvider(androidDebugger, androidDebuggerState, project, launchOptions.isDebug(), UserIdHelper.getFlagsFromUserId(userId));
    BlazeAndroidDeployInfo deployInfo;
    try {
        deployInfo = buildStep.getDeployInfo();
    } catch (ApkProvisionException e) {
        throw new ExecutionException(e);
    }
    return BlazeAndroidBinaryApplicationLaunchTaskProvider.getApplicationLaunchTask(project, applicationIdProvider, deployInfo.getMergedManifestFile(), configState, startActivityFlagsProvider, processHandlerLaunchStatus);
}
Also used : DefaultStartActivityFlagsProvider(com.android.tools.idea.run.activity.DefaultStartActivityFlagsProvider) ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) StartActivityFlagsProvider(com.android.tools.idea.run.activity.StartActivityFlagsProvider) DefaultStartActivityFlagsProvider(com.android.tools.idea.run.activity.DefaultStartActivityFlagsProvider) ExecutionException(com.intellij.execution.ExecutionException)

Example 3 with BlazeAndroidDeployInfo

use of com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo in project intellij by bazelbuild.

the class BlazeAndroidTestApplicationIdProvider method getPackageName.

@Override
public String getPackageName() throws ApkProvisionException {
    BlazeAndroidDeployInfo deployInfo = buildStep.getDeployInfo();
    Manifest manifest = Iterables.getFirst(deployInfo.getAdditionalMergedManifests(), null);
    if (manifest == null) {
        // and can instead be in the same package as the tests.
        return getTestPackageName();
    }
    String applicationId = ApplicationManager.getApplication().runReadAction((Computable<String>) () -> manifest.getPackage().getValue());
    if (applicationId == null) {
        throw new ApkProvisionException("No application id in manifest under test");
    }
    return applicationId;
}
Also used : ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) Manifest(org.jetbrains.android.dom.manifest.Manifest)

Example 4 with BlazeAndroidDeployInfo

use of com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo in project intellij by bazelbuild.

the class BlazeAndroidTestApplicationIdProvider method getTestPackageName.

@Nullable
@Override
public String getTestPackageName() throws ApkProvisionException {
    BlazeAndroidDeployInfo deployInfo = buildStep.getDeployInfo();
    Manifest manifest = deployInfo.getMergedManifest();
    if (manifest == null) {
        throw new ApkProvisionException("Could not find merged manifest: " + deployInfo.getMergedManifestFile());
    }
    String applicationId = ApplicationManager.getApplication().runReadAction((Computable<String>) () -> manifest.getPackage().getValue());
    if (applicationId == null) {
        throw new ApkProvisionException("No application id in merged manifest: " + deployInfo.getMergedManifestFile());
    }
    return applicationId;
}
Also used : ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) Manifest(org.jetbrains.android.dom.manifest.Manifest) Nullable(javax.annotation.Nullable)

Example 5 with BlazeAndroidDeployInfo

use of com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo in project intellij by bazelbuild.

the class BlazeAndroidBinaryMobileInstallRunContext method getApplicationLaunchTask.

@Override
public LaunchTask getApplicationLaunchTask(LaunchOptions launchOptions, @Nullable Integer userId, AndroidDebugger androidDebugger, AndroidDebuggerState androidDebuggerState, ProcessHandlerLaunchStatus processHandlerLaunchStatus) throws ExecutionException {
    final StartActivityFlagsProvider startActivityFlagsProvider = new DefaultStartActivityFlagsProvider(androidDebugger, androidDebuggerState, project, launchOptions.isDebug(), UserIdHelper.getFlagsFromUserId(userId));
    BlazeAndroidDeployInfo deployInfo;
    try {
        deployInfo = buildStep.getDeployInfo();
    } catch (ApkProvisionException e) {
        throw new ExecutionException(e);
    }
    return BlazeAndroidBinaryApplicationLaunchTaskProvider.getApplicationLaunchTask(project, applicationIdProvider, deployInfo.getMergedManifestFile(), configState, startActivityFlagsProvider, processHandlerLaunchStatus);
}
Also used : DefaultStartActivityFlagsProvider(com.android.tools.idea.run.activity.DefaultStartActivityFlagsProvider) ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) StartActivityFlagsProvider(com.android.tools.idea.run.activity.StartActivityFlagsProvider) DefaultStartActivityFlagsProvider(com.android.tools.idea.run.activity.DefaultStartActivityFlagsProvider) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

ApkProvisionException (com.android.tools.idea.run.ApkProvisionException)5 BlazeAndroidDeployInfo (com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo)5 Manifest (org.jetbrains.android.dom.manifest.Manifest)3 DefaultStartActivityFlagsProvider (com.android.tools.idea.run.activity.DefaultStartActivityFlagsProvider)2 StartActivityFlagsProvider (com.android.tools.idea.run.activity.StartActivityFlagsProvider)2 ExecutionException (com.intellij.execution.ExecutionException)2 Nullable (javax.annotation.Nullable)1