Merge "Synchronise access to topRunningActivity" into tm-qpr-dev am: 961c53cb70

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21592560

Change-Id: I40297b906e50e912b79cf9000d7ee0a0fc29ddef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2023-03-02 15:15:36 +00:00
committed by Automerger Merge Worker

View File

@@ -359,12 +359,6 @@ final class DisplayRotationCompatPolicy {
CAMERA_OPENED_ROTATION_UPDATE_DELAY_MS); CAMERA_OPENED_ROTATION_UPDATE_DELAY_MS);
} }
private void updateOrientationWithWmLock() {
synchronized (mWmService.mGlobalLock) {
mDisplayContent.updateOrientation();
}
}
private void delayedUpdateOrientationWithWmLock( private void delayedUpdateOrientationWithWmLock(
@NonNull String cameraId, @NonNull String packageName) { @NonNull String cameraId, @NonNull String packageName) {
synchronized (this) { synchronized (this) {
@@ -375,25 +369,28 @@ final class DisplayRotationCompatPolicy {
} }
mCameraIdPackageBiMap.put(packageName, cameraId); mCameraIdPackageBiMap.put(packageName, cameraId);
} }
ActivityRecord topActivity = mDisplayContent.topRunningActivity( synchronized (mWmService.mGlobalLock) {
/* considerKeyguardState= */ true); ActivityRecord topActivity = mDisplayContent.topRunningActivity(
if (topActivity == null || topActivity.getTask() == null) { /* considerKeyguardState= */ true);
return; 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
if (topActivity.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) { // compat treatment doesn't cover activity embedding.
if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) { if (topActivity.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
topActivity.recomputeConfiguration(); if (topActivity.mLetterboxUiController
.isOverrideOrientationOnlyForCameraEnabled()) {
topActivity.recomputeConfiguration();
}
mDisplayContent.updateOrientation();
return;
}
// Checking that the whole app is in multi-window mode as we shouldn't show toast
// for the activity embedding case.
if (topActivity.getTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW
&& isTreatmentEnabledForActivity(topActivity, /* mustBeFullscreen */ false)) {
showToast(R.string.display_rotation_camera_compat_toast_in_split_screen);
} }
updateOrientationWithWmLock();
return;
}
// Checking that the whole app is in multi-window mode as we shouldn't show toast
// for the activity embedding case.
if (topActivity.getTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW
&& isTreatmentEnabledForActivity(topActivity, /* mustBeFullscreen */ false)) {
showToast(R.string.display_rotation_camera_compat_toast_in_split_screen);
} }
} }
@@ -441,18 +438,20 @@ final class DisplayRotationCompatPolicy {
ProtoLog.v(WM_DEBUG_ORIENTATION, ProtoLog.v(WM_DEBUG_ORIENTATION,
"Display id=%d is notified that Camera %s is closed, updating rotation.", "Display id=%d is notified that Camera %s is closed, updating rotation.",
mDisplayContent.mDisplayId, cameraId); mDisplayContent.mDisplayId, cameraId);
ActivityRecord topActivity = mDisplayContent.topRunningActivity( synchronized (mWmService.mGlobalLock) {
/* considerKeyguardState= */ true); ActivityRecord topActivity = mDisplayContent.topRunningActivity(
if (topActivity == null /* considerKeyguardState= */ true);
// Checking whether an activity in fullscreen rather than the task as this camera if (topActivity == null
// compat treatment doesn't cover activity embedding. // Checking whether an activity in fullscreen rather than the task as this
|| topActivity.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) { // camera compat treatment doesn't cover activity embedding.
return; || topActivity.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
return;
}
if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) {
topActivity.recomputeConfiguration();
}
mDisplayContent.updateOrientation();
} }
if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) {
topActivity.recomputeConfiguration();
}
updateOrientationWithWmLock();
} }
private boolean isActivityForCameraIdRefreshing(String cameraId) { private boolean isActivityForCameraIdRefreshing(String cameraId) {