OSDN Git Service

Fix WallpaperManager APIs
authorEdward Savage-Jones <edward.savage-jones@sonymobile.com>
Tue, 30 Aug 2016 16:44:19 +0000 (18:44 +0200)
committerChristopher Tate <ctate@google.com>
Wed, 21 Sep 2016 22:13:39 +0000 (15:13 -0700)
When support for lockscreen wallpapers was added in API level 24 the
behaviour for earlier API versions changed. Calls to the old 'set' APIs
no longer affect the overall device wallpaper, and can result in an end
user not being able to change their lockscreen wallpaper.

This upload restores the original API behaviour.

Bug: 31204228
Bug: 30456015
Change-Id: Ia16d2e2e379c54d798eef8f5c653099c2c581d78

core/java/android/app/WallpaperManager.java

index 219afea..a7ad619 100644 (file)
@@ -910,7 +910,7 @@ public class WallpaperManager {
      * wallpaper.
      */
     public void setResource(@RawRes int resid) throws IOException {
-        setResource(resid, FLAG_SYSTEM);
+        setResource(resid, FLAG_SYSTEM | FLAG_LOCK);
     }
 
     /**
@@ -1016,7 +1016,7 @@ public class WallpaperManager {
      */
     public int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup)
             throws IOException {
-        return setBitmap(fullImage, visibleCropHint, allowBackup, FLAG_SYSTEM);
+        return setBitmap(fullImage, visibleCropHint, allowBackup, FLAG_SYSTEM | FLAG_LOCK);
     }
 
     /**
@@ -1154,7 +1154,7 @@ public class WallpaperManager {
      */
     public int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup)
             throws IOException {
-        return setStream(bitmapData, visibleCropHint, allowBackup, FLAG_SYSTEM);
+        return setStream(bitmapData, visibleCropHint, allowBackup, FLAG_SYSTEM | FLAG_LOCK);
     }
 
     /**
@@ -1393,7 +1393,7 @@ public class WallpaperManager {
      */
     @SystemApi
     public void clearWallpaper() {
-        clearWallpaper(FLAG_SYSTEM, mContext.getUserId());
+        clearWallpaper(FLAG_SYSTEM | FLAG_LOCK, mContext.getUserId());
     }
 
     /**