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

Commit 8b5afd93 authored by Louis Chang's avatar Louis Chang
Browse files

Do not relaunch bg activities when application info changes

Update the configurations via ActivityTaskManager to prevent the
activities being relaunched while in background. Instead, the
activities will be relaunched after brought to front and being visible.

This also prevents all activities in the system being relaunched
at the same time.

Bug: 185301309
Test: update app info via shell command while activity in background
Change-Id: Ibf93b9e3f203578c25e0b6b50494065938790f24
parent 062b61f2
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -5961,20 +5961,6 @@ public final class ActivityThread extends ClientTransactionHandler
            // Update all affected Resources objects to use new ResourcesImpl
            mResourcesManager.applyNewResourceDirsLocked(ai, oldResDirs);
        }

        ApplicationPackageManager.configurationChanged();

        // Trigger a regular Configuration change event, only with a different assetsSeq number
        // so that we actually call through to all components.
        // TODO(adamlesinski): Change this to make use of ActivityManager's upcoming ability to
        // store configurations per-process.
        final Configuration config = mConfigurationController.getConfiguration();
        Configuration newConfig = new Configuration();
        newConfig.assetsSeq = (config != null ? config.assetsSeq : 0) + 1;
        mConfigurationController.handleConfigurationChanged(newConfig, null /* compat */);

        // Preserve windows to avoid black flickers when overlays change.
        relaunchAllActivities(true /* preserveWindows */, "handleApplicationInfoChanged");
    }

    /**
+0 −9
Original line number Diff line number Diff line
@@ -184,15 +184,6 @@ public class ActivityThreadTest {
        });
    }

    @Test
    public void testHandleActivity_assetsChanged() {
        relaunchActivityAndAssertPreserveWindow(activity -> {
            // Relaunches all activities.
            activity.getActivityThread().handleApplicationInfoChanged(
                    activity.getApplicationInfo());
        });
    }

    @Test
    public void testRecreateActivity() {
        relaunchActivityAndAssertPreserveWindow(Activity::recreate);
+7 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
import android.net.LocalSocket;
@@ -4643,6 +4644,12 @@ public final class ProcessList {
                }
            });
        }

        // Update the global configuration and increase the assets sequence number.
        Configuration currentConfig = mService.mActivityTaskManager.getConfiguration();
        Configuration newConfig = new Configuration();
        newConfig.assetsSeq = (currentConfig != null ? currentConfig.assetsSeq : 0) + 1;
        mService.mActivityTaskManager.updateConfiguration(newConfig);
    }

    @GuardedBy("mService")