From 516020a523558d1603f759d5bc566d7ba7572ace Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Mon, 28 Jan 2019 14:16:42 -0800 Subject: [PATCH] Fix LauncherApps.isActivityEnalbed() It should say false for disabled activities too. Fix: 113135768 Test: manual test with "pm disable com.google.android.deskclock/com.android.deskclock.DeskClock" and "pm enable" Change-Id: Ib5d986178a1f37ef60268ff3cc58271b1e2808e7 --- core/java/android/content/pm/LauncherApps.java | 3 +++ .../java/com/android/server/pm/LauncherAppsService.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 89630e15972e1..4ccf419be543c 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -781,6 +781,9 @@ public class LauncherApps { /** * Checks if the activity exists and it enabled for a profile. * + *

The activity may still not be exported, in which case {@link #startMainActivity} will + * throw a {@link SecurityException} unless the caller has the same UID as the target app's. + * * @param component The activity to check. * @param user The UserHandle of the profile. * diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index d0ef4f1523d41..e509c79a793fe 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -837,7 +837,11 @@ public class LauncherAppsService extends SystemService { PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, callingUid, user.getIdentifier()); - return info != null; + // Note we don't check "exported" because if the caller has the same UID as the + // callee's UID, it can still be launched. + // (If an app doesn't export a front door activity and causes issues with the + // launcher, that's just the app's bug.) + return info != null && info.isEnabled(); } finally { Binder.restoreCallingIdentity(ident); }