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

Commit 1898f09e authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Reduce method invocation when checking orientation" into main

parents 10ff8b86 f7215a70
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1835,7 +1835,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (mTransitionController.useShellTransitionsRotation()) {
            return ROTATION_UNDEFINED;
        }
        final int activityOrientation = r.getOverrideOrientation();
        int activityOrientation = r.getOverrideOrientation();
        if (!WindowManagerService.ENABLE_FIXED_ROTATION_TRANSFORM
                || shouldIgnoreOrientationRequest(activityOrientation)) {
            return ROTATION_UNDEFINED;
@@ -1846,14 +1846,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                    r /* boundary */, false /* includeBoundary */, true /* traverseTopToBottom */);
            if (nextCandidate != null) {
                r = nextCandidate;
                activityOrientation = r.getOverrideOrientation();
            }
        }
        if (r.inMultiWindowMode() || r.getRequestedConfigurationOrientation(true /* forDisplay */)
                == getConfiguration().orientation) {
        if (r.inMultiWindowMode() || r.getRequestedConfigurationOrientation(true /* forDisplay */,
                activityOrientation) == getConfiguration().orientation) {
            return ROTATION_UNDEFINED;
        }
        final int currentRotation = getRotation();
        final int rotation = mDisplayRotation.rotationForOrientation(r.getRequestedOrientation(),
        final int rotation = mDisplayRotation.rotationForOrientation(activityOrientation,
                currentRotation);
        if (rotation == currentRotation) {
            return ROTATION_UNDEFINED;
+7 −7
Original line number Diff line number Diff line
@@ -1731,13 +1731,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
     *         last time {@link #getOrientation(int) was called.
     */
    @Nullable
    WindowContainer getLastOrientationSource() {
        final WindowContainer source = mLastOrientationSource;
        if (source != null && source != this) {
            final WindowContainer nextSource = source.getLastOrientationSource();
            if (nextSource != null) {
                return nextSource;
    final WindowContainer<?> getLastOrientationSource() {
        if (mLastOrientationSource == null) {
            return null;
        }
        WindowContainer<?> source = this;
        while (source != source.mLastOrientationSource && source.mLastOrientationSource != null) {
            source = source.mLastOrientationSource;
        }
        return source;
    }
+1 −0
Original line number Diff line number Diff line
@@ -1144,6 +1144,7 @@ public class DisplayContentTests extends WindowTestsBase {

    @Test
    public void testOrientationBehind() {
        assertNull(mDisplayContent.getLastOrientationSource());
        final ActivityRecord prev = new ActivityBuilder(mAtm).setCreateTask(true)
                .setScreenOrientation(getRotatedOrientation(mDisplayContent)).build();
        prev.setVisibleRequested(false);