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

Commit 3b9e4bda authored by lumark's avatar lumark
Browse files

Add CLEAR_APP_CACHE check for deletePreloadsFileCache.

StorageManager is priv-app & need add CLEAR_APP_CACHE permission to
access deletePreloadsFileCache.

Bug: 36595933
Test: adb shell service call package <api> to verify non-priv-app, fail.
Test: adb shell service call package <api> to verify priv-app with CLEAR_APP_CACHE, success.
Change-Id: Ie9f13285a725d9bf4b552617ee13c1eb142a3609
parent 6ec9142d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -4506,9 +4506,8 @@ public class PackageManagerService extends IPackageManager.Stub
    @Override
    public void deletePreloadsFileCache() {
        if (!UserHandle.isSameApp(Binder.getCallingUid(), Process.SYSTEM_UID)) {
            throw new SecurityException("Only system or settings may call deletePreloadsFileCache");
        }
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CLEAR_APP_CACHE,
                "deletePreloadsFileCache");
        File dir = Environment.getDataPreloadsFileCacheDirectory();
        Slog.i(TAG, "Deleting preloaded file cache " + dir);
        FileUtils.deleteContents(dir);