Merge "wallpaper: add reportVisibility(forceReport)" into udc-dev

This commit is contained in:
Lucas Dupin
2023-03-03 15:53:05 +00:00
committed by Android (Google) Code Review

View File

@@ -1543,14 +1543,14 @@ public abstract class WallpaperService extends Service {
void doVisibilityChanged(boolean visible) { void doVisibilityChanged(boolean visible) {
if (!mDestroyed) { if (!mDestroyed) {
mVisible = visible; mVisible = visible;
reportVisibility(); reportVisibility(false);
if (mReportedVisible) processLocalColors(); if (mReportedVisible) processLocalColors();
} else { } else {
AnimationHandler.requestAnimatorsEnabled(visible, this); AnimationHandler.requestAnimatorsEnabled(visible, this);
} }
} }
void reportVisibility() { void reportVisibility(boolean forceReport) {
if (mScreenshotSurfaceControl != null && mVisible) { if (mScreenshotSurfaceControl != null && mVisible) {
if (DEBUG) Log.v(TAG, "Frozen so don't report visibility change"); if (DEBUG) Log.v(TAG, "Frozen so don't report visibility change");
return; return;
@@ -1558,10 +1558,29 @@ public abstract class WallpaperService extends Service {
if (!mDestroyed) { if (!mDestroyed) {
mDisplayState = mDisplay == null ? Display.STATE_UNKNOWN : mDisplay.getState(); mDisplayState = mDisplay == null ? Display.STATE_UNKNOWN : mDisplay.getState();
boolean visible = mVisible && mDisplayState != Display.STATE_OFF; boolean visible = mVisible && mDisplayState != Display.STATE_OFF;
if (mReportedVisible != visible) { if (DEBUG) {
Log.v(
TAG,
"reportVisibility"
+ " mReportedVisible="
+ mReportedVisible
+ " mVisible="
+ mVisible
+ " mDisplayState="
+ mDisplayState);
}
if (mReportedVisible != visible || forceReport) {
mReportedVisible = visible; mReportedVisible = visible;
if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + visible if (DEBUG) {
+ "): " + this); Log.v(
TAG,
"onVisibilityChanged("
+ visible
+ "): "
+ this
+ " forceReport="
+ forceReport);
}
if (visible) { if (visible) {
// If becoming visible, in preview mode the surface // If becoming visible, in preview mode the surface
// may have been destroyed so now we need to make // may have been destroyed so now we need to make
@@ -2205,22 +2224,22 @@ public abstract class WallpaperService extends Service {
} }
} }
private final DisplayListener mDisplayListener = new DisplayListener() { private final DisplayListener mDisplayListener =
@Override new DisplayListener() {
public void onDisplayChanged(int displayId) { @Override
if (mDisplay.getDisplayId() == displayId) { public void onDisplayChanged(int displayId) {
reportVisibility(); if (mDisplay.getDisplayId() == displayId) {
} boolean forceReport = mDisplay.getState() != Display.STATE_DOZE_SUSPEND;
} reportVisibility(forceReport);
}
}
@Override @Override
public void onDisplayRemoved(int displayId) { public void onDisplayRemoved(int displayId) {}
}
@Override @Override
public void onDisplayAdded(int displayId) { public void onDisplayAdded(int displayId) {}
} };
};
private Surface getOrCreateBLASTSurface(int width, int height, int format) { private Surface getOrCreateBLASTSurface(int width, int height, int format) {
Surface ret = null; Surface ret = null;