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

Commit cff3d13a authored by Bryce Lee's avatar Bryce Lee Committed by android-build-merger
Browse files

Merge "Reduce synchronized lock scope." into oc-mr1-dev am: 9b6ef6a8

am: 0ab501b9

Change-Id: I4cfd66ba2f1748751c5355466bedb36d5d369bba
parents 9c99f325 0ab501b9
Loading
Loading
Loading
Loading
+118 −114
Original line number Diff line number Diff line
@@ -2138,14 +2138,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        try {
            // Protect against recursion.
            mStackSupervisor.inResumeTopActivity = true;
            // The contained logic must be synchronized, since we are both changing the visibility
            // and updating the {@link Configuration}. {@link ActivityRecord#setVisibility} will
            // ultimately cause the client code to schedule a layout. Since layouts retrieve the
            // current {@link Configuration}, we must ensure that the below code updates it before
            // the layout can occur.
            synchronized (mWindowManager.getWindowManagerLock()) {
            result = resumeTopActivityInnerLocked(prev, options);
            }
        } finally {
            mStackSupervisor.inResumeTopActivity = false;
        }
@@ -2454,6 +2447,12 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                    || (lastStack.mLastPausedActivity != null
                    && !lastStack.mLastPausedActivity.fullscreen));

            // The contained logic must be synchronized, since we are both changing the visibility
            // and updating the {@link Configuration}. {@link ActivityRecord#setVisibility} will
            // ultimately cause the client code to schedule a layout. Since layouts retrieve the
            // current {@link Configuration}, we must ensure that the below code updates it before
            // the layout can occur.
            synchronized(mWindowManager.getWindowManagerLock()) {
                // This activity is now becoming visible.
                if (!next.visible || next.stopped || lastActivityTranslucent) {
                    next.setVisibility(true);
@@ -2468,7 +2467,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai

                mService.updateCpuStats();

            if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to RESUMED: " + next + " (in existing)");
                if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to RESUMED: " + next
                        + " (in existing)");

                setResumedActivityLocked(next, "resumeTopActivityInnerLocked");

@@ -2479,20 +2479,22 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                // Have the window manager re-evaluate the orientation of
                // the screen based on the new activity order.
                boolean notUpdated = true;

                if (mStackSupervisor.isFocusedStack(this)) {

                // We have special rotation behavior when Keyguard is locked. Make sure all activity
                // visibilities are set correctly as well as the transition is updated if needed to
                // get the correct rotation behavior.
                // TODO: Remove this once visibilities are set correctly immediately when starting
                // an activity.
                    // We have special rotation behavior when Keyguard is locked. Make sure all
                    // activity visibilities are set correctly as well as the transition is updated
                    // if needed to get the correct rotation behavior.
                    // TODO: Remove this once visibilities are set correctly immediately when
                    // starting an activity.
                    if (mStackSupervisor.mKeyguardController.isKeyguardLocked()) {
                        mStackSupervisor.ensureActivitiesVisibleLocked(null /* starting */,
                                0 /* configChanges */, false /* preserveWindows */);
                    }
                    final Configuration config = mWindowManager.updateOrientationFromAppTokens(
                            mStackSupervisor.getDisplayOverrideConfiguration(mDisplayId),
                        next.mayFreezeScreenLocked(next.app) ? next.appToken : null, mDisplayId);
                            next.mayFreezeScreenLocked(next.app) ? next.appToken : null,
                                    mDisplayId);
                    if (config != null) {
                        next.frozenBeforeDestroy = true;
                    }
@@ -2556,7 +2558,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                    next.app.thread.scheduleResumeActivity(next.appToken, next.app.repProcState,
                            mService.isNextTransitionForward(), resumeAnimOptions);

                if (DEBUG_STATES) Slog.d(TAG_STATES, "resumeTopActivityLocked: Resumed " + next);
                    if (DEBUG_STATES) Slog.d(TAG_STATES, "resumeTopActivityLocked: Resumed "
                            + next);
                } catch (Exception e) {
                    // Whoops, need to restart this activity!
                    if (DEBUG_STATES) Slog.v(TAG_STATES, "Resume failed; resetting state to "
@@ -2577,6 +2580,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                    if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
                    return true;
                }
            }

            // From this point on, if something goes wrong there is no way
            // to recover the activity.