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

Commit 849dbffc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Keep overlay info for the android app info up to date"

parents e2aa12f9 83fb5ca0
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
@@ -799,6 +799,13 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    private AndroidPackage mPlatformPackage;
    ComponentName mCustomResolverComponentName;

    // Recorded overlay paths configuration for the Android app info.
    private String[] mPlatformPackageOverlayPaths = null;
    private String[] mPlatformPackageOverlayResourceDirs = null;
    // And the same paths for the replaced resolver activity package
    private String[] mReplacedResolverPackageOverlayPaths = null;
    private String[] mReplacedResolverPackageOverlayResourceDirs = null;

    private boolean mResolverReplaced = false;

    @NonNull
@@ -6563,9 +6570,63 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            });
        }

        if (userId == UserHandle.USER_SYSTEM) {
            // Keep the overlays in the system application info (and anything special cased as well)
            // up to date to make sure system ui is themed correctly.
            for (int i = 0; i < numberOfPendingChanges; i++) {
                final String targetPackageName = pendingChanges.keyAt(i);
                final OverlayPaths newOverlayPaths = pendingChanges.valueAt(i);
                maybeUpdateSystemOverlays(targetPackageName, newOverlayPaths);
            }
        }

        invalidatePackageInfoCache();
    }

    private void maybeUpdateSystemOverlays(String targetPackageName, OverlayPaths newOverlayPaths) {
        if (!mResolverReplaced) {
            if (targetPackageName.equals("android")) {
                if (newOverlayPaths == null) {
                    mPlatformPackageOverlayPaths = null;
                    mPlatformPackageOverlayResourceDirs = null;
                } else {
                    mPlatformPackageOverlayPaths = newOverlayPaths.getOverlayPaths().toArray(
                            new String[0]);
                    mPlatformPackageOverlayResourceDirs = newOverlayPaths.getResourceDirs().toArray(
                            new String[0]);
                }
                applyUpdatedSystemOverlayPaths();
            }
        } else {
            if (targetPackageName.equals(mResolveActivity.applicationInfo.packageName)) {
                if (newOverlayPaths == null) {
                    mReplacedResolverPackageOverlayPaths = null;
                    mReplacedResolverPackageOverlayResourceDirs = null;
                } else {
                    mReplacedResolverPackageOverlayPaths =
                            newOverlayPaths.getOverlayPaths().toArray(new String[0]);
                    mReplacedResolverPackageOverlayResourceDirs =
                            newOverlayPaths.getResourceDirs().toArray(new String[0]);
                }
                applyUpdatedSystemOverlayPaths();
            }
        }
    }

    private void applyUpdatedSystemOverlayPaths() {
        if (mAndroidApplication == null) {
            Slog.i(TAG, "Skipped the AndroidApplication overlay paths update - no app yet");
        } else {
            mAndroidApplication.overlayPaths = mPlatformPackageOverlayPaths;
            mAndroidApplication.resourceDirs = mPlatformPackageOverlayResourceDirs;
        }
        if (mResolverReplaced) {
            mResolveActivity.applicationInfo.overlayPaths = mReplacedResolverPackageOverlayPaths;
            mResolveActivity.applicationInfo.resourceDirs =
                    mReplacedResolverPackageOverlayResourceDirs;
        }
    }

    private void enforceAdjustRuntimePermissionsPolicyOrUpgradeRuntimePermissions(
            @NonNull String message) {
        if (mContext.checkCallingOrSelfPermission(
@@ -7027,6 +7088,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            }
            PackageManagerService.onChanged();
        }
        applyUpdatedSystemOverlayPaths();
    }

    ApplicationInfo getCoreAndroidApplication() {