Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6174c6a authored by Vadim Tryshev's avatar Vadim Tryshev Committed by android-build-merger
Browse files

Merge "Add Wallpaper.getBitmapAsUser()" into nyc-dev am: a6a12774

am: 935755cc

* commit '935755cc':
  Add Wallpaper.getBitmapAsUser()
parents 857e40a6 935755cc
Loading
Loading
Loading
Loading
+17 −4
Original line number Original line Diff line number Diff line
@@ -282,6 +282,10 @@ public class WallpaperManager {
        }
        }


        public Bitmap peekWallpaperBitmap(Context context, boolean returnDefault) {
        public Bitmap peekWallpaperBitmap(Context context, boolean returnDefault) {
            return peekWallpaperBitmap(context, returnDefault, context.getUserId());
        }

        public Bitmap peekWallpaperBitmap(Context context, boolean returnDefault, int userId) {
            synchronized (this) {
            synchronized (this) {
                if (mService != null) {
                if (mService != null) {
                    try {
                    try {
@@ -300,7 +304,7 @@ public class WallpaperManager {
                }
                }
                mWallpaper = null;
                mWallpaper = null;
                try {
                try {
                    mWallpaper = getCurrentWallpaperLocked(context);
                    mWallpaper = getCurrentWallpaperLocked(userId);
                } catch (OutOfMemoryError e) {
                } catch (OutOfMemoryError e) {
                    Log.w(TAG, "No memory load current wallpaper", e);
                    Log.w(TAG, "No memory load current wallpaper", e);
                }
                }
@@ -323,7 +327,7 @@ public class WallpaperManager {
            }
            }
        }
        }


        private Bitmap getCurrentWallpaperLocked(Context context) {
        private Bitmap getCurrentWallpaperLocked(int userId) {
            if (mService == null) {
            if (mService == null) {
                Log.w(TAG, "WallpaperService not running");
                Log.w(TAG, "WallpaperService not running");
                return null;
                return null;
@@ -332,7 +336,7 @@ public class WallpaperManager {
            try {
            try {
                Bundle params = new Bundle();
                Bundle params = new Bundle();
                ParcelFileDescriptor fd = mService.getWallpaper(this, FLAG_SET_SYSTEM,
                ParcelFileDescriptor fd = mService.getWallpaper(this, FLAG_SET_SYSTEM,
                        params, context.getUserId());
                        params, userId);
                if (fd != null) {
                if (fd != null) {
                    try {
                    try {
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        BitmapFactory.Options options = new BitmapFactory.Options();
@@ -644,7 +648,16 @@ public class WallpaperManager {
     * @hide
     * @hide
     */
     */
    public Bitmap getBitmap() {
    public Bitmap getBitmap() {
        return sGlobals.peekWallpaperBitmap(mContext, true);
        return getBitmapAsUser(mContext.getUserId());
    }

    /**
     * Like {@link #getDrawable()} but returns a Bitmap for the provided user.
     *
     * @hide
     */
    public Bitmap getBitmapAsUser(int userId) {
        return sGlobals.peekWallpaperBitmap(mContext, true, userId);
    }
    }


    /**
    /**
+1 −0
Original line number Original line Diff line number Diff line
@@ -1072,6 +1072,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
        }
        }
    }
    }


    @Override
    public ParcelFileDescriptor getWallpaper(IWallpaperManagerCallback cb, final int which,
    public ParcelFileDescriptor getWallpaper(IWallpaperManagerCallback cb, final int which,
            Bundle outParams, int wallpaperUserId) {
            Bundle outParams, int wallpaperUserId) {
        if (wallpaperUserId != UserHandle.getCallingUserId()) {
        if (wallpaperUserId != UserHandle.getCallingUserId()) {