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

Commit e9abb755 authored by Varun Shah's avatar Varun Shah
Browse files

Allow only Recents to query app usage limit info.

The active launcher will no longer be able to query #getAppUsageLimit.

Bug: 124126265
Test: manual (verified SecurityException is not thrown anymore for Recents)
Change-Id: Ic948cf16232e7585eb74523ed360680aca9ceaf1
parent fe2c7ed9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -792,7 +792,7 @@ public class LauncherApps {
     *
     * @return an {@link AppUsageLimit} object describing the app time limit containing
     * the given package with the smallest time remaining, or {@code null} if none exist.
     * @throws SecurityException when the caller is not the active launcher.
     * @throws SecurityException when the caller is not the recents app.
     */
    @Nullable
    public LauncherApps.AppUsageLimit getAppUsageLimit(String packageName, UserHandle user) {
+2 −6
Original line number Diff line number Diff line
@@ -744,12 +744,8 @@ public class LauncherAppsService extends SystemService {
            if (!canAccessProfile(user.getIdentifier(), "Cannot access usage limit")) {
                return null;
            }

            final PackageManagerInternal pmi =
                    LocalServices.getService(PackageManagerInternal.class);
            final ComponentName cn = pmi.getDefaultHomeActivity(user.getIdentifier());
            if (!cn.getPackageName().equals(callingPackage)) {
                throw new SecurityException("Caller is not the active launcher");
            if (!mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid())) {
                throw new SecurityException("Caller is not the recents app");
            }

            final UsageStatsManagerInternal.AppUsageLimitData data =