summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Poultney <poultney@google.com> 2022-11-30 03:23:51 +0000
committer Chris Poultney <poultney@google.com> 2022-12-02 03:01:48 +0000
commit61152bc81229a1af5a3919d2f3de87752d5d24f7 (patch)
treede3332586eb677fc909242c843d7a6b8ab1dc639
parente354477990414020e90a8b403f655e6a7b3395b9 (diff)
Add home/lock screen argument to remaining methods that require one
After merge into master, @hide annotations will be removed and CTS tests added. Bug: 253481667 Test: will be added in master Change-Id: Ia8bb930c72113c510ed7c4eb70738083c0662151
-rw-r--r--core/api/current.txt8
-rw-r--r--core/java/android/app/WallpaperManager.java82
2 files changed, 86 insertions, 4 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index c8a43db2f9c2..487e57d114c9 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -7216,8 +7216,8 @@ package android.app {
method public android.content.Intent getCropAndSetWallpaperIntent(android.net.Uri);
method public int getDesiredMinimumHeight();
method public int getDesiredMinimumWidth();
- method @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.graphics.drawable.Drawable getDrawable();
- method @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.graphics.drawable.Drawable getFastDrawable();
+ method @Nullable @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.graphics.drawable.Drawable getDrawable();
+ method @Nullable @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.graphics.drawable.Drawable getFastDrawable();
method public static android.app.WallpaperManager getInstance(android.content.Context);
method @Nullable public android.app.WallpaperColors getWallpaperColors(int);
method @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.os.ParcelFileDescriptor getWallpaperFile(int);
@@ -7226,8 +7226,8 @@ package android.app {
method public boolean hasResourceWallpaper(@RawRes int);
method public boolean isSetWallpaperAllowed();
method public boolean isWallpaperSupported();
- method public android.graphics.drawable.Drawable peekDrawable();
- method @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.graphics.drawable.Drawable peekFastDrawable();
+ method @Nullable public android.graphics.drawable.Drawable peekDrawable();
+ method @Nullable @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) public android.graphics.drawable.Drawable peekFastDrawable();
method public void removeOnColorsChangedListener(@NonNull android.app.WallpaperManager.OnColorsChangedListener);
method public void sendWallpaperCommand(android.os.IBinder, String, int, int, int, android.os.Bundle);
method @RequiresPermission(android.Manifest.permission.SET_WALLPAPER) public void setBitmap(android.graphics.Bitmap) throws java.io.IOException;
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index 3e6283e25aa5..162a9976f4f3 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -786,6 +786,7 @@ public class WallpaperManager {
* is not able to access the wallpaper.
*/
@RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ @Nullable
public Drawable getDrawable() {
final ColorManagementProxy cmProxy = getColorManagementProxy();
Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, FLAG_SYSTEM, cmProxy);
@@ -798,6 +799,29 @@ public class WallpaperManager {
}
/**
+ * Retrieve the requested wallpaper; if
+ * no wallpaper is set, the requested built-in static wallpaper is returned.
+ * This is returned as an
+ * abstract Drawable that you can install in a View to display whatever
+ * wallpaper the user has currently set.
+ * <p>
+ * This method can return null if the requested wallpaper is not available, if
+ * wallpapers are not supported in the current user, or if the calling app is not
+ * permitted to access the requested wallpaper.
+ *
+ * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
+ * IllegalArgumentException if an invalid wallpaper is requested.
+ * @return Returns a Drawable object that will draw the requested wallpaper,
+ * or {@code null} if the requested wallpaper does not exist or if the calling application
+ * is not able to access the wallpaper.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ @Nullable
+ public Drawable getDrawable(@SetWallpaperFlags int which) {
+ return getDrawable();
+ }
+ /**
* Obtain a drawable for the built-in static system wallpaper.
*/
public Drawable getBuiltInDrawable() {
@@ -1018,6 +1042,7 @@ public class WallpaperManager {
* @return Returns a Drawable object that will draw the wallpaper or a
* null pointer if these is none.
*/
+ @Nullable
public Drawable peekDrawable() {
final ColorManagementProxy cmProxy = getColorManagementProxy();
Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, false, FLAG_SYSTEM, cmProxy);
@@ -1030,6 +1055,23 @@ public class WallpaperManager {
}
/**
+ * Retrieve the requested wallpaper; if there is no wallpaper set,
+ * a null pointer is returned. This is returned as an
+ * abstract Drawable that you can install in a View to display whatever
+ * wallpaper the user has currently set.
+ *
+ * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
+ * IllegalArgumentException if an invalid wallpaper is requested.
+ * @return Returns a Drawable object that will draw the wallpaper or a null pointer if these
+ * is none.
+ * @hide
+ */
+ @Nullable
+ public Drawable peekDrawable(@SetWallpaperFlags int which) {
+ return peekDrawable();
+ }
+
+ /**
* Like {@link #getDrawable()}, but the returned Drawable has a number
* of limitations to reduce its overhead as much as possible. It will
* never scale the wallpaper (only centering it if the requested bounds
@@ -1043,6 +1085,7 @@ public class WallpaperManager {
* @return Returns a Drawable object that will draw the wallpaper.
*/
@RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ @Nullable
public Drawable getFastDrawable() {
final ColorManagementProxy cmProxy = getColorManagementProxy();
Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, FLAG_SYSTEM, cmProxy);
@@ -1053,6 +1096,28 @@ public class WallpaperManager {
}
/**
+ * Like {@link #getFastDrawable(int)}, but the returned Drawable has a number
+ * of limitations to reduce its overhead as much as possible. It will
+ * never scale the wallpaper (only centering it if the requested bounds
+ * do match the bitmap bounds, which should not be typical), doesn't
+ * allow setting an alpha, color filter, or other attributes, etc. The
+ * bounds of the returned drawable will be initialized to the same bounds
+ * as the wallpaper, so normally you will not need to touch it. The
+ * drawable also assumes that it will be used in a context running in
+ * the same density as the screen (not in density compatibility mode).
+ *
+ * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
+ * IllegalArgumentException if an invalid wallpaper is requested.
+ * @return Returns a Drawable object that will draw the wallpaper.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ @Nullable
+ public Drawable getFastDrawable(@SetWallpaperFlags int which) {
+ return getFastDrawable();
+ }
+
+ /**
* Like {@link #getFastDrawable()}, but if there is no wallpaper set,
* a null pointer is returned.
*
@@ -1060,6 +1125,7 @@ public class WallpaperManager {
* wallpaper or a null pointer if these is none.
*/
@RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ @Nullable
public Drawable peekFastDrawable() {
final ColorManagementProxy cmProxy = getColorManagementProxy();
Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, false, FLAG_SYSTEM, cmProxy);
@@ -1070,6 +1136,22 @@ public class WallpaperManager {
}
/**
+ * Like {@link #getFastDrawable()}, but if there is no wallpaper set,
+ * a null pointer is returned.
+ *
+ * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
+ * IllegalArgumentException if an invalid wallpaper is requested.
+ * @return Returns an optimized Drawable object that will draw the
+ * wallpaper or a null pointer if these is none.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ @Nullable
+ public Drawable peekFastDrawable(@SetWallpaperFlags int which) {
+ return peekFastDrawable();
+ }
+
+ /**
* Whether the wallpaper supports Wide Color Gamut or not.
* @param which The wallpaper whose image file is to be retrieved. Must be a single
* defined kind of wallpaper, either {@link #FLAG_SYSTEM} or {@link #FLAG_LOCK}.