Skip to content

Commit fb46276

Browse files
author
Android Build Coastguard Worker
committed
Merge cherrypicks of ['googleplex-android-review.googlesource.com/23053887', 'googleplex-android-review.googlesource.com/23054378', 'googleplex-android-review.googlesource.com/22733606', 'googleplex-android-review.googlesource.com/22912038', 'googleplex-android-review.googlesource.com/22915981', 'googleplex-android-review.googlesource.com/23048037', 'googleplex-android-review.googlesource.com/23103421'] into sparse-10099262-L86600000960563267.
SPARSE_CHANGE: I98618477a828eb72b2173af6988e804471139e81 SPARSE_CHANGE: Ic7b1c4b40960fd04de9efbf4f6d7abee45c93025 SPARSE_CHANGE: I1c51c6f66cd6967651068de1ffc2e6e8566f5a46 SPARSE_CHANGE: I35ba4652a125c8c83e18138f0fb0a51f3ef65b73 SPARSE_CHANGE: I2bfdc7801cec1b3aaa44f841d8a821214c6cb801 SPARSE_CHANGE: I62e829555c43136080ee4909f7dcf8c388165e9f SPARSE_CHANGE: Ib4eef40a0f59512c669b069532e55d36293f9e1c Change-Id: If333e1f0e70f3ac79663474de4417017bca30310
2 parents a056e02 + ad3fb95 commit fb46276

12 files changed

Lines changed: 239 additions & 89 deletions

File tree

libs/hwui/renderthread/VulkanSurface.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@ void VulkanSurface::releaseBuffers() {
368368
}
369369
}
370370

