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

Commit df113c36 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Add internal implementation for notifyPackageUse

We have checks that prevent applications from modifying the usage
times of instant apps [and vice versa]. However, it's critical for
internal components such as the ActivityManager to be able to upate
this for all packages. Add an internal implementation of this
method that skips the checks.

Change-Id: Ib890296065024104cdaf7c8d64a5a7583d9062c1
Fixes: 65228752
Test: Manual. Run an application installed as an "instant app" and notice the usage time goes up
parent d9abde75
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -378,4 +378,9 @@ public abstract class PackageManagerInternal {
     * associated with an instant app. It may be kept after the instant app has been uninstalled.
     */
    public abstract boolean hasInstantApplicationMetadata(String packageName, int userId);

    /**
     * Updates a package last used time.
     */
    public abstract void notifyPackageUse(String packageName, int reason);
}
+2 −4
Original line number Diff line number Diff line
@@ -3579,10 +3579,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    void notifyPackageUse(String packageName, int reason) {
        IPackageManager pm = AppGlobals.getPackageManager();
        try {
            pm.notifyPackageUse(packageName, reason);
        } catch (RemoteException e) {
        synchronized(this) {
            getPackageManagerInternalLocked().notifyPackageUse(packageName, reason);
        }
    }
+16 −5
Original line number Diff line number Diff line
@@ -9844,13 +9844,17 @@ public class PackageManagerService extends IPackageManager.Stub
                    return;
                }
            }
            notifyPackageUseLocked(packageName, reason);
        }
    }
    private void notifyPackageUseLocked(String packageName, int reason) {
        final PackageParser.Package p = mPackages.get(packageName);
        if (p == null) {
            return;
        }
        p.mLastPackageUsageTimeInMills[reason] = System.currentTimeMillis();
    }
    }
    @Override
    public void notifyDexLoad(String loadingPackageName, List<String> classLoaderNames,
@@ -25502,6 +25506,13 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
                return mInstantAppRegistry.hasInstantApplicationMetadataLPr(packageName, userId);
            }
        }
        @Override
        public void notifyPackageUse(String packageName, int reason) {
            synchronized (mPackages) {
                PackageManagerService.this.notifyPackageUseLocked(packageName, reason);
            }
        }
    }
    @Override