Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a388f32 authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Automerger Merge Worker
Browse files

Merge "Start test apks via adb command instead of calling the API directly."...

Merge "Start test apks via adb command instead of calling the API directly." into udc-dev am: d8c71e5d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22887198



Change-Id: Id81619557a2f5384290ead73d3920836aec76be7
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 291dbc7f d8c71e5d
Loading
Loading
Loading
Loading
+14 −10
Original line number Original line Diff line number Diff line
@@ -24,11 +24,9 @@ import static org.junit.Assume.assumeTrue;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.AppGlobals;
import android.app.IActivityManager;
import android.app.IActivityManager;
import android.app.IStopUserCallback;
import android.app.IStopUserCallback;
import android.app.WaitResult;
import android.app.WallpaperManager;
import android.app.WallpaperManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
@@ -1387,14 +1385,20 @@ public class UserLifecycleTests {
     * Launches the given package in the given user.
     * Launches the given package in the given user.
     * Make sure the keyguard has been dismissed prior to calling.
     * Make sure the keyguard has been dismissed prior to calling.
     */
     */
    private void startApp(int userId, String packageName) throws RemoteException {
    private void startApp(int userId, String packageName) {
        final Context context = InstrumentationRegistry.getContext();
        final String failMessage = "User " + userId + " failed to start " + packageName;
        final WaitResult result = ActivityTaskManager.getService().startActivityAndWait(null,
        final String component = InstrumentationRegistry.getContext().getPackageManager()
                context.getPackageName(), context.getAttributionTag(),
                .getLaunchIntentForPackage(packageName).getComponent().flattenToShortString();
                context.getPackageManager().getLaunchIntentForPackage(packageName), null, null,
        try {
                null, 0, 0, null, null, userId);
            final String result = ShellHelper.runShellCommandWithTimeout(
        attestTrue("User " + userId + " failed to start " + packageName,
                    "am start -W -n " + component + " --user " + userId, TIMEOUT_IN_SECOND);
                result.result == ActivityManager.START_SUCCESS);
            assertTrue(failMessage + ", component=" + component + ", result=" + result,
                    result.contains("Status: ok")
                    && !result.contains("Warning:")
                    && !result.contains("Error:"));
        } catch (TimeoutException e) {
            fail(failMessage + " in " + TIMEOUT_IN_SECOND + " seconds");
        }
    }
    }


    private class ProgressWaiter extends IProgressListener.Stub {
    private class ProgressWaiter extends IProgressListener.Stub {