From 06ef5afb1c5b435e4787154291f819475ae7a896 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 16 Oct 2018 15:32:41 -0700 Subject: [PATCH] Removing douple lookup when calling startActivityAsUser Test: atest \ com.android.cts.devicepolicy.LauncherAppsMultiUserTest \ com.android.cts.devicepolicy.LauncherAppsProfileTest \ com.android.cts.devicepolicy.LauncherAppsSingleUserTest Bug: 117888136 Change-Id: Ia25058b3bb2fb6cf57eedc5eecae4cb99275b4e7 --- .../com/android/server/pm/LauncherAppsService.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index a08c189cb1253..404f152bb8d1e 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -659,15 +659,6 @@ public class LauncherAppsService extends SystemService { try { final PackageManagerInternal pmInt = LocalServices.getService(PackageManagerInternal.class); - ActivityInfo info = pmInt.getActivityInfo(component, - PackageManager.MATCH_DIRECT_BOOT_AWARE - | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, - callingUid, user.getIdentifier()); - if (!info.exported) { - throw new SecurityException("Cannot launch non-exported components " - + component); - } - // Check that the component actually has Intent.CATEGORY_LAUCNCHER // as calling startActivityAsUser ignores the category and just // resolves based on the component if present. @@ -680,6 +671,11 @@ public class LauncherAppsService extends SystemService { ActivityInfo activityInfo = apps.get(i).activityInfo; if (activityInfo.packageName.equals(component.getPackageName()) && activityInfo.name.equals(component.getClassName())) { + if (!activityInfo.exported) { + throw new SecurityException("Cannot launch non-exported components " + + component); + } + // Found an activity with category launcher that matches // this component so ok to launch. launchIntent.setPackage(null);