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

Commit 9055c1b6 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Wait to pause activity if translucent activity is waiting."

parents e51234b4 a0fb8e03
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -1732,8 +1732,12 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
            mStackSupervisor.mStoppingActivities.remove(this);
            mStackSupervisor.mStoppingActivities.remove(this);
            mStackSupervisor.mGoingToSleepActivities.remove(this);
            mStackSupervisor.mGoingToSleepActivities.remove(this);


            // If the activity is stopped or stopping, cycle to the paused state.
            // If the activity is stopped or stopping, cycle to the paused state. We avoid doing
            if (isState(STOPPED, STOPPING)) {
            // this when there is an activity waiting to become translucent as the extra binder
            // calls will lead to noticeable jank. A later call to
            // ActivityStack#ensureActivitiesVisibleLocked will bring the activity to the proper
            // paused state.
            if (isState(STOPPED, STOPPING) && stack.mTranslucentActivityWaiting == null) {
                // Capture reason before state change
                // Capture reason before state change
                final String reason = getLifecycleDescription("makeVisibleIfNeeded");
                final String reason = getLifecycleDescription("makeVisibleIfNeeded");


@@ -1747,7 +1751,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            // Just skip on any failure; we'll make it visible when it next restarts.
            // Just skip on any failure; we'll make it visible when it next restarts.
            Slog.w(TAG, "Exception thrown making visibile: " + intent.getComponent(), e);
            Slog.w(TAG, "Exception thrown making visible: " + intent.getComponent(), e);
        }
        }
        handleAlreadyVisible();
        handleAlreadyVisible();
    }
    }
+11 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.server.am.ActivityStack.ActivityState.DESTROYED;
import static com.android.server.am.ActivityStack.ActivityState.DESTROYED;
import static com.android.server.am.ActivityStack.ActivityState.DESTROYING;
import static com.android.server.am.ActivityStack.ActivityState.DESTROYING;
import static com.android.server.am.ActivityStack.ActivityState.INITIALIZING;
import static com.android.server.am.ActivityStack.ActivityState.INITIALIZING;
import static com.android.server.am.ActivityStack.ActivityState.PAUSED;
import static com.android.server.am.ActivityStack.ActivityState.PAUSING;
import static com.android.server.am.ActivityStack.ActivityState.PAUSING;
import static com.android.server.am.ActivityStack.ActivityState.STOPPED;
import static com.android.server.am.ActivityStack.ActivityState.STOPPED;
import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_MOVING;
import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_MOVING;
@@ -135,6 +136,16 @@ public class ActivityRecordTests extends ActivityTestsBase {
        mActivity.makeVisibleIfNeeded(null /* starting */);
        mActivity.makeVisibleIfNeeded(null /* starting */);


        assertTrue(mActivity.isState(INITIALIZING));
        assertTrue(mActivity.isState(INITIALIZING));

        // Make sure the state does not change if we are not the current top activity.
        mActivity.setState(STOPPED, "testPausingWhenVisibleFromStopped behind");

        // Make sure that the state does not change when we have an activity becoming translucent
        final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
        mStack.mTranslucentActivityWaiting = topActivity;
        mActivity.makeVisibleIfNeeded(null /* starting */);

        assertTrue(mActivity.isState(STOPPED));
    }
    }


    @Test
    @Test