Pass callingPackage in UserLifecycleTest#startApp

Calling IActivityTaskManager#startActivity requires the callingPackage
to be set correctly as of ag/8668823, otherwise a SecurityException is
thrown.

Bug: 138095678
Test: Enable multi-user by declaring the
      "android.software.managed_users" feature and setting
      "config_multiuserMaximumUsers" to greather than 1. Then:
      `atest android.multiuser.UserLifecycleTests#managedProfileUnlockAndLaunchApp`

Change-Id: Iab7cf0198a02a976ef5c54e4b87fb127aa7eac9a
This commit is contained in:
Robert Horvath
2019-07-24 16:28:29 +02:00
parent cac13d44ab
commit 5f47c59103

View File

@@ -530,10 +530,10 @@ public class UserLifecycleTests {
*/
private void startApp(int userId, String packageName) throws RemoteException {
final Context context = InstrumentationRegistry.getContext();
final WaitResult result = ActivityTaskManager.getService().startActivityAndWait(null, null,
context.getPackageManager().getLaunchIntentForPackage(packageName),
null, null, null, 0, 0, null, null,
userId);
final WaitResult result = ActivityTaskManager.getService().startActivityAndWait(null,
context.getPackageName(),
context.getPackageManager().getLaunchIntentForPackage(packageName), null, null,
null, 0, 0, null, null, userId);
attestTrue("User " + userId + " failed to start " + packageName,
result.result == ActivityManager.START_SUCCESS);
}