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

Commit bebd32ea authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Associate activity config before creating application

In case when cold launching an activity with letterboxed bounds, the
app stores the size or configuration in its Application#onCreate,
which could be still from relative to entire display. And then
Activity#onCreate may initialize with letterboxed configuration,
which may cause UI issue if it uses the stored size from Application.

So this change makes the configuration consistent in both
Application#onCreate and Activity#onCreate.

Bug: 345582967
Flag: EXEMPT bugfix
Test: atest RootWindowContainerTests#testAttachApplication
Change-Id: I7604671446901c87cb1440022327b562dcb4baf6
parent 65e59d9a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -6706,6 +6706,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            synchronized (mGlobalLockWithoutBoost) {
                mTaskSupervisor.getActivityMetricsLogger().notifyBindApplication(wpc.mInfo);
                wpc.onConfigurationChanged(getGlobalConfiguration());
                // Let the application initialize with consistent configuration as its activity.
                for (int i = mStartingProcessActivities.size() - 1; i >= 0; i--) {
                    final ActivityRecord r = mStartingProcessActivities.get(i);
                    if (wpc.mUid == r.info.applicationInfo.uid && wpc.mName.equals(r.processName)) {
                        wpc.registerActivityConfigurationListener(r);
                        break;
                    }
                }
                // The "info" can be the target of instrumentation.
                return new PreBindInfo(compatibilityInfoForPackageLocked(info),
                        new Configuration(wpc.getConfiguration()));
+5 −0
Original line number Diff line number Diff line
@@ -1543,6 +1543,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        unregisterConfigurationListeners();
        mConfigActivityRecord = activityRecord;
        activityRecord.registerConfigurationChangeListener(this);
        // If the process hasn't attached, make sure that prepareConfigurationForLaunchingActivity
        // will use the newer configuration sequence.
        if (mThread == null) {
            mHasPendingConfigurationChange = true;
        }
    }

    private void unregisterActivityConfigurationListener() {
+2 −0
Original line number Diff line number Diff line
@@ -331,6 +331,8 @@ public class RootWindowContainerTests extends WindowTestsBase {
        final WindowProcessController proc = mSystemServicesTestRule.addProcess(
                activity.packageName, activity.processName,
                6789 /* pid */, activity.info.applicationInfo.uid);
        mAtm.mInternal.preBindApplication(proc, proc.mInfo);
        assertTrue(proc.registeredForActivityConfigChanges());
        assertFalse(proc.mHasEverAttached);
        try {
            mRootWindowContainer.attachApplication(proc);