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

Commit 961c53cb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Synchronise access to topRunningActivity" into tm-qpr-dev

parents 1112655d bc757f43
Loading
Loading
Loading
Loading
+34 −35
Original line number Diff line number Diff line
@@ -359,12 +359,6 @@ final class DisplayRotationCompatPolicy {
                CAMERA_OPENED_ROTATION_UPDATE_DELAY_MS);
    }

    private void updateOrientationWithWmLock() {
        synchronized (mWmService.mGlobalLock) {
            mDisplayContent.updateOrientation();
        }
    }

    private void delayedUpdateOrientationWithWmLock(
            @NonNull String cameraId, @NonNull String packageName) {
        synchronized (this) {
@@ -375,18 +369,20 @@ final class DisplayRotationCompatPolicy {
            }
            mCameraIdPackageBiMap.put(packageName, cameraId);
        }
        synchronized (mWmService.mGlobalLock) {
            ActivityRecord topActivity = mDisplayContent.topRunningActivity(
                        /* considerKeyguardState= */ true);
            if (topActivity == null || topActivity.getTask() == null) {
                return;
            }
        // Checking whether an activity in fullscreen rather than the task as this camera compat
        // treatment doesn't cover activity embedding.
            // Checking whether an activity in fullscreen rather than the task as this camera
            // compat treatment doesn't cover activity embedding.
            if (topActivity.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
            if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) {
                if (topActivity.mLetterboxUiController
                        .isOverrideOrientationOnlyForCameraEnabled()) {
                    topActivity.recomputeConfiguration();
                }
            updateOrientationWithWmLock();
                mDisplayContent.updateOrientation();
                return;
            }
            // Checking that the whole app is in multi-window mode as we shouldn't show toast
@@ -396,6 +392,7 @@ final class DisplayRotationCompatPolicy {
                showToast(R.string.display_rotation_camera_compat_toast_in_split_screen);
            }
        }
    }

    @VisibleForTesting
    void showToast(@StringRes int stringRes) {
@@ -441,18 +438,20 @@ final class DisplayRotationCompatPolicy {
        ProtoLog.v(WM_DEBUG_ORIENTATION,
                "Display id=%d is notified that Camera %s is closed, updating rotation.",
                mDisplayContent.mDisplayId, cameraId);
        synchronized (mWmService.mGlobalLock) {
            ActivityRecord topActivity = mDisplayContent.topRunningActivity(
                    /* considerKeyguardState= */ true);
            if (topActivity == null
                // Checking whether an activity in fullscreen rather than the task as this camera
                // compat treatment doesn't cover activity embedding.
                    // Checking whether an activity in fullscreen rather than the task as this
                    // camera compat treatment doesn't cover activity embedding.
                    || topActivity.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
                return;
            }
            if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) {
                topActivity.recomputeConfiguration();
            }
        updateOrientationWithWmLock();
            mDisplayContent.updateOrientation();
        }
    }

    private boolean isActivityForCameraIdRefreshing(String cameraId) {