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

Commit 530ad2a0 authored by Chilun's avatar Chilun
Browse files

Skip config check for destroyed activities

Skip config check if the activity is in destroyed state.

Bug: 170134300
Test: restart activity after process restarted and config changed
      atest ActivityRecordTests#testDestroyedActivityNotScheduleConfigChanged
Change-Id: Ie3d4e3884f06ca6cf0830e48fb4e52c0c0490682
parent 4eb5ec4a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2749,6 +2749,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "1105210816": {
      "message": "Skipping config check in destroyed state %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1112047265": {
      "message": "finishDrawingWindow: %s mDrawState=%s",
      "level": "DEBUG",
+6 −0
Original line number Diff line number Diff line
@@ -7081,6 +7081,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return true;
        }

        if (isState(DESTROYED)) {
            ProtoLog.v(WM_DEBUG_CONFIGURATION, "Skipping config check "
                    + "in destroyed state %s", this);
            return true;
        }

        if (!ignoreVisibility && (mState == STOPPING || mState == STOPPED || !shouldBeVisible())) {
            ProtoLog.v(WM_DEBUG_CONFIGURATION, "Skipping config check "
                    + "invisible: %s", this);
+22 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.never;

@@ -375,6 +376,27 @@ public class ActivityRecordTests extends WindowTestsBase {
                activity.mRelaunchReason);
    }

    @Test
    public void testDestroyedActivityNotScheduleConfigChanged() throws RemoteException {
        final ActivityRecord activity = new ActivityBuilder(mAtm)
                .setCreateTask(true)
                .setConfigChanges(CONFIG_ORIENTATION)
                .build();
        final Task task = activity.getTask();
        activity.setState(DESTROYED, "Testing");

        final Configuration newConfig = new Configuration(task.getConfiguration());
        newConfig.orientation = newConfig.orientation == ORIENTATION_PORTRAIT
                ? ORIENTATION_LANDSCAPE
                : ORIENTATION_PORTRAIT;
        task.onRequestedOverrideConfigurationChanged(newConfig);

        ensureActivityConfiguration(activity);

        verify(mAtm.getLifecycleManager(), never())
                .scheduleTransaction(any(), any(), isA(ActivityConfigurationChangeItem.class));
    }

    @Test
    public void testSetRequestedOrientationUpdatesConfiguration() throws Exception {
        final ActivityRecord activity = new ActivityBuilder(mAtm)