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

Commit 3100c1e4 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Do not relaunch bg activities when application info changes" into sc-dev

parents 9fb45cc8 33a43368
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -5613,7 +5613,7 @@ public final class ActivityThread extends ClientTransactionHandler
    }

    /** Performs the activity relaunch locally vs. requesting from system-server. */
    private void handleRelaunchActivityLocally(IBinder token) {
    public void handleRelaunchActivityLocally(IBinder token) {
        final ActivityClientRecord r = mActivities.get(token);
        if (r == null) {
            Log.w(TAG, "Activity to relaunch no longer exists");
@@ -5977,20 +5977,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);
+6 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ import com.android.server.pm.dex.DexManager;
import com.android.server.pm.parsing.pkg.AndroidPackage;
import com.android.server.wm.ActivityServiceConnectionsHolder;
import com.android.server.wm.WindowManagerService;
import com.android.server.wm.WindowProcessController;

import dalvik.system.VMRuntime;

@@ -4626,6 +4627,7 @@ public final class ProcessList {
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    void updateApplicationInfoLOSP(List<String> packagesToUpdate, int userId,
            boolean updateFrameworkRes) {
        final ArrayList<WindowProcessController> targetProcesses = new ArrayList<>();
        for (int i = mLruProcesses.size() - 1; i >= 0; i--) {
            final ProcessRecord app = mLruProcesses.get(i);
            if (app.getThread() == null) {
@@ -4646,6 +4648,7 @@ public final class ProcessList {
                            if (ai.packageName.equals(app.info.packageName)) {
                                app.info = ai;
                            }
                            targetProcesses.add(app.getWindowProcessController());
                        }
                    } catch (RemoteException e) {
                        Slog.w(TAG, String.format("Failed to update %s ApplicationInfo for %s",
@@ -4654,6 +4657,9 @@ public final class ProcessList {
                }
            });
        }

        mService.mActivityTaskManager.updateAssetConfiguration(
                updateFrameworkRes ? null : targetProcesses);
    }

    @GuardedBy("mService")
+6 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import static android.content.pm.ActivityInfo.SIZE_CHANGES_UNSUPPORTED_OVERRIDE;
import static android.content.pm.ActivityInfo.isFixedOrientationLandscape;
import static android.content.pm.ActivityInfo.isFixedOrientationPortrait;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.res.Configuration.ASSETS_SEQ_UNDEFINED;
import static android.content.res.Configuration.EMPTY;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
@@ -6858,6 +6859,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    @Override
    void resolveOverrideConfiguration(Configuration newParentConfiguration) {
        final Configuration requestedOverrideConfig = getRequestedOverrideConfiguration();
        if (requestedOverrideConfig.assetsSeq != ASSETS_SEQ_UNDEFINED
                && newParentConfiguration.assetsSeq > requestedOverrideConfig.assetsSeq) {
            requestedOverrideConfig.assetsSeq = ASSETS_SEQ_UNDEFINED;
        }
        super.resolveOverrideConfiguration(newParentConfiguration);
        final Configuration resolvedConfig = getResolvedOverrideConfiguration();
        if (isFixedRotationTransforming()) {
+33 −0
Original line number Diff line number Diff line
@@ -472,6 +472,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

    /** Current sequencing integer of the configuration, for skipping old configurations. */
    private int mConfigurationSeq;

    /** Current sequencing integer of the asset changes, for skipping old resources overlays. */
    private int mGlobalAssetsSeq;

    // To cache the list of supported system locales
    private String[] mSupportedSystemLocales = null;

@@ -4129,6 +4133,35 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return changes;
    }

    private int increaseAssetConfigurationSeq() {
        mGlobalAssetsSeq = Math.max(++mGlobalAssetsSeq, 1);
        return mGlobalAssetsSeq;
    }

    /**
     * Update the asset configuration and increase the assets sequence number.
     * @param processes the processes that needs to update the asset configuration, if none
     *                  updates the global configuration for all processes.
     */
    public void updateAssetConfiguration(List<WindowProcessController> processes) {
        synchronized (mGlobalLock) {
            final int assetSeq = increaseAssetConfigurationSeq();

            // Update the global configuration if the no target processes
            if (processes == null) {
                Configuration newConfig = new Configuration();
                newConfig.assetsSeq = assetSeq;
                updateConfiguration(newConfig);
                return;
            }

            for (int i = processes.size() - 1; i >= 0; i--) {
                final WindowProcessController wpc = processes.get(i);
                wpc.updateAssetConfiguration(assetSeq);
            }
        }
    }

    void startLaunchPowerMode(@PowerModeReason int reason) {
        if (mPowerManagerInternal == null) return;
        mPowerManagerInternal.setPowerMode(Mode.LAUNCH, true);
Loading