OSDN Git Service

Merge "Document that WallpaperManager.getDrawable() can return null" into nyc-mr1-dev
authorChris Tate <ctate@android.com>
Mon, 18 Jul 2016 17:29:37 +0000 (17:29 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Mon, 18 Jul 2016 17:29:39 +0000 (17:29 +0000)
1  2 
core/java/android/app/WallpaperManager.java

@@@ -417,8 -417,14 +417,14 @@@ public class WallpaperManager 
       * 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 there is no system wallpaper available, if
+      * wallpapers are not supported in the current user, or if the calling app is not
+      * permitted to access the system wallpaper.
       *
-      * @return Returns a Drawable object that will draw the wallpaper.
+      * @return Returns a Drawable object that will draw the system wallpaper,
+      *     or {@code null} if no system wallpaper exists or if the calling application
+      *     is not able to access the wallpaper.
       */
      public Drawable getDrawable() {
          Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, FLAG_SYSTEM);
       */
      @SystemApi
      public boolean setWallpaperComponent(ComponentName name) {
 +        return setWallpaperComponent(name, UserHandle.myUserId());
 +    }
 +
 +    /**
 +     * Set the live wallpaper.
 +     *
 +     * This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT
 +     * permission. The caller must hold the INTERACT_ACROSS_USERS_FULL permission to change
 +     * another user's wallpaper.
 +     *
 +     * @hide
 +     */
 +    public boolean setWallpaperComponent(ComponentName name, int userId) {
          if (sGlobals.mService == null) {
              Log.w(TAG, "WallpaperService not running");
              throw new RuntimeException(new DeadSystemException());
          }
          try {
 -            sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName());
 +            sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName(),
 +                    userId);
              return true;
          } catch (RemoteException e) {
              throw e.rethrowFromSystemServer();