Expose Ambient Wallpaper API
In P we introduced a private concept of AOD wallpapers, in Q we're making it a public surface. Bug: 111395593 Test: make Change-Id: I4c406386f0ee15dc8734a24b040482b6cb807126
This commit is contained in:
@@ -1295,6 +1295,7 @@ package android {
|
||||
field public static final int summaryColumn = 16843426; // 0x10102a2
|
||||
field public static final int summaryOff = 16843248; // 0x10101f0
|
||||
field public static final int summaryOn = 16843247; // 0x10101ef
|
||||
field public static final int supportsAmbientMode = 16844172; // 0x101058c
|
||||
field public static final int supportsAssist = 16844016; // 0x10104f0
|
||||
field public static final int supportsLaunchVoiceAssistFromKeyguard = 16844017; // 0x10104f1
|
||||
field public static final int supportsLocalInteraction = 16844047; // 0x101050f
|
||||
@@ -6281,6 +6282,7 @@ package android.app {
|
||||
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
|
||||
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);
|
||||
method public android.graphics.drawable.Drawable loadThumbnail(android.content.pm.PackageManager);
|
||||
method public boolean supportsAmbientMode();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.app.WallpaperInfo> CREATOR;
|
||||
}
|
||||
@@ -39851,9 +39853,11 @@ package android.service.wallpaper {
|
||||
method public int getDesiredMinimumHeight();
|
||||
method public int getDesiredMinimumWidth();
|
||||
method public android.view.SurfaceHolder getSurfaceHolder();
|
||||
method public boolean isInAmbientMode();
|
||||
method public boolean isPreview();
|
||||
method public boolean isVisible();
|
||||
method public void notifyColorsChanged();
|
||||
method public void onAmbientModeChanged(boolean, boolean);
|
||||
method public void onApplyWindowInsets(android.view.WindowInsets);
|
||||
method public android.os.Bundle onCommand(java.lang.String, int, int, int, android.os.Bundle, boolean);
|
||||
method public android.app.WallpaperColors onComputeColors();
|
||||
|
||||
@@ -315,12 +315,13 @@ public final class WallpaperInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a wallpaper was optimized or not for ambient mode.
|
||||
* Returns whether a wallpaper was optimized or not for ambient mode and can be drawn in there.
|
||||
*
|
||||
* @return {@code true} if wallpaper can draw in ambient mode.
|
||||
* @hide
|
||||
* @see WallpaperService.Engine#onAmbientModeChanged(boolean, boolean)
|
||||
* @see WallpaperService.Engine#isInAmbientMode()
|
||||
* @return {@code true} if wallpaper can draw when in ambient mode.
|
||||
*/
|
||||
public boolean getSupportsAmbientMode() {
|
||||
public boolean supportsAmbientMode() {
|
||||
return mSupportsAmbientMode;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.app.Service;
|
||||
import android.app.WallpaperColors;
|
||||
import android.app.WallpaperInfo;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -436,8 +437,7 @@ public abstract class WallpaperService extends Service {
|
||||
|
||||
/**
|
||||
* Returns true if this engine is running in ambient mode -- that is,
|
||||
* it is being shown in low power mode, in always on display.
|
||||
* @hide
|
||||
* it is being shown in low power mode, on always on display.
|
||||
*/
|
||||
public boolean isInAmbientMode() {
|
||||
return mIsInAmbientMode;
|
||||
@@ -563,10 +563,12 @@ public abstract class WallpaperService extends Service {
|
||||
* 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
|
||||
* @param animated {@code true} if you'll have the opportunity of animating your transition
|
||||
* {@code false} when the wallpaper should present its ambient version
|
||||
* immediately.
|
||||
*
|
||||
* @see #isInAmbientMode()
|
||||
* @see WallpaperInfo#supportsAmbientMode()
|
||||
*/
|
||||
public void onAmbientModeChanged(boolean inAmbientMode, boolean animated) {
|
||||
}
|
||||
|
||||
@@ -7866,8 +7866,7 @@
|
||||
wallpaper. -->
|
||||
<attr name="showMetadataInPreview" format="boolean" />
|
||||
|
||||
<!-- Wallpapers optimized and capable of drawing in ambient mode will return true.
|
||||
@hide -->
|
||||
<!-- Wallpapers optimized and capable of drawing in ambient mode will return true. -->
|
||||
<attr name="supportsAmbientMode" format="boolean" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
@@ -2908,6 +2908,7 @@
|
||||
<public name="opticalInsetRight" />
|
||||
<public name="opticalInsetBottom" />
|
||||
<public name="allowForceDark" />
|
||||
<public name="supportsAmbientMode" />
|
||||
</public-group>
|
||||
|
||||
<public-group type="style" first-id="0x010302e2">
|
||||
|
||||
@@ -516,7 +516,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
WallpaperInfo info = wallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT);
|
||||
final boolean supportsAmbientMode = info != null &&
|
||||
info.getSupportsAmbientMode();
|
||||
info.supportsAmbientMode();
|
||||
|
||||
mStatusBarWindowManager.setWallpaperSupportsAmbientMode(supportsAmbientMode);
|
||||
mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode);
|
||||
|
||||
@@ -965,7 +965,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
}
|
||||
mPaddingChanged = false;
|
||||
}
|
||||
if (mInfo != null && mInfo.getSupportsAmbientMode()) {
|
||||
if (mInfo != null && mInfo.supportsAmbientMode()) {
|
||||
try {
|
||||
mEngine.setInAmbientMode(mInAmbientMode, false /* animated */);
|
||||
} catch (RemoteException e) {
|
||||
@@ -1777,7 +1777,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
mInAmbientMode = inAmbienMode;
|
||||
final WallpaperData data = mWallpaperMap.get(mCurrentUserId);
|
||||
if (data != null && data.connection != null && data.connection.mInfo != null
|
||||
&& data.connection.mInfo.getSupportsAmbientMode()) {
|
||||
&& data.connection.mInfo.supportsAmbientMode()) {
|
||||
engine = data.connection.mEngine;
|
||||
} else {
|
||||
engine = null;
|
||||
|
||||
@@ -16,5 +16,4 @@
|
||||
-->
|
||||
<wallpaper
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
androidprv:supportsAmbientMode="true"/>
|
||||
android:supportsAmbientMode="true"/>
|
||||
@@ -55,13 +55,13 @@ public class WallpaperInfoTest {
|
||||
|
||||
// Defined as true in the XML
|
||||
assertTrue("supportsAmbientMode should be true, as defined in the XML.",
|
||||
wallpaperInfo.getSupportsAmbientMode());
|
||||
wallpaperInfo.supportsAmbientMode());
|
||||
Parcel parcel = Parcel.obtain();
|
||||
wallpaperInfo.writeToParcel(parcel, 0 /* flags */);
|
||||
parcel.setDataPosition(0);
|
||||
WallpaperInfo fromParcel = WallpaperInfo.CREATOR.createFromParcel(parcel);
|
||||
assertTrue("supportsAmbientMode should have been restored from parcelable",
|
||||
fromParcel.getSupportsAmbientMode());
|
||||
fromParcel.supportsAmbientMode());
|
||||
parcel.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user