Merge "Only supports ambient mode when necessary." into qt-dev

am: 10a9fde8b5

Change-Id: I730338a57ee3c73f77dc7951ae45d6ad4f6246ee
This commit is contained in:
bsears
2019-07-28 10:49:37 -07:00
committed by android-build-merger
4 changed files with 38 additions and 24 deletions

View File

@@ -47,7 +47,7 @@ public class ImageWallpaper extends WallpaperService {
// This is to avoid destroying then recreating render context in a very short time. // This is to avoid destroying then recreating render context in a very short time.
private static final int DELAY_FINISH_RENDERING = 1000; private static final int DELAY_FINISH_RENDERING = 1000;
private static final int INTERVAL_WAIT_FOR_RENDERING = 100; private static final int INTERVAL_WAIT_FOR_RENDERING = 100;
private static final int PATIENCE_WAIT_FOR_RENDERING = 5; private static final int PATIENCE_WAIT_FOR_RENDERING = 10;
private HandlerThread mWorker; private HandlerThread mWorker;
@Override @Override
@@ -124,10 +124,10 @@ public class ImageWallpaper extends WallpaperService {
@Override @Override
public void onAmbientModeChanged(boolean inAmbientMode, long animationDuration) { public void onAmbientModeChanged(boolean inAmbientMode, long animationDuration) {
long duration = mNeedTransition || animationDuration != 0 ? animationDuration : 0; if (!mNeedTransition) return;
mWorker.getThreadHandler().post( mWorker.getThreadHandler().post(
() -> mRenderer.updateAmbientMode(inAmbientMode, duration)); () -> mRenderer.updateAmbientMode(inAmbientMode, animationDuration));
if (inAmbientMode && duration == 0) { if (inAmbientMode && animationDuration == 0) {
// This means that we are transiting from home to aod, to avoid // This means that we are transiting from home to aod, to avoid
// race condition between window visibility and transition, // race condition between window visibility and transition,
// we don't return until the transition is finished. See b/136643341. // we don't return until the transition is finished. See b/136643341.

View File

@@ -65,7 +65,7 @@ class ImageRevealHelper {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
if (mRevealListener != null) { if (mRevealListener != null) {
mRevealListener.onRevealStart(); mRevealListener.onRevealStart(true /* animate */);
} }
} }
}); });
@@ -73,7 +73,7 @@ class ImageRevealHelper {
private void animate() { private void animate() {
mAnimator.cancel(); mAnimator.cancel();
mAnimator.setFloatValues(mReveal, !mAwake ? MIN_REVEAL : MAX_REVEAL); mAnimator.setFloatValues(mReveal, mAwake ? MAX_REVEAL : MIN_REVEAL);
mAnimator.start(); mAnimator.start();
} }
@@ -84,12 +84,11 @@ class ImageRevealHelper {
void updateAwake(boolean awake, long duration) { void updateAwake(boolean awake, long duration) {
mAwake = awake; mAwake = awake;
mAnimator.setDuration(duration); mAnimator.setDuration(duration);
if (!mAwake && duration == 0) { if (duration == 0) {
// We are transiting from home to aod, // We are transiting from home to aod or aod to home directly,
// since main thread is waiting for rendering finished, we only need draw // we don't need to do transition in these cases.
// the last state directly, which is a black screen. mReveal = mAwake ? MAX_REVEAL : MIN_REVEAL;
mReveal = MIN_REVEAL; mRevealListener.onRevealStart(false /* animate */);
mRevealListener.onRevealStart();
mRevealListener.onRevealStateChanged(); mRevealListener.onRevealStateChanged();
mRevealListener.onRevealEnd(); mRevealListener.onRevealEnd();
} else { } else {
@@ -110,7 +109,7 @@ class ImageRevealHelper {
/** /**
* Called back while reveal starts. * Called back while reveal starts.
*/ */
void onRevealStart(); void onRevealStart(boolean animate);
/** /**
* Called back while reveal ends. * Called back while reveal ends.

View File

@@ -24,6 +24,7 @@ import static android.opengl.GLES20.glViewport;
import android.app.WallpaperManager; import android.app.WallpaperManager;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.Log; import android.util.Log;
@@ -70,7 +71,14 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer,
DisplayInfo displayInfo = new DisplayInfo(); DisplayInfo displayInfo = new DisplayInfo();
WindowManager wm = context.getSystemService(WindowManager.class); WindowManager wm = context.getSystemService(WindowManager.class);
wm.getDefaultDisplay().getDisplayInfo(displayInfo); wm.getDefaultDisplay().getDisplayInfo(displayInfo);
mScissor = new Rect(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
// We only do transition in portrait currently, b/137962047.
int orientation = context.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
mScissor = new Rect(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
} else {
mScissor = new Rect(0, 0, displayInfo.logicalHeight, displayInfo.logicalWidth);
}
mProxy = proxy; mProxy = proxy;
mProgram = new ImageGLProgram(context); mProgram = new ImageGLProgram(context);
@@ -179,20 +187,24 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer,
} }
@Override @Override
public void onRevealStart() { public void onRevealStart(boolean animate) {
mScissorMode = true; if (animate) {
// Use current display area of texture. mScissorMode = true;
mWallpaper.adjustTextureCoordinates(mSurfaceSize, mScissor, mXOffset, mYOffset); // Use current display area of texture.
mWallpaper.adjustTextureCoordinates(mSurfaceSize, mScissor, mXOffset, mYOffset);
}
mProxy.preRender(); mProxy.preRender();
} }
@Override @Override
public void onRevealEnd() { public void onRevealEnd() {
mScissorMode = false; if (mScissorMode) {
// reset texture coordinates to use full texture. mScissorMode = false;
mWallpaper.adjustTextureCoordinates(null, null, 0, 0); // reset texture coordinates to use full texture.
// We need draw full texture back before finishing render. mWallpaper.adjustTextureCoordinates(null, null, 0, 0);
mProxy.requestRender(); // We need draw full texture back before finishing render.
mProxy.requestRender();
}
mProxy.postRender(); mProxy.postRender();
} }

View File

@@ -490,9 +490,12 @@ public class StatusBar extends SystemUI implements DemoMode,
WallpaperInfo info = wallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT); WallpaperInfo info = wallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT);
final boolean deviceSupportsAodWallpaper = mContext.getResources().getBoolean( final boolean deviceSupportsAodWallpaper = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_dozeSupportsAodWallpaper); com.android.internal.R.bool.config_dozeSupportsAodWallpaper);
final boolean imageWallpaperInAmbient =
!DozeParameters.getInstance(mContext).getDisplayNeedsBlanking();
// If WallpaperInfo is null, it must be ImageWallpaper. // If WallpaperInfo is null, it must be ImageWallpaper.
final boolean supportsAmbientMode = deviceSupportsAodWallpaper final boolean supportsAmbientMode = deviceSupportsAodWallpaper
&& (info == null || info.supportsAmbientMode()); && ((info == null && imageWallpaperInAmbient)
|| (info != null && info.supportsAmbientMode()));
mStatusBarWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode); mStatusBarWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode);
mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode); mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode);