diff options
12 files changed, 89 insertions, 239 deletions
diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp index cbee104aa3b0..666f32939206 100644 --- a/libs/hwui/renderthread/VulkanSurface.cpp +++ b/libs/hwui/renderthread/VulkanSurface.cpp @@ -368,14 +368,6 @@ void VulkanSurface::releaseBuffers() { } } -void VulkanSurface::invalidateBuffers() { - for (uint32_t i = 0; i < mWindowInfo.bufferCount; i++) { - VulkanSurface::NativeBufferInfo& bufferInfo = mNativeBuffers[i]; - bufferInfo.hasValidContents = false; - bufferInfo.lastPresentedCount = 0; - } -} - VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() { // Set the mCurrentBufferInfo to invalid in case of error and only reset it to the correct // value at the end of the function if everything dequeued correctly. @@ -408,10 +400,6 @@ VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() { // new NativeBufferInfo storage will be populated lazily as we dequeue each new buffer. mWindowInfo.actualSize = actualSize; releaseBuffers(); - } else { - // A change in transform means we need to repaint the entire buffer area as the damage - // rects have just moved about. - invalidateBuffers(); } if (transformHint != mWindowInfo.transform) { diff --git a/libs/hwui/renderthread/VulkanSurface.h b/libs/hwui/renderthread/VulkanSurface.h index ff328b25d195..b8ccf7810b5d 100644 --- a/libs/hwui/renderthread/VulkanSurface.h +++ b/libs/hwui/renderthread/VulkanSurface.h @@ -113,7 +113,6 @@ private: WindowInfo* outWindowInfo); static bool UpdateWindow(ANativeWindow* window, const WindowInfo& windowInfo); void releaseBuffers(); - void invalidateBuffers(); // TODO: This number comes from ui/BufferQueueDefs. We're not pulling the // header in so that we don't need to depend on libui, but we should share diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 6cd0aee62551..7388c27ed313 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -2843,7 +2843,6 @@ public final class NotificationPanelViewController implements Dumpable { /** Set whether the bouncer is showing. */ public void setBouncerShowing(boolean bouncerShowing) { mBouncerShowing = bouncerShowing; - mNotificationStackScrollLayoutController.updateShowEmptyShadeView(); updateVisibility(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index f6c260a875ea..906b9592e3dd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -1240,8 +1240,7 @@ public class NotificationStackScrollLayoutController { // Hide empty shade view when in transition to Keyguard. // That avoids "No Notifications" to blink when transitioning to AOD. // For more details, see: b/228790482 - && !isInTransitionToKeyguard() - && !mCentralSurfaces.isBouncerShowing(); + && !isInTransitionToKeyguard(); mView.updateEmptyShadeView(shouldShow, mZenModeController.areNotificationsHiddenInShade()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java index ac60626ba768..45ae96c10345 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java @@ -295,34 +295,6 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { } @Test - public void testUpdateEmptyShadeView_bouncerShowing_hideEmptyView() { - when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false); - mController.attach(mNotificationStackScrollLayout); - - when(mCentralSurfaces.isBouncerShowing()).thenReturn(true); - setupShowEmptyShadeViewState(true); - reset(mNotificationStackScrollLayout); - mController.updateShowEmptyShadeView(); - verify(mNotificationStackScrollLayout).updateEmptyShadeView( - /* visible= */ false, - /* areNotificationsHiddenInShade= */ false); - } - - @Test - public void testUpdateEmptyShadeView_bouncerNotShowing_showEmptyView() { - when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false); - mController.attach(mNotificationStackScrollLayout); - - when(mCentralSurfaces.isBouncerShowing()).thenReturn(false); - setupShowEmptyShadeViewState(true); - reset(mNotificationStackScrollLayout); - mController.updateShowEmptyShadeView(); - verify(mNotificationStackScrollLayout).updateEmptyShadeView( - /* visible= */ true, - /* areNotificationsHiddenInShade= */ false); - } - - @Test public void testOnUserChange_verifySensitiveProfile() { when(mNotificationLockscreenUserManager.isAnyProfilePublicMode()).thenReturn(true); diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index a6236251635a..d872ada1fd0c 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -1612,7 +1612,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A newParent.setResumedActivity(this, "onParentChanged"); mImeInsetsFrozenUntilStartInput = false; } - mLetterboxUiController.updateInheritedLetterbox(); + mLetterboxUiController.onActivityParentChanged(newParent); } if (rootTask != null && rootTask.topRunningActivity() == this) { diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 0da178b2bcd0..988e98f28d10 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -17,6 +17,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; +import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.view.Display.TYPE_INTERNAL; import static android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES; import static android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT; @@ -2381,16 +2382,16 @@ public class DisplayPolicy { private int updateSystemBarsLw(WindowState win, int disableFlags) { final TaskDisplayArea defaultTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea(); - final boolean adjacentTasksVisible = + final boolean multiWindowTaskVisible = defaultTaskDisplayArea.getRootTask(task -> task.isVisible() - && task.getAdjacentTask() != null) + && task.getTopLeafTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW) != null; final boolean freeformRootTaskVisible = defaultTaskDisplayArea.isRootTaskVisible(WINDOWING_MODE_FREEFORM); // We need to force showing system bars when the multi-window or freeform root task is // visible. - mForceShowSystemBars = adjacentTasksVisible || freeformRootTaskVisible; + mForceShowSystemBars = multiWindowTaskVisible || freeformRootTaskVisible; // We need to force the consumption of the system bars if they are force shown or if they // are controlled by a remote insets controller. mForceConsumeSystemBars = mForceShowSystemBars @@ -2411,7 +2412,7 @@ public class DisplayPolicy { int appearance = APPEARANCE_OPAQUE_NAVIGATION_BARS | APPEARANCE_OPAQUE_STATUS_BARS; appearance = configureStatusBarOpacity(appearance); - appearance = configureNavBarOpacity(appearance, adjacentTasksVisible, + appearance = configureNavBarOpacity(appearance, multiWindowTaskVisible, freeformRootTaskVisible); final boolean requestHideNavBar = !win.getRequestedVisibility(ITYPE_NAVIGATION_BAR); diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index d69542c42548..684e787ec4cf 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -112,8 +112,6 @@ import com.android.internal.statusbar.LetterboxDetails; import com.android.server.wm.LetterboxConfiguration.LetterboxBackgroundType; import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; import java.util.Optional; import java.util.function.BooleanSupplier; import java.util.function.Consumer; @@ -128,7 +126,8 @@ import java.util.function.Predicate; final class LetterboxUiController { private static final Predicate<ActivityRecord> FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE = - activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing(); + activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing() + && activityRecord.nowVisible; private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxUiController" : TAG_ATM; @@ -186,10 +185,6 @@ final class LetterboxUiController { // Corresponds to OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS private final boolean mIsOverrideEnableCompatFakeFocusEnabled; - // The list of observers for the destroy event of candidate opaque activities - // when dealing with translucent activities. - private final List<LetterboxUiController> mDestroyListeners = new ArrayList<>(); - @Nullable private final Boolean mBooleanPropertyAllowOrientationOverride; @Nullable @@ -203,10 +198,6 @@ final class LetterboxUiController { @Nullable private WindowContainerListener mLetterboxConfigListener; - @Nullable - @VisibleForTesting - ActivityRecord mFirstOpaqueActivityBeneath; - private boolean mShowWallpaperForLetterboxBackground; // In case of transparent activities we might need to access the aspectRatio of the @@ -370,10 +361,6 @@ final class LetterboxUiController { mLetterbox.destroy(); mLetterbox = null; } - for (int i = mDestroyListeners.size() - 1; i >= 0; i--) { - mDestroyListeners.get(i).updateInheritedLetterbox(); - } - mDestroyListeners.clear(); if (mLetterboxConfigListener != null) { mLetterboxConfigListener.onRemoved(); mLetterboxConfigListener = null; @@ -1590,11 +1577,7 @@ final class LetterboxUiController { * first opaque activity beneath. * @param parent The parent container. */ - void updateInheritedLetterbox() { - final WindowContainer<?> parent = mActivityRecord.getParent(); - if (parent == null) { - return; - } + void onActivityParentChanged(WindowContainer<?> parent) { if (!mLetterboxConfiguration.isTranslucentLetterboxingEnabled()) { return; } @@ -1604,28 +1587,27 @@ final class LetterboxUiController { } // In case mActivityRecord.hasCompatDisplayInsetsWithoutOverride() we don't apply the // opaque activity constraints because we're expecting the activity is already letterboxed. - mFirstOpaqueActivityBeneath = mActivityRecord.getTask().getActivity( + if (mActivityRecord.getTask() == null || mActivityRecord.fillsParent() + || mActivityRecord.hasCompatDisplayInsetsWithoutInheritance()) { + return; + } + final ActivityRecord firstOpaqueActivityBeneath = mActivityRecord.getTask().getActivity( FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE /* callback */, mActivityRecord /* boundary */, false /* includeBoundary */, true /* traverseTopToBottom */); - if (mFirstOpaqueActivityBeneath == null || mFirstOpaqueActivityBeneath.isEmbedded()) { + if (firstOpaqueActivityBeneath == null) { // We skip letterboxing if the translucent activity doesn't have any opaque - // activities beneath or the activity below is embedded which never has letterbox. - mActivityRecord.recomputeConfiguration(); + // activities beneath return; } - if (mActivityRecord.getTask() == null || mActivityRecord.fillsParent() - || mActivityRecord.hasCompatDisplayInsetsWithoutInheritance()) { - return; - } - mFirstOpaqueActivityBeneath.mLetterboxUiController.mDestroyListeners.add(this); - inheritConfiguration(mFirstOpaqueActivityBeneath); + inheritConfiguration(firstOpaqueActivityBeneath); mLetterboxConfigListener = WindowContainer.overrideConfigurationPropagation( - mActivityRecord, mFirstOpaqueActivityBeneath, - (opaqueConfig, transparentOverrideConfig) -> { - resetTranslucentOverrideConfig(transparentOverrideConfig); + mActivityRecord, firstOpaqueActivityBeneath, + (opaqueConfig, transparentConfig) -> { + final Configuration mutatedConfiguration = + fromOriginalTranslucentConfig(transparentConfig); final Rect parentBounds = parent.getWindowConfiguration().getBounds(); - final Rect bounds = transparentOverrideConfig.windowConfiguration.getBounds(); + final Rect bounds = mutatedConfiguration.windowConfiguration.getBounds(); final Rect letterboxBounds = opaqueConfig.windowConfiguration.getBounds(); // We cannot use letterboxBounds directly here because the position relies on // letterboxing. Using letterboxBounds directly, would produce a double offset. @@ -1634,9 +1616,9 @@ final class LetterboxUiController { parentBounds.top + letterboxBounds.height()); // We need to initialize appBounds to avoid NPE. The actual value will // be set ahead when resolving the Configuration for the activity. - transparentOverrideConfig.windowConfiguration.setAppBounds(new Rect()); - inheritConfiguration(mFirstOpaqueActivityBeneath); - return transparentOverrideConfig; + mutatedConfiguration.windowConfiguration.setAppBounds(new Rect()); + inheritConfiguration(firstOpaqueActivityBeneath); + return mutatedConfiguration; }); } @@ -1709,19 +1691,26 @@ final class LetterboxUiController { if (!hasInheritedLetterboxBehavior() || mActivityRecord.getTask() == null) { return Optional.empty(); } - return Optional.ofNullable(mFirstOpaqueActivityBeneath); + return Optional.ofNullable(mActivityRecord.getTask().getActivity( + FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE /* callback */, + mActivityRecord /* boundary */, false /* includeBoundary */, + true /* traverseTopToBottom */)); } - /** Resets the screen size related fields so they can be resolved by requested bounds later. */ - private static void resetTranslucentOverrideConfig(Configuration config) { + // When overriding translucent activities configuration we need to keep some of the + // original properties + private Configuration fromOriginalTranslucentConfig(Configuration translucentConfig) { + final Configuration configuration = new Configuration(translucentConfig); // The values for the following properties will be defined during the configuration // resolution in {@link ActivityRecord#resolveOverrideConfiguration} using the // properties inherited from the first not finishing opaque activity beneath. - config.orientation = ORIENTATION_UNDEFINED; - config.screenWidthDp = config.compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED; - config.screenHeightDp = config.compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED; - config.smallestScreenWidthDp = config.compatSmallestScreenWidthDp = - SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; + configuration.orientation = ORIENTATION_UNDEFINED; + configuration.screenWidthDp = configuration.compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED; + configuration.screenHeightDp = + configuration.compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED; + configuration.smallestScreenWidthDp = + configuration.compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; + return configuration; } private void inheritConfiguration(ActivityRecord firstOpaque) { @@ -1740,10 +1729,6 @@ final class LetterboxUiController { } private void clearInheritedConfig() { - if (mFirstOpaqueActivityBeneath != null) { - mFirstOpaqueActivityBeneath.mLetterboxUiController.mDestroyListeners.remove(this); - } - mFirstOpaqueActivityBeneath = null; mLetterboxConfigListener = null; mInheritedMinAspectRatio = UNDEFINED_ASPECT_RATIO; mInheritedMaxAspectRatio = UNDEFINED_ASPECT_RATIO; diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 1ddc3e8c19b3..f5c44d94160b 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -2385,22 +2385,6 @@ class Task extends TaskFragment { return parentTask == null ? null : parentTask.getCreatedByOrganizerTask(); } - /** @return the first adjacent task of this task or its parent. */ - @Nullable - Task getAdjacentTask() { - final TaskFragment adjacentTaskFragment = getAdjacentTaskFragment(); - if (adjacentTaskFragment != null && adjacentTaskFragment.asTask() != null) { - return adjacentTaskFragment.asTask(); - } - - final WindowContainer parent = getParent(); - if (parent == null || parent.asTask() == null) { - return null; - } - - return parent.asTask().getAdjacentTask(); - } - // TODO(task-merge): Figure out what's the right thing to do for places that used it. boolean isRootTask() { return getRootTask() == this; diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 6ec08dc08c51..02d3af6da326 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -1396,9 +1396,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } void onAppTransitionDone() { - if (mSurfaceFreezer.hasLeash()) { - mSurfaceFreezer.unfreeze(getSyncTransaction()); - } for (int i = mChildren.size() - 1; i >= 0; --i) { final WindowContainer wc = mChildren.get(i); wc.onAppTransitionDone(); diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java index 9f376ad6edab..d3282b97a6b8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java @@ -81,14 +81,12 @@ public class InsetsPolicyTest extends WindowTestsBase { } @Test - public void testControlsForDispatch_adjacentTasksVisible() { + public void testControlsForDispatch_multiWindowTaskVisible() { addWindow(TYPE_STATUS_BAR, "statusBar"); addWindow(TYPE_NAVIGATION_BAR, "navBar"); - final Task task1 = createTask(mDisplayContent); - final Task task2 = createTask(mDisplayContent); - task1.setAdjacentTaskFragment(task2); - final WindowState win = createAppWindow(task1, WINDOWING_MODE_MULTI_WINDOW, "app"); + final WindowState win = createWindow(null, WINDOWING_MODE_MULTI_WINDOW, + ACTIVITY_TYPE_STANDARD, TYPE_APPLICATION, mDisplayContent, "app"); final InsetsSourceControl[] controls = addWindowAndGetControlsForDispatch(win); // The app must not control any system bars. diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 637ec7e92a7d..d93871e59b37 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -175,6 +175,44 @@ public class SizeCompatTests extends WindowTestsBase { } @Test + public void testActivityInHistoryAndNotVisibleIsNotUsedAsOpaqueForTranslucentActivities() { + mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); + setUpDisplaySizeWithApp(2000, 1000); + prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); + mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = false; + // Translucent Activity + final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) + .setLaunchedFromUid(mActivity.getUid()) + .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) + .build(); + doReturn(false).when(translucentActivity).fillsParent(); + + mTask.addChild(translucentActivity); + + assertFalse(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); + } + + @Test + public void testActivityInHistoryAndVisibleIsUsedAsOpaqueForTranslucentActivities() { + mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); + setUpDisplaySizeWithApp(2000, 1000); + prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); + mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = true; + // Translucent Activity + final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) + .setLaunchedFromUid(mActivity.getUid()) + .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) + .build(); + doReturn(false).when(translucentActivity).fillsParent(); + + mTask.addChild(translucentActivity); + + assertTrue(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); + } + + @Test public void testCleanLetterboxConfigListenerWhenTranslucentIsDestroyed() { mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); setUpDisplaySizeWithApp(2000, 1000); @@ -198,6 +236,7 @@ public class SizeCompatTests extends WindowTestsBase { public void testHorizontalReachabilityEnabledForTranslucentActivities() { setUpDisplaySizeWithApp(2500, 1000); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = true; final LetterboxConfiguration config = mWm.mLetterboxConfiguration; config.setTranslucentLetterboxingOverrideEnabled(true); config.setLetterboxHorizontalPositionMultiplier(0.5f); @@ -273,6 +312,7 @@ public class SizeCompatTests extends WindowTestsBase { public void testVerticalReachabilityEnabledForTranslucentActivities() { setUpDisplaySizeWithApp(1000, 2500); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = true; final LetterboxConfiguration config = mWm.mLetterboxConfiguration; config.setTranslucentLetterboxingOverrideEnabled(true); config.setLetterboxVerticalPositionMultiplier(0.5f); @@ -345,110 +385,13 @@ public class SizeCompatTests extends WindowTestsBase { } @Test - public void testApplyStrategyAgainWhenOpaqueIsDestroyed() { - mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); - setUpDisplaySizeWithApp(2000, 1000); - prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - // Launch another opaque activity - final ActivityRecord opaqueActivity = new ActivityBuilder(mAtm) - .setLaunchedFromUid(mActivity.getUid()) - .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) - .build(); - mTask.addChild(opaqueActivity); - // Transparent activity strategy not applied - assertFalse(opaqueActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); - - // Launch translucent Activity - final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) - .setLaunchedFromUid(mActivity.getUid()) - .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) - .build(); - doReturn(false).when(translucentActivity).fillsParent(); - mTask.addChild(translucentActivity); - // Transparent strategy applied - assertTrue(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); - - spyOn(translucentActivity.mLetterboxUiController); - clearInvocations(translucentActivity.mLetterboxUiController); - - // We destroy the first opaque activity - opaqueActivity.setState(DESTROYED, "testing"); - opaqueActivity.removeImmediately(); - - // Check that updateInheritedLetterbox() is invoked again - verify(translucentActivity.mLetterboxUiController).updateInheritedLetterbox(); - } - - @Test - public void testResetOpaqueReferenceWhenOpaqueIsDestroyed() { - mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); - setUpDisplaySizeWithApp(2000, 1000); - prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - - // Launch translucent Activity - final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) - .setLaunchedFromUid(mActivity.getUid()) - .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) - .build(); - doReturn(false).when(translucentActivity).fillsParent(); - mTask.addChild(translucentActivity); - // Transparent strategy applied - assertTrue(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); - assertNotNull(translucentActivity.mLetterboxUiController.mFirstOpaqueActivityBeneath); - - spyOn(translucentActivity.mLetterboxUiController); - clearInvocations(translucentActivity.mLetterboxUiController); - - // We destroy the first opaque activity - mActivity.setState(DESTROYED, "testing"); - mActivity.removeImmediately(); - - // Check that updateInheritedLetterbox() is invoked again - verify(translucentActivity.mLetterboxUiController).updateInheritedLetterbox(); - assertNull(translucentActivity.mLetterboxUiController.mFirstOpaqueActivityBeneath); - } - - @Test - public void testNotApplyStrategyAgainWhenOpaqueIsNotDestroyed() { - mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); - setUpDisplaySizeWithApp(2000, 1000); - prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - // Launch another opaque activity - final ActivityRecord opaqueActivity = new ActivityBuilder(mAtm) - .setLaunchedFromUid(mActivity.getUid()) - .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) - .build(); - mTask.addChild(opaqueActivity); - // Transparent activity strategy not applied - assertFalse(opaqueActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); - - // Launch translucent Activity - final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) - .setLaunchedFromUid(mActivity.getUid()) - .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT) - .build(); - doReturn(false).when(translucentActivity).fillsParent(); - mTask.addChild(translucentActivity); - // Transparent strategy applied - assertTrue(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); - - spyOn(translucentActivity.mLetterboxUiController); - clearInvocations(translucentActivity.mLetterboxUiController); - - // Check that updateInheritedLetterbox() is invoked again - verify(translucentActivity.mLetterboxUiController, never()).updateInheritedLetterbox(); - } - - @Test public void testApplyStrategyToTranslucentActivities() { mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); setUpDisplaySizeWithApp(2000, 1000); prepareUnresizable(mActivity, 1.5f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT); mActivity.info.setMinAspectRatio(1.2f); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = true; // Translucent Activity final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) .setLaunchedFromUid(mActivity.getUid()) @@ -505,6 +448,7 @@ public class SizeCompatTests extends WindowTestsBase { prepareUnresizable(mActivity, 1.5f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT); mActivity.info.setMinAspectRatio(1.2f); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = true; // Translucent Activity final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) .setLaunchedFromUid(mActivity.getUid()) @@ -531,25 +475,7 @@ public class SizeCompatTests extends WindowTestsBase { } @Test - public void testNotApplyStrategyToTranslucentActivitiesOverEmbeddedActivities() { - mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); - setUpDisplaySizeWithApp(2000, 1000); - mActivity.info.screenOrientation = SCREEN_ORIENTATION_PORTRAIT; - mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); - // Mock the activity as embedded without additional TaskFragment layer in the task for - // simplicity. - doReturn(true).when(mActivity).isEmbedded(); - // Translucent Activity - final ActivityRecord translucentActivity = new ActivityBuilder(mAtm).build(); - doReturn(false).when(translucentActivity).matchParentBounds(); - doReturn(false).when(translucentActivity).fillsParent(); - mTask.addChild(translucentActivity); - // Check the strategy has not being applied - assertFalse(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior()); - } - - @Test - public void testTranslucentActivitiesDontGoInSizeCompactMode() { + public void testTranslucentActivitiesDontGoInSizeCompatMode() { mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); setUpDisplaySizeWithApp(2800, 1400); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); @@ -598,6 +524,7 @@ public class SizeCompatTests extends WindowTestsBase { true /* ignoreOrientationRequest */); mActivity.mWmService.mLetterboxConfiguration.setLetterboxHorizontalPositionMultiplier( 1.0f /*letterboxVerticalPositionMultiplier*/); + mActivity.nowVisible = true; prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); // We launch a transparent activity final ActivityRecord translucentActivity = new ActivityBuilder(mAtm) @@ -630,6 +557,7 @@ public class SizeCompatTests extends WindowTestsBase { mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true); setUpDisplaySizeWithApp(2800, 1400); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + mActivity.nowVisible = true; prepareUnresizable(mActivity, -1f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT); // Rotate to put activity in size compat mode. rotateDisplay(mActivity.mDisplayContent, ROTATION_90); |