Merge "Skip updating system bar attributes while relaunching related apps" into tm-qpr-dev am: eab3c0d8bc

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

Change-Id: Ia09520cc4915b56eb0e3bdbff0780f0142d87e71
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Tiger Huang
2022-11-12 15:21:37 +00:00
committed by Automerger Merge Worker
3 changed files with 75 additions and 9 deletions

View File

@@ -1750,6 +1750,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
} }
prevDc.mClosingApps.remove(this); prevDc.mClosingApps.remove(this);
prevDc.getDisplayPolicy().removeRelaunchingApp(this);
if (prevDc.mFocusedApp == this) { if (prevDc.mFocusedApp == this) {
prevDc.setFocusedApp(null); prevDc.setFocusedApp(null);
@@ -3969,6 +3970,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
void startRelaunching() { void startRelaunching() {
if (mPendingRelaunchCount == 0) { if (mPendingRelaunchCount == 0) {
mRelaunchStartTime = SystemClock.elapsedRealtime(); mRelaunchStartTime = SystemClock.elapsedRealtime();
if (mVisibleRequested) {
mDisplayContent.getDisplayPolicy().addRelaunchingApp(this);
}
} }
clearAllDrawn(); clearAllDrawn();
@@ -3982,7 +3986,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
mPendingRelaunchCount--; mPendingRelaunchCount--;
if (mPendingRelaunchCount == 0 && !isClientVisible()) { if (mPendingRelaunchCount == 0 && !isClientVisible()) {
// Don't count if the client won't report drawn. // Don't count if the client won't report drawn.
mRelaunchStartTime = 0; finishOrAbortReplacingWindow();
} }
} else { } else {
// Update keyguard flags upon finishing relaunch. // Update keyguard flags upon finishing relaunch.
@@ -4003,7 +4007,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return; return;
} }
mPendingRelaunchCount = 0; mPendingRelaunchCount = 0;
finishOrAbortReplacingWindow();
}
void finishOrAbortReplacingWindow() {
mRelaunchStartTime = 0; mRelaunchStartTime = 0;
mDisplayContent.getDisplayPolicy().removeRelaunchingApp(this);
} }
/** /**
@@ -5112,6 +5121,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */);
} }
logAppCompatState(); logAppCompatState();
if (!visible) {
finishOrAbortReplacingWindow();
}
} }
/** /**

View File

@@ -282,6 +282,12 @@ public class DisplayPolicy {
private final ArraySet<WindowState> mInsetsSourceWindowsExceptIme = new ArraySet<>(); private final ArraySet<WindowState> mInsetsSourceWindowsExceptIme = new ArraySet<>();
/** Apps which are controlling the appearance of system bars */
private final ArraySet<ActivityRecord> mSystemBarColorApps = new ArraySet<>();
/** Apps which are relaunching and were controlling the appearance of system bars */
private final ArraySet<ActivityRecord> mRelaunchingSystemBarColorApps = new ArraySet<>();
private boolean mIsFreeformWindowOverlappingWithNavBar; private boolean mIsFreeformWindowOverlappingWithNavBar;
private boolean mLastImmersiveMode; private boolean mLastImmersiveMode;
@@ -1550,6 +1556,7 @@ public class DisplayPolicy {
mStatusBarBackgroundWindows.clear(); mStatusBarBackgroundWindows.clear();
mStatusBarColorCheckedBounds.setEmpty(); mStatusBarColorCheckedBounds.setEmpty();
mStatusBarBackgroundCheckedBounds.setEmpty(); mStatusBarBackgroundCheckedBounds.setEmpty();
mSystemBarColorApps.clear();
mAllowLockscreenWhenOn = false; mAllowLockscreenWhenOn = false;
mShowingDream = false; mShowingDream = false;
@@ -1626,6 +1633,7 @@ public class DisplayPolicy {
win.mAttrs.insetsFlags.appearance & APPEARANCE_LIGHT_STATUS_BARS, win.mAttrs.insetsFlags.appearance & APPEARANCE_LIGHT_STATUS_BARS,
new Rect(win.getFrame()))); new Rect(win.getFrame())));
mStatusBarColorCheckedBounds.union(sTmpRect); mStatusBarColorCheckedBounds.union(sTmpRect);
addSystemBarColorApp(win);
} }
} }
@@ -1638,6 +1646,7 @@ public class DisplayPolicy {
if (isOverlappingWithNavBar) { if (isOverlappingWithNavBar) {
if (mNavBarColorWindowCandidate == null) { if (mNavBarColorWindowCandidate == null) {
mNavBarColorWindowCandidate = win; mNavBarColorWindowCandidate = win;
addSystemBarColorApp(win);
} }
if (mNavBarBackgroundWindow == null) { if (mNavBarBackgroundWindow == null) {
mNavBarBackgroundWindow = win; mNavBarBackgroundWindow = win;
@@ -1656,9 +1665,11 @@ public class DisplayPolicy {
} }
} else if (win.isDimming()) { } else if (win.isDimming()) {
if (mStatusBar != null) { if (mStatusBar != null) {
addStatusBarAppearanceRegionsForDimmingWindow( if (addStatusBarAppearanceRegionsForDimmingWindow(
win.mAttrs.insetsFlags.appearance & APPEARANCE_LIGHT_STATUS_BARS, win.mAttrs.insetsFlags.appearance & APPEARANCE_LIGHT_STATUS_BARS,
mStatusBar.getFrame(), win.getBounds(), win.getFrame()); mStatusBar.getFrame(), win.getBounds(), win.getFrame())) {
addSystemBarColorApp(win);
}
} }
if (isOverlappingWithNavBar && mNavBarColorWindowCandidate == null) { if (isOverlappingWithNavBar && mNavBarColorWindowCandidate == null) {
mNavBarColorWindowCandidate = win; mNavBarColorWindowCandidate = win;
@@ -1666,18 +1677,21 @@ public class DisplayPolicy {
} }
} }
private void addStatusBarAppearanceRegionsForDimmingWindow(int appearance, Rect statusBarFrame, /**
Rect winBounds, Rect winFrame) { * Returns true if mStatusBarAppearanceRegionList is changed.
*/
private boolean addStatusBarAppearanceRegionsForDimmingWindow(
int appearance, Rect statusBarFrame, Rect winBounds, Rect winFrame) {
if (!sTmpRect.setIntersect(winBounds, statusBarFrame)) { if (!sTmpRect.setIntersect(winBounds, statusBarFrame)) {
return; return false;
} }
if (mStatusBarColorCheckedBounds.contains(sTmpRect)) { if (mStatusBarColorCheckedBounds.contains(sTmpRect)) {
return; return false;
} }
if (appearance == 0 || !sTmpRect2.setIntersect(winFrame, statusBarFrame)) { if (appearance == 0 || !sTmpRect2.setIntersect(winFrame, statusBarFrame)) {
mStatusBarAppearanceRegionList.add(new AppearanceRegion(0, new Rect(winBounds))); mStatusBarAppearanceRegionList.add(new AppearanceRegion(0, new Rect(winBounds)));
mStatusBarColorCheckedBounds.union(sTmpRect); mStatusBarColorCheckedBounds.union(sTmpRect);
return; return true;
} }
// A dimming window can divide status bar into different appearance regions (up to 3). // A dimming window can divide status bar into different appearance regions (up to 3).
// +---------+-------------+---------+ // +---------+-------------+---------+
@@ -1706,6 +1720,14 @@ public class DisplayPolicy {
// We don't have vertical status bar yet, so we don't handle the other orientation. // We don't have vertical status bar yet, so we don't handle the other orientation.
} }
mStatusBarColorCheckedBounds.union(sTmpRect); mStatusBarColorCheckedBounds.union(sTmpRect);
return true;
}
private void addSystemBarColorApp(WindowState win) {
final ActivityRecord app = win.mActivityRecord;
if (app != null) {
mSystemBarColorApps.add(app);
}
} }
/** /**
@@ -2202,6 +2224,25 @@ public class DisplayPolicy {
return mDisplayContent.getInsetsPolicy(); return mDisplayContent.getInsetsPolicy();
} }
/**
* Called when an app has started replacing its main window.
*/
void addRelaunchingApp(ActivityRecord app) {
if (mSystemBarColorApps.contains(app)) {
mRelaunchingSystemBarColorApps.add(app);
}
}
/**
* Called when an app has finished replacing its main window or aborted.
*/
void removeRelaunchingApp(ActivityRecord app) {
final boolean removed = mRelaunchingSystemBarColorApps.remove(app);
if (removed & mRelaunchingSystemBarColorApps.isEmpty()) {
updateSystemBarAttributes();
}
}
void resetSystemBarAttributes() { void resetSystemBarAttributes() {
mLastDisableFlags = 0; mLastDisableFlags = 0;
updateSystemBarAttributes(); updateSystemBarAttributes();
@@ -2244,6 +2285,11 @@ public class DisplayPolicy {
final int displayId = getDisplayId(); final int displayId = getDisplayId();
final int disableFlags = win.getDisableFlags(); final int disableFlags = win.getDisableFlags();
final int opaqueAppearance = updateSystemBarsLw(win, disableFlags); final int opaqueAppearance = updateSystemBarsLw(win, disableFlags);
if (!mRelaunchingSystemBarColorApps.isEmpty()) {
// The appearance of system bars might change while relaunching apps. We don't report
// the intermediate state to system UI. Otherwise, it might trigger redundant effects.
return;
}
final WindowState navColorWin = chooseNavigationColorWindowLw(mNavBarColorWindowCandidate, final WindowState navColorWin = chooseNavigationColorWindowLw(mNavBarColorWindowCandidate,
mDisplayContent.mInputMethodWindow, mNavigationBarPosition); mDisplayContent.mInputMethodWindow, mNavigationBarPosition);
final boolean isNavbarColorManagedByIme = final boolean isNavbarColorManagedByIme =
@@ -2707,6 +2753,14 @@ public class DisplayPolicy {
pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState=");
pw.println(mTopFullscreenOpaqueWindowState); pw.println(mTopFullscreenOpaqueWindowState);
} }
if (!mSystemBarColorApps.isEmpty()) {
pw.print(prefix); pw.print("mSystemBarColorApps=");
pw.println(mSystemBarColorApps);
}
if (!mRelaunchingSystemBarColorApps.isEmpty()) {
pw.print(prefix); pw.print("mRelaunchingSystemBarColorApps=");
pw.println(mRelaunchingSystemBarColorApps);
}
if (mNavBarColorWindowCandidate != null) { if (mNavBarColorWindowCandidate != null) {
pw.print(prefix); pw.print("mNavBarColorWindowCandidate="); pw.print(prefix); pw.print("mNavBarColorWindowCandidate=");
pw.println(mNavBarColorWindowCandidate); pw.println(mNavBarColorWindowCandidate);

View File

@@ -6024,7 +6024,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final long duration = final long duration =
SystemClock.elapsedRealtime() - mActivityRecord.mRelaunchStartTime; SystemClock.elapsedRealtime() - mActivityRecord.mRelaunchStartTime;
Slog.i(TAG, "finishDrawing of relaunch: " + this + " " + duration + "ms"); Slog.i(TAG, "finishDrawing of relaunch: " + this + " " + duration + "ms");
mActivityRecord.mRelaunchStartTime = 0; mActivityRecord.finishOrAbortReplacingWindow();
} }
if (mActivityRecord != null && mAttrs.type == TYPE_APPLICATION_STARTING) { if (mActivityRecord != null && mAttrs.type == TYPE_APPLICATION_STARTING) {
mWmService.mAtmService.mTaskSupervisor.getActivityMetricsLogger() mWmService.mAtmService.mTaskSupervisor.getActivityMetricsLogger()