Let wallpaper know when to animate AoD transition
Sometimes the screen will blank, and sometime the
wallpaper has the opportunity to animate the
transition.
Bug: 64155983
Test: atest tests/Internal/src/android/service/wallpaper/WallpaperServiceTest.java
Test: atest packages/SystemUI/tests/src/com/android/systemui/doze/DozeWallpaperStateTest.java
Change-Id: Ia92c00edb98eeeba42da33bdc7bec3feb961a658
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl
index 80782e3..4ba0ff2 100644
--- a/core/java/android/app/IWallpaperManager.aidl
+++ b/core/java/android/app/IWallpaperManager.aidl
@@ -159,5 +159,5 @@
/**
* Called from SystemUI when it shows the AoD UI.
*/
- void setInAmbientMode(boolean inAmbienMode);
+ void setInAmbientMode(boolean inAmbientMode, boolean animated);
}
diff --git a/core/java/android/service/wallpaper/IWallpaperEngine.aidl b/core/java/android/service/wallpaper/IWallpaperEngine.aidl
index b8f2191..dccce40 100644
--- a/core/java/android/service/wallpaper/IWallpaperEngine.aidl
+++ b/core/java/android/service/wallpaper/IWallpaperEngine.aidl
@@ -27,7 +27,7 @@
void setDesiredSize(int width, int height);
void setDisplayPadding(in Rect padding);
void setVisibility(boolean visible);
- void setInAmbientMode(boolean inAmbientDisplay);
+ void setInAmbientMode(boolean inAmbientDisplay, boolean animated);
void dispatchPointer(in MotionEvent event);
void dispatchWallpaperCommand(String action, int x, int y,
int z, in Bundle extras);
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 595bfb7..8588df7 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -563,9 +563,12 @@
* Called when the device enters or exits ambient mode.
*
* @param inAmbientMode {@code true} if in ambient mode.
+ * @param animated {@code true} if you'll have te opportunity of animating your transition
+ * {@code false} when the screen will blank and the wallpaper should be
+ * set to ambient mode immediately.
* @hide
*/
- public void onAmbientModeChanged(boolean inAmbientMode) {
+ public void onAmbientModeChanged(boolean inAmbientMode, boolean animated) {
}
/**
@@ -1021,18 +1024,20 @@
* Executes life cycle event and updates internal ambient mode state based on
* message sent from handler.
*
- * @param inAmbientMode True if in ambient mode.
+ * @param inAmbientMode {@code true} if in ambient mode.
+ * @param animated {@code true} if the transition will be animated.
* @hide
*/
@VisibleForTesting
- public void doAmbientModeChanged(boolean inAmbientMode) {
+ public void doAmbientModeChanged(boolean inAmbientMode, boolean animated) {
if (!mDestroyed) {
if (DEBUG) {
- Log.v(TAG, "onAmbientModeChanged(" + inAmbientMode + "): " + this);
+ Log.v(TAG, "onAmbientModeChanged(" + inAmbientMode + ", "
+ + animated + "): " + this);
}
mIsInAmbientMode = inAmbientMode;
if (mCreated) {
- onAmbientModeChanged(inAmbientMode);
+ onAmbientModeChanged(inAmbientMode, animated);
}
}
}
@@ -1278,8 +1283,10 @@
}
@Override
- public void setInAmbientMode(boolean inAmbientDisplay) throws RemoteException {
- Message msg = mCaller.obtainMessageI(DO_IN_AMBIENT_MODE, inAmbientDisplay ? 1 : 0);
+ public void setInAmbientMode(boolean inAmbientDisplay, boolean animated)
+ throws RemoteException {
+ Message msg = mCaller.obtainMessageII(DO_IN_AMBIENT_MODE, inAmbientDisplay ? 1 : 0,
+ animated ? 1 : 0);
mCaller.sendMessage(msg);
}
@@ -1350,7 +1357,7 @@
return;
}
case DO_IN_AMBIENT_MODE: {
- mEngine.doAmbientModeChanged(message.arg1 != 0);
+ mEngine.doAmbientModeChanged(message.arg1 != 0, message.arg2 != 0);
return;
}
case MSG_UPDATE_SURFACE: