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

Commit b9dfa31c authored by Louis Chang's avatar Louis Chang
Browse files

Update the application info of all activities

The application was applying the legacy theme when brought to the
foreground after theme switched. That's because the app process
was killed while the it was in the background and the application-info
that cached in the ActivityRecord was used next time starting app
process.

Bug: 280130977
Test: relaunch chrome after theme switched and manually kill process
Change-Id: Iea30ee6dd28a53b3fec226b24ffb567411d445a7
parent 8fe4e9d9
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -4907,6 +4907,18 @@ public final class ProcessList {
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    void updateApplicationInfoLOSP(List<String> packagesToUpdate, int userId,
            boolean updateFrameworkRes) {
        final ArrayMap<String, ApplicationInfo> applicationInfoByPackage = new ArrayMap<>();
        for (int i = packagesToUpdate.size() - 1; i >= 0; i--) {
            final String packageName = packagesToUpdate.get(i);
            final ApplicationInfo ai = mService.getPackageManagerInternal().getApplicationInfo(
                    packageName, STOCK_PM_FLAGS, Process.SYSTEM_UID, userId);
            if (ai != null) {
                applicationInfoByPackage.put(packageName, ai);
            }
        }
        mService.mActivityTaskManager.updateActivityApplicationInfo(userId,
                applicationInfoByPackage);

        final ArrayList<WindowProcessController> targetProcesses = new ArrayList<>();
        for (int i = mLruProcesses.size() - 1; i >= 0; i--) {
            final ProcessRecord app = mLruProcesses.get(i);
@@ -4921,8 +4933,7 @@ public final class ProcessList {
            app.getPkgList().forEachPackage(packageName -> {
                if (updateFrameworkRes || packagesToUpdate.contains(packageName)) {
                    try {
                        final ApplicationInfo ai = AppGlobals.getPackageManager()
                                .getApplicationInfo(packageName, STOCK_PM_FLAGS, app.userId);
                        final ApplicationInfo ai = applicationInfoByPackage.get(packageName);
                        if (ai != null) {
                            if (ai.packageName.equals(app.info.packageName)) {
                                app.info = ai;
+14 −0
Original line number Diff line number Diff line
@@ -4587,6 +4587,20 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return mGlobalAssetsSeq;
    }

    /**
     * Updates the {@link ApplicationInfo}s of the package activities th that are attached in the
     * WM hierarchy.
     */
    public void updateActivityApplicationInfo(int userId,
            ArrayMap<String, ApplicationInfo> applicationInfoByPackage) {
        synchronized (mGlobalLock) {
            if (mRootWindowContainer != null) {
                mRootWindowContainer.updateActivityApplicationInfo(userId,
                        applicationInfoByPackage);
            }
        }
    }

    /**
     * Update the asset configuration and increase the assets sequence number.
     * @param processes the processes that needs to update the asset configuration
+14 −0
Original line number Diff line number Diff line
@@ -3173,6 +3173,20 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        });
    }

    void updateActivityApplicationInfo(int userId,
            ArrayMap<String, ApplicationInfo> applicationInfoByPackage) {
        forAllActivities(r -> {
            if (r.mUserId != userId) {
                return;
            }

            final ApplicationInfo aInfo = applicationInfoByPackage.get(r.packageName);
            if (aInfo != null) {
                r.updateApplicationInfo(aInfo);
            }
        });
    }

    void finishVoiceTask(IVoiceInteractionSession session) {
        final IBinder binder = session.asBinder();
        forAllLeafTasks(t -> t.finishIfVoiceTask(binder), true /* traverseTopToBottom */);