Loading core/java/android/app/AppCompatTaskInfo.java +9 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,11 @@ public class AppCompatTaskInfo implements Parcelable { */ public boolean topActivityEligibleForLetterboxEducation; /** * Whether the letterbox education is enabled */ public boolean isLetterboxEducationEnabled; /** * Whether the direct top activity is in size compat mode on foreground. */ Loading Loading @@ -224,6 +229,7 @@ public class AppCompatTaskInfo implements Parcelable { == that.topActivityEligibleForUserAspectRatioButton && topActivityEligibleForLetterboxEducation == that.topActivityEligibleForLetterboxEducation && isLetterboxEducationEnabled == that.isLetterboxEducationEnabled && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxHorizontalPosition == that.topActivityLetterboxHorizontalPosition Loading @@ -238,6 +244,7 @@ public class AppCompatTaskInfo implements Parcelable { * Reads the TaskInfo from a parcel. */ void readFromParcel(Parcel source) { isLetterboxEducationEnabled = source.readBoolean(); topActivityInSizeCompat = source.readBoolean(); topActivityEligibleForLetterboxEducation = source.readBoolean(); cameraCompatControlState = source.readInt(); Loading @@ -258,6 +265,7 @@ public class AppCompatTaskInfo implements Parcelable { */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeBoolean(isLetterboxEducationEnabled); dest.writeBoolean(topActivityInSizeCompat); dest.writeBoolean(topActivityEligibleForLetterboxEducation); dest.writeInt(cameraCompatControlState); Loading @@ -278,6 +286,7 @@ public class AppCompatTaskInfo implements Parcelable { return "AppCompatTaskInfo { topActivityInSizeCompat=" + topActivityInSizeCompat + " topActivityEligibleForLetterboxEducation= " + topActivityEligibleForLetterboxEducation + "isLetterboxEducationEnabled= " + isLetterboxEducationEnabled + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled + " topActivityEligibleForUserAspectRatioButton= " + topActivityEligibleForUserAspectRatioButton Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +34 −2 Original line number Diff line number Diff line Loading @@ -188,6 +188,11 @@ public class CompatUIController implements OnDisplaysChangedListener, */ private boolean mHasShownUserAspectRatioSettingsButton = false; /** * This is true when the rechability education is displayed for the first time. */ private boolean mIsFirstReachabilityEducationRunning; public CompatUIController(@NonNull Context context, @NonNull ShellInit shellInit, @NonNull ShellController shellController, Loading Loading @@ -252,9 +257,35 @@ public class CompatUIController implements OnDisplaysChangedListener, removeLayouts(taskInfo.taskId); return; } createOrUpdateCompatLayout(taskInfo, taskListener); // We're showing the first reachability education so we ignore incoming TaskInfo // until the education flow has completed or we double tap. if (mIsFirstReachabilityEducationRunning) { return; } if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) { if (taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled) { createOrUpdateLetterboxEduLayout(taskInfo, taskListener); } else if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap) { // In this case the app is letterboxed and the letterbox education // is disabled. In this case we need to understand if it's the first // time we show the reachability education. When this is happening // we need to ignore all the incoming TaskInfo until the education // completes. If we come from a double tap we follow the normal flow. final boolean topActivityPillarboxed = taskInfo.appCompatTaskInfo.isTopActivityPillarboxed(); final boolean isFirstTimeHorizontalReachabilityEdu = topActivityPillarboxed && !mCompatUIConfiguration.hasSeenHorizontalReachabilityEducation(taskInfo); final boolean isFirstTimeVerticalReachabilityEdu = !topActivityPillarboxed && !mCompatUIConfiguration.hasSeenVerticalReachabilityEducation(taskInfo); if (isFirstTimeHorizontalReachabilityEdu || isFirstTimeVerticalReachabilityEdu) { mIsFirstReachabilityEducationRunning = true; mCompatUIConfiguration.setSeenLetterboxEducation(taskInfo.userId); createOrUpdateReachabilityEduLayout(taskInfo, taskListener); return; } } } createOrUpdateCompatLayout(taskInfo, taskListener); createOrUpdateRestartDialogLayout(taskInfo, taskListener); if (mCompatUIConfiguration.getHasSeenLetterboxEducation(taskInfo.userId)) { createOrUpdateReachabilityEduLayout(taskInfo, taskListener); Loading Loading @@ -589,6 +620,7 @@ public class CompatUIController implements OnDisplaysChangedListener, private void onInitialReachabilityEduDismissed(@NonNull TaskInfo taskInfo, @NonNull ShellTaskOrganizer.TaskListener taskListener) { // We need to update the UI otherwise it will not be shown until the user relaunches the app mIsFirstReachabilityEducationRunning = false; createOrUpdateUserAspectRatioSettingsLayout(taskInfo, taskListener); } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -668,6 +668,18 @@ public class CompatUIControllerTest extends ShellTestCase { Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton()); } @Test public void testLetterboxEduLayout_notCreatedWhenLetterboxEducationIsDisabled() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN); taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = false; mController.onCompatInfoChanged(taskInfo, mMockTaskListener); verify(mController, never()).createLetterboxEduWindowManager(any(), eq(taskInfo), eq(mMockTaskListener)); } private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat, @CameraCompatControlState int cameraCompatControlState) { return createTaskInfo(displayId, taskId, hasSizeCompat, cameraCompatControlState, Loading @@ -693,6 +705,8 @@ public class CompatUIControllerTest extends ShellTestCase { taskInfo.isVisible = isVisible; taskInfo.isFocused = isFocused; taskInfo.isTopActivityTransparent = isTopActivityTransparent; taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = true; taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed = true; return taskInfo; } } services/core/java/com/android/server/wm/LetterboxUiController.java +4 −0 Original line number Diff line number Diff line Loading @@ -970,6 +970,10 @@ final class LetterboxUiController { } } boolean isLetterboxEducationEnabled() { return mLetterboxConfiguration.getIsEducationEnabled(); } /** * Whether we use split screen aspect ratio for the activity when camera compat treatment * is active because the corresponding config is enabled and activity supports resizing. Loading services/core/java/com/android/server/wm/Task.java +2 −0 Original line number Diff line number Diff line Loading @@ -3541,6 +3541,8 @@ class Task extends TaskFragment { // Whether the direct top activity is eligible for letterbox education. appCompatTaskInfo.topActivityEligibleForLetterboxEducation = isTopActivityResumed && top.isEligibleForLetterboxEducation(); appCompatTaskInfo.isLetterboxEducationEnabled = top != null && top.mLetterboxUiController.isLetterboxEducationEnabled(); // Whether the direct top activity requested showing camera compat control. appCompatTaskInfo.cameraCompatControlState = isTopActivityResumed ? top.getCameraCompatControlState() Loading Loading
core/java/android/app/AppCompatTaskInfo.java +9 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,11 @@ public class AppCompatTaskInfo implements Parcelable { */ public boolean topActivityEligibleForLetterboxEducation; /** * Whether the letterbox education is enabled */ public boolean isLetterboxEducationEnabled; /** * Whether the direct top activity is in size compat mode on foreground. */ Loading Loading @@ -224,6 +229,7 @@ public class AppCompatTaskInfo implements Parcelable { == that.topActivityEligibleForUserAspectRatioButton && topActivityEligibleForLetterboxEducation == that.topActivityEligibleForLetterboxEducation && isLetterboxEducationEnabled == that.isLetterboxEducationEnabled && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxHorizontalPosition == that.topActivityLetterboxHorizontalPosition Loading @@ -238,6 +244,7 @@ public class AppCompatTaskInfo implements Parcelable { * Reads the TaskInfo from a parcel. */ void readFromParcel(Parcel source) { isLetterboxEducationEnabled = source.readBoolean(); topActivityInSizeCompat = source.readBoolean(); topActivityEligibleForLetterboxEducation = source.readBoolean(); cameraCompatControlState = source.readInt(); Loading @@ -258,6 +265,7 @@ public class AppCompatTaskInfo implements Parcelable { */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeBoolean(isLetterboxEducationEnabled); dest.writeBoolean(topActivityInSizeCompat); dest.writeBoolean(topActivityEligibleForLetterboxEducation); dest.writeInt(cameraCompatControlState); Loading @@ -278,6 +286,7 @@ public class AppCompatTaskInfo implements Parcelable { return "AppCompatTaskInfo { topActivityInSizeCompat=" + topActivityInSizeCompat + " topActivityEligibleForLetterboxEducation= " + topActivityEligibleForLetterboxEducation + "isLetterboxEducationEnabled= " + isLetterboxEducationEnabled + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled + " topActivityEligibleForUserAspectRatioButton= " + topActivityEligibleForUserAspectRatioButton Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +34 −2 Original line number Diff line number Diff line Loading @@ -188,6 +188,11 @@ public class CompatUIController implements OnDisplaysChangedListener, */ private boolean mHasShownUserAspectRatioSettingsButton = false; /** * This is true when the rechability education is displayed for the first time. */ private boolean mIsFirstReachabilityEducationRunning; public CompatUIController(@NonNull Context context, @NonNull ShellInit shellInit, @NonNull ShellController shellController, Loading Loading @@ -252,9 +257,35 @@ public class CompatUIController implements OnDisplaysChangedListener, removeLayouts(taskInfo.taskId); return; } createOrUpdateCompatLayout(taskInfo, taskListener); // We're showing the first reachability education so we ignore incoming TaskInfo // until the education flow has completed or we double tap. if (mIsFirstReachabilityEducationRunning) { return; } if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) { if (taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled) { createOrUpdateLetterboxEduLayout(taskInfo, taskListener); } else if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap) { // In this case the app is letterboxed and the letterbox education // is disabled. In this case we need to understand if it's the first // time we show the reachability education. When this is happening // we need to ignore all the incoming TaskInfo until the education // completes. If we come from a double tap we follow the normal flow. final boolean topActivityPillarboxed = taskInfo.appCompatTaskInfo.isTopActivityPillarboxed(); final boolean isFirstTimeHorizontalReachabilityEdu = topActivityPillarboxed && !mCompatUIConfiguration.hasSeenHorizontalReachabilityEducation(taskInfo); final boolean isFirstTimeVerticalReachabilityEdu = !topActivityPillarboxed && !mCompatUIConfiguration.hasSeenVerticalReachabilityEducation(taskInfo); if (isFirstTimeHorizontalReachabilityEdu || isFirstTimeVerticalReachabilityEdu) { mIsFirstReachabilityEducationRunning = true; mCompatUIConfiguration.setSeenLetterboxEducation(taskInfo.userId); createOrUpdateReachabilityEduLayout(taskInfo, taskListener); return; } } } createOrUpdateCompatLayout(taskInfo, taskListener); createOrUpdateRestartDialogLayout(taskInfo, taskListener); if (mCompatUIConfiguration.getHasSeenLetterboxEducation(taskInfo.userId)) { createOrUpdateReachabilityEduLayout(taskInfo, taskListener); Loading Loading @@ -589,6 +620,7 @@ public class CompatUIController implements OnDisplaysChangedListener, private void onInitialReachabilityEduDismissed(@NonNull TaskInfo taskInfo, @NonNull ShellTaskOrganizer.TaskListener taskListener) { // We need to update the UI otherwise it will not be shown until the user relaunches the app mIsFirstReachabilityEducationRunning = false; createOrUpdateUserAspectRatioSettingsLayout(taskInfo, taskListener); } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -668,6 +668,18 @@ public class CompatUIControllerTest extends ShellTestCase { Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton()); } @Test public void testLetterboxEduLayout_notCreatedWhenLetterboxEducationIsDisabled() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN); taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = false; mController.onCompatInfoChanged(taskInfo, mMockTaskListener); verify(mController, never()).createLetterboxEduWindowManager(any(), eq(taskInfo), eq(mMockTaskListener)); } private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat, @CameraCompatControlState int cameraCompatControlState) { return createTaskInfo(displayId, taskId, hasSizeCompat, cameraCompatControlState, Loading @@ -693,6 +705,8 @@ public class CompatUIControllerTest extends ShellTestCase { taskInfo.isVisible = isVisible; taskInfo.isFocused = isFocused; taskInfo.isTopActivityTransparent = isTopActivityTransparent; taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = true; taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed = true; return taskInfo; } }
services/core/java/com/android/server/wm/LetterboxUiController.java +4 −0 Original line number Diff line number Diff line Loading @@ -970,6 +970,10 @@ final class LetterboxUiController { } } boolean isLetterboxEducationEnabled() { return mLetterboxConfiguration.getIsEducationEnabled(); } /** * Whether we use split screen aspect ratio for the activity when camera compat treatment * is active because the corresponding config is enabled and activity supports resizing. Loading
services/core/java/com/android/server/wm/Task.java +2 −0 Original line number Diff line number Diff line Loading @@ -3541,6 +3541,8 @@ class Task extends TaskFragment { // Whether the direct top activity is eligible for letterbox education. appCompatTaskInfo.topActivityEligibleForLetterboxEducation = isTopActivityResumed && top.isEligibleForLetterboxEducation(); appCompatTaskInfo.isLetterboxEducationEnabled = top != null && top.mLetterboxUiController.isLetterboxEducationEnabled(); // Whether the direct top activity requested showing camera compat control. appCompatTaskInfo.cameraCompatControlState = isTopActivityResumed ? top.getCameraCompatControlState() Loading