371+
void VulkanSurface::invalidateBuffers() {
372+
for (uint32_t i = 0; i < mWindowInfo.bufferCount; i++) {
373+
VulkanSurface::NativeBufferInfo& bufferInfo = mNativeBuffers[i];
374+
bufferInfo.hasValidContents = false;
375+
bufferInfo.lastPresentedCount = 0;
376+
}
377+
}
378+
371379
VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() {
372380
// Set the mCurrentBufferInfo to invalid in case of error and only reset it to the correct
373381
// value at the end of the function if everything dequeued correctly.
@@ -400,6 +408,10 @@ VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() {
400408
// new NativeBufferInfo storage will be populated lazily as we dequeue each new buffer.
401409
mWindowInfo.actualSize = actualSize;
402410
releaseBuffers();
411+
} else {
412+
// A change in transform means we need to repaint the entire buffer area as the damage
413+
// rects have just moved about.
414+
invalidateBuffers();
403415
}
404416

405417
if (transformHint != mWindowInfo.transform) {

libs/hwui/renderthread/VulkanSurface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class VulkanSurface {
113113
WindowInfo* outWindowInfo);
114114
static bool UpdateWindow(ANativeWindow* window, const WindowInfo& windowInfo);
115115
void releaseBuffers();
116+
void invalidateBuffers();
116117

117118
// TODO: This number comes from ui/BufferQueueDefs. We're not pulling the
118119
// header in so that we don't need to depend on libui, but we should share

packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,6 +2843,7 @@ public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
28432843
/** Set whether the bouncer is showing. */
28442844
public void setBouncerShowing(boolean bouncerShowing) {
28452845
mBouncerShowing = bouncerShowing;
2846+
mNotificationStackScrollLayoutController.updateShowEmptyShadeView();
28462847
updateVisibility();
28472848
}
28482849

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,8 @@ public void updateShowEmptyShadeView() {
12401240
// Hide empty shade view when in transition to Keyguard.
12411241
// That avoids "No Notifications" to blink when transitioning to AOD.
12421242
// For more details, see: b/228790482
1243-
&& !isInTransitionToKeyguard();
1243+
&& !isInTransitionToKeyguard()
1244+
&& !mCentralSurfaces.isBouncerShowing();
12441245

12451246
mView.updateEmptyShadeView(shouldShow, mZenModeController.areNotificationsHiddenInShade());
12461247

packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,34 @@ public void testUpdateEmptyShadeView_splitShadeMode_alwaysShowEmptyView() {
294294
/* notifVisibleInShade= */ false);
295295
}
296296

297+
@Test
298+
public void testUpdateEmptyShadeView_bouncerShowing_hideEmptyView() {
299+
when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
300+
mController.attach(mNotificationStackScrollLayout);
301+
302+
when(mCentralSurfaces.isBouncerShowing()).thenReturn(true);
303+
setupShowEmptyShadeViewState(true);
304+
reset(mNotificationStackScrollLayout);
305+
mController.updateShowEmptyShadeView();
306+
verify(mNotificationStackScrollLayout).updateEmptyShadeView(
307+
/* visible= */ false,
308+
/* areNotificationsHiddenInShade= */ false);
309+
}
310+
311+
@Test
312+
public void testUpdateEmptyShadeView_bouncerNotShowing_showEmptyView() {
313+
when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
314+
mController.attach(mNotificationStackScrollLayout);
315+
316+
when(mCentralSurfaces.isBouncerShowing()).thenReturn(false);
317+
setupShowEmptyShadeViewState(true);
318+
reset(mNotificationStackScrollLayout);
319+
mController.updateShowEmptyShadeView();
320+
verify(mNotificationStackScrollLayout).updateEmptyShadeView(
321+
/* visible= */ true,
322+
/* areNotificationsHiddenInShade= */ false);
323+
}
324+
297325
@Test
298326
public void testOnUserChange_verifySensitiveProfile() {
299327
when(mNotificationLockscreenUserManager.isAnyProfilePublicMode()).thenReturn(true);

services/core/java/com/android/server/wm/ActivityRecord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ void onParentChanged(ConfigurationContainer rawNewParent, ConfigurationContainer
16121612
newParent.setResumedActivity(this, "onParentChanged");
16131613
mImeInsetsFrozenUntilStartInput = false;
16141614
}
1615-
mLetterboxUiController.onActivityParentChanged(newParent);
1615+
mLetterboxUiController.updateInheritedLetterbox();
16161616
}
16171617

16181618
if (rootTask != null && rootTask.topRunningActivity() == this) {

services/core/java/com/android/server/wm/DisplayPolicy.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.android.server.wm;
1818

1919
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
20-
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
2120
import static android.view.Display.TYPE_INTERNAL;
2221
import static android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES;
2322
import static android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
@@ -2382,16 +2381,16 @@ int updateLightNavigationBarLw(int appearance, WindowState navColorWin) {
23822381

23832382
private int updateSystemBarsLw(WindowState win, int disableFlags) {
23842383
final TaskDisplayArea defaultTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
2385-
final boolean multiWindowTaskVisible =
2384+
final boolean adjacentTasksVisible =
23862385
defaultTaskDisplayArea.getRootTask(task -> task.isVisible()
2387-
&& task.getTopLeafTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW)
2386+
&& task.getAdjacentTask() != null)
23882387
!= null;
23892388
final boolean freeformRootTaskVisible =
23902389
defaultTaskDisplayArea.isRootTaskVisible(WINDOWING_MODE_FREEFORM);
23912390

23922391
// We need to force showing system bars when the multi-window or freeform root task is
23932392
// visible.
2394-
mForceShowSystemBars = multiWindowTaskVisible || freeformRootTaskVisible;
2393+
mForceShowSystemBars = adjacentTasksVisible || freeformRootTaskVisible;
23952394
// We need to force the consumption of the system bars if they are force shown or if they
23962395
// are controlled by a remote insets controller.
23972396
mForceConsumeSystemBars = mForceShowSystemBars
@@ -2412,7 +2411,7 @@ private int updateSystemBarsLw(WindowState win, int disableFlags) {
24122411

24132412
int appearance = APPEARANCE_OPAQUE_NAVIGATION_BARS | APPEARANCE_OPAQUE_STATUS_BARS;
24142413
appearance = configureStatusBarOpacity(appearance);
2415-
appearance = configureNavBarOpacity(appearance, multiWindowTaskVisible,
2414+
appearance = configureNavBarOpacity(appearance, adjacentTasksVisible,
24162415
freeformRootTaskVisible);
24172416

24182417
final boolean requestHideNavBar = !win.getRequestedVisibility(ITYPE_NAVIGATION_BAR);

services/core/java/com/android/server/wm/LetterboxUiController.java

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@
112112
import com.android.server.wm.LetterboxConfiguration.LetterboxBackgroundType;
113113

114114
import java.io.PrintWriter;
115+
import java.util.ArrayList;
116+
import java.util.List;
115117
import java.util.Optional;
116118
import java.util.function.BooleanSupplier;
117119
import java.util.function.Consumer;
@@ -126,8 +128,7 @@
126128
final class LetterboxUiController {
127129

128130
private static final Predicate<ActivityRecord> FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE =
129-
activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing()
130-
&& activityRecord.nowVisible;
131+
activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing();
131132

132133
private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxUiController" : TAG_ATM;
133134

@@ -185,6 +186,10 @@ final class LetterboxUiController {
185186
// Corresponds to OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS
186187
private final boolean mIsOverrideEnableCompatFakeFocusEnabled;
187188

189+
// The list of observers for the destroy event of candidate opaque activities
190+
// when dealing with translucent activities.
191+
private final List<LetterboxUiController> mDestroyListeners = new ArrayList<>();
192+
188193
@Nullable
189194
private final Boolean mBooleanPropertyAllowOrientationOverride;
190195
@Nullable
@@ -198,6 +203,10 @@ final class LetterboxUiController {
198203
@Nullable
199204
private WindowContainerListener mLetterboxConfigListener;
200205

206+
@Nullable
207+
@VisibleForTesting
208+
ActivityRecord mFirstOpaqueActivityBeneath;
209+
201210
private boolean mShowWallpaperForLetterboxBackground;
202211

203212
// In case of transparent activities we might need to access the aspectRatio of the
@@ -361,6 +370,10 @@ void destroy() {
361370
mLetterbox.destroy();
362371
mLetterbox = null;
363372
}
373+
for (int i = mDestroyListeners.size() - 1; i >= 0; i--) {
374+
mDestroyListeners.get(i).updateInheritedLetterbox();
375+
}
376+
mDestroyListeners.clear();
364377
if (mLetterboxConfigListener != null) {
365378
mLetterboxConfigListener.onRemoved();
366379
mLetterboxConfigListener = null;
@@ -1577,7 +1590,11 @@ LetterboxDetails getLetterboxDetails() {
15771590
* first opaque activity beneath.
15781591
* @param parent The parent container.
15791592
*/
1580-
void onActivityParentChanged(WindowContainer<?> parent) {
1593+
void updateInheritedLetterbox() {
1594+
final WindowContainer<?> parent = mActivityRecord.getParent();
1595+
if (parent == null) {
1596+
return;
1597+
}
15811598
if (!mLetterboxConfiguration.isTranslucentLetterboxingEnabled()) {
15821599
return;
15831600
}
@@ -1587,27 +1604,28 @@ void onActivityParentChanged(WindowContainer<?> parent) {
15871604
}
15881605
// In case mActivityRecord.hasCompatDisplayInsetsWithoutOverride() we don't apply the
15891606
// opaque activity constraints because we're expecting the activity is already letterboxed.
1590-
if (mActivityRecord.getTask() == null || mActivityRecord.fillsParent()
1591-
|| mActivityRecord.hasCompatDisplayInsetsWithoutInheritance()) {
1592-
return;
1593-
}
1594-
final ActivityRecord firstOpaqueActivityBeneath = mActivityRecord.getTask().getActivity(
1607+
mFirstOpaqueActivityBeneath = mActivityRecord.getTask().getActivity(
15951608
FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE /* callback */,
15961609
mActivityRecord /* boundary */, false /* includeBoundary */,
15971610
true /* traverseTopToBottom */);
1598-
if (firstOpaqueActivityBeneath == null) {
1611+
if (mFirstOpaqueActivityBeneath == null || mFirstOpaqueActivityBeneath.isEmbedded()) {
15991612
// We skip letterboxing if the translucent activity doesn't have any opaque
1600-
// activities beneath
1613+
// activities beneath or the activity below is embedded which never has letterbox.
1614+
mActivityRecord.recomputeConfiguration();
16011615
return;
16021616
}
1603-
inheritConfiguration(firstOpaqueActivityBeneath);
1617+
if (mActivityRecord.getTask() == null || mActivityRecord.fillsParent()
1618+
|| mActivityRecord.hasCompatDisplayInsetsWithoutInheritance()) {
1619+
return;
1620+
}
1621+
mFirstOpaqueActivityBeneath.mLetterboxUiController.mDestroyListeners.add(this);
1622+
inheritConfiguration(mFirstOpaqueActivityBeneath);
16041623
mLetterboxConfigListener = WindowContainer.overrideConfigurationPropagation(
1605-
mActivityRecord, firstOpaqueActivityBeneath,
1606-
(opaqueConfig, transparentConfig) -> {
1607-
final Configuration mutatedConfiguration =
1608-
fromOriginalTranslucentConfig(transparentConfig);
1624+
mActivityRecord, mFirstOpaqueActivityBeneath,
1625+
(opaqueConfig, transparentOverrideConfig) -> {
1626+
resetTranslucentOverrideConfig(transparentOverrideConfig);
16091627
final Rect parentBounds = parent.getWindowConfiguration().getBounds();
1610-
final Rect bounds = mutatedConfiguration.windowConfiguration.getBounds();
1628+
final Rect bounds = transparentOverrideConfig.windowConfiguration.getBounds();
16111629
final Rect letterboxBounds = opaqueConfig.windowConfiguration.getBounds();
16121630
// We cannot use letterboxBounds directly here because the position relies on
16131631
// letterboxing. Using letterboxBounds directly, would produce a double offset.
@@ -1616,9 +1634,9 @@ void onActivityParentChanged(WindowContainer<?> parent) {
16161634
parentBounds.top + letterboxBounds.height());
16171635
// We need to initialize appBounds to avoid NPE. The actual value will
16181636
// be set ahead when resolving the Configuration for the activity.
1619-
mutatedConfiguration.windowConfiguration.setAppBounds(new Rect());
1620-
inheritConfiguration(firstOpaqueActivityBeneath);
1621-
return mutatedConfiguration;
1637+
transparentOverrideConfig.windowConfiguration.setAppBounds(new Rect());
1638+
inheritConfiguration(mFirstOpaqueActivityBeneath);
1639+
return transparentOverrideConfig;
16221640
});
16231641
}
16241642

@@ -1691,26 +1709,19 @@ Optional<ActivityRecord> findOpaqueNotFinishingActivityBelow() {
16911709
if (!hasInheritedLetterboxBehavior() || mActivityRecord.getTask() == null) {
16921710
return Optional.empty();
16931711
}
1694-
return Optional.ofNullable(mActivityRecord.getTask().getActivity(
1695-
FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE /* callback */,
1696-
mActivityRecord /* boundary */, false /* includeBoundary */,
1697-
true /* traverseTopToBottom */));
1712+
return Optional.ofNullable(mFirstOpaqueActivityBeneath);
16981713
}
16991714

1700-
// When overriding translucent activities configuration we need to keep some of the
1701-
// original properties
1702-
private Configuration fromOriginalTranslucentConfig(Configuration translucentConfig) {
1703-
final Configuration configuration = new Configuration(translucentConfig);
1715+
/** Resets the screen size related fields so they can be resolved by requested bounds later. */
1716+
private static void resetTranslucentOverrideConfig(Configuration config) {
17041717
// The values for the following properties will be defined during the configuration
17051718
// resolution in {@link ActivityRecord#resolveOverrideConfiguration} using the
17061719
// properties inherited from the first not finishing opaque activity beneath.
1707-
configuration.orientation = ORIENTATION_UNDEFINED;
1708-
configuration.screenWidthDp = configuration.compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
1709-
configuration.screenHeightDp =
1710-
configuration.compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
1711-
configuration.smallestScreenWidthDp =
1712-
configuration.compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
1713-
return configuration;
1720+
config.orientation = ORIENTATION_UNDEFINED;
1721+
config.screenWidthDp = config.compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
1722+
config.screenHeightDp = config.compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
1723+
config.smallestScreenWidthDp = config.compatSmallestScreenWidthDp =
1724+
SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
17141725
}
17151726

17161727
private void inheritConfiguration(ActivityRecord firstOpaque) {
@@ -1729,6 +1740,10 @@ private void inheritConfiguration(ActivityRecord firstOpaque) {
17291740
}
17301741

17311742
private void clearInheritedConfig() {
1743+
if (mFirstOpaqueActivityBeneath != null) {
1744+
mFirstOpaqueActivityBeneath.mLetterboxUiController.mDestroyListeners.remove(this);
1745+
}
1746+
mFirstOpaqueActivityBeneath = null;
17321747
mLetterboxConfigListener = null;
17331748
mInheritedMinAspectRatio = UNDEFINED_ASPECT_RATIO;
17341749
mInheritedMaxAspectRatio = UNDEFINED_ASPECT_RATIO;

services/core/java/com/android/server/wm/Task.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,22 @@ Task getCreatedByOrganizerTask() {
23852385
return parentTask == null ? null : parentTask.getCreatedByOrganizerTask();
23862386
}
23872387

2388+
/** @return the first adjacent task of this task or its parent. */
2389+
@Nullable
2390+
Task getAdjacentTask() {
2391+
final TaskFragment adjacentTaskFragment = getAdjacentTaskFragment();
2392+
if (adjacentTaskFragment != null && adjacentTaskFragment.asTask() != null) {
2393+
return adjacentTaskFragment.asTask();
2394+
}
2395+
2396+
final WindowContainer parent = getParent();
2397+
if (parent == null || parent.asTask() == null) {
2398+
return null;
2399+
}
2400+
2401+
return parent.asTask().getAdjacentTask();
2402+
}
2403+
23882404
// TODO(task-merge): Figure out what's the right thing to do for places that used it.
23892405
boolean isRootTask() {
23902406
return getRootTask() == this;

services/core/java/com/android/server/wm/WindowContainer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,9 @@ void checkAppWindowsReadyToShow() {
13961396
}
13971397

13981398
void onAppTransitionDone() {
1399+
if (mSurfaceFreezer.hasLeash()) {
1400+
mSurfaceFreezer.unfreeze(getSyncTransaction());
1401+
}
13991402
for (int i = mChildren.size() - 1; i >= 0; --i) {
14001403
final WindowContainer wc = mChildren.get(i);
14011404
wc.onAppTransitionDone();

0 commit comments

Comments
 (0)