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

Commit 6f17fc20 authored by Aurélien Pomini's avatar Aurélien Pomini Committed by Automerger Merge Worker
Browse files

Merge "WallpaperManager getDrawable & al clarifications" into udc-dev am: 5b1d2b53

parents f5b06ea4 5b1d2b53
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -258,6 +258,14 @@ interface IWallpaperManager {
     */
     */
    boolean lockScreenWallpaperExists();
    boolean lockScreenWallpaperExists();


    /**
     * Return true if there is a static wallpaper on the specified screen. With which=FLAG_LOCK,
     * always return false if the lock screen doesn't run its own wallpaper engine.
     *
     * @hide
     */
    boolean isStaticWallpaper(int which);

    /**
    /**
     * Temporary method for project b/197814683.
     * Temporary method for project b/197814683.
     * Return true if the lockscreen wallpaper always uses a WallpaperService, not a static image.
     * Return true if the lockscreen wallpaper always uses a WallpaperService, not a static image.
+152 −105
Original line number Original line Diff line number Diff line
@@ -658,15 +658,8 @@ public class WallpaperManager {
                    return currentWallpaper;
                    return currentWallpaper;
                }
                }
            }
            }
            if (returnDefault) {
            if (returnDefault || (which == FLAG_LOCK && isStaticWallpaper(FLAG_LOCK))) {
                Bitmap defaultWallpaper = mDefaultWallpaper;
                return getDefaultWallpaper(context, which);
                if (defaultWallpaper == null || defaultWallpaper.isRecycled()) {
                    defaultWallpaper = getDefaultWallpaper(context, which);
                    synchronized (this) {
                        mDefaultWallpaper = defaultWallpaper;
                    }
                }
                return defaultWallpaper;
            }
            }
            return null;
            return null;
        }
        }
@@ -705,7 +698,7 @@ public class WallpaperManager {
            }
            }
            // If user wallpaper is unavailable, may be the default one instead.
            // If user wallpaper is unavailable, may be the default one instead.
            if ((dimensions == null || dimensions.width() == 0 || dimensions.height() == 0)
            if ((dimensions == null || dimensions.width() == 0 || dimensions.height() == 0)
                    && returnDefault) {
                    && (returnDefault || (which == FLAG_LOCK && isStaticWallpaper(FLAG_LOCK)))) {
                InputStream is = openDefaultWallpaper(context, which);
                InputStream is = openDefaultWallpaper(context, which);
                if (is != null) {
                if (is != null) {
                    try {
                    try {
@@ -769,18 +762,39 @@ public class WallpaperManager {
        }
        }


        private Bitmap getDefaultWallpaper(Context context, @SetWallpaperFlags int which) {
        private Bitmap getDefaultWallpaper(Context context, @SetWallpaperFlags int which) {
            InputStream is = openDefaultWallpaper(context, which);
            Bitmap defaultWallpaper = mDefaultWallpaper;
            if (defaultWallpaper == null || defaultWallpaper.isRecycled()) {
                defaultWallpaper = null;
                try (InputStream is = openDefaultWallpaper(context, which)) {
                    if (is != null) {
                    if (is != null) {
                try {
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        BitmapFactory.Options options = new BitmapFactory.Options();
                    return BitmapFactory.decodeStream(is, null, options);
                        defaultWallpaper = BitmapFactory.decodeStream(is, null, options);
                } catch (OutOfMemoryError e) {
                    }
                } catch (OutOfMemoryError | IOException e) {
                    Log.w(TAG, "Can't decode stream", e);
                    Log.w(TAG, "Can't decode stream", e);
                } finally {
                    IoUtils.closeQuietly(is);
                }
                }
            }
            }
            return null;
            synchronized (this) {
                mDefaultWallpaper = defaultWallpaper;
            }
            return defaultWallpaper;
        }

        /**
         * Return true if there is a static wallpaper on the specified screen.
         * With {@code which=}{@link #FLAG_LOCK}, always return false if the lockscreen doesn't run
         * its own wallpaper engine.
         */
        private boolean isStaticWallpaper(@SetWallpaperFlags int which) {
            if (mService == null) {
                Log.w(TAG, "WallpaperService not running");
                throw new RuntimeException(new DeadSystemException());
            }
            try {
                return mService.isStaticWallpaper(which);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        }
    }
    }


@@ -882,21 +896,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * Retrieve the current system wallpaper; if
     * no wallpaper is set, the system 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>
     * <p>
     * This method can return null if there is no system wallpaper available, if
     * Equivalent to {@link #getDrawable(int)} with {@code which=}{@link #FLAG_SYSTEM}.
     * wallpapers are not supported in the current user, or if the calling app is not
     * </p>
     * permitted to access the system wallpaper.
     *
     *
     * @return Returns a Drawable object that will draw the system wallpaper,
     * @return A Drawable object for the requested wallpaper.
     *     or {@code null} if no system wallpaper exists or if the calling application
     *
     *     is not able to access the wallpaper.
     * @see #getDrawable(int)
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
@@ -919,23 +926,29 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * 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>
     * <p>
     * This method can return null if the requested wallpaper is not available, if
     * Retrieve the requested wallpaper for the specified wallpaper type if the wallpaper is not
     * wallpapers are not supported in the current user, or if the calling app is not
     * a live wallpaper. This method should not be used to display the user wallpaper on an app:
     * permitted to access the requested wallpaper.
     * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER} should be used instead.
     * </p>
     * <p>
     * When called with {@code which=}{@link #FLAG_SYSTEM},
     * if there is a live wallpaper on home screen, the built-in default wallpaper is returned.
     * </p>
     * <p>
     * When called with {@code which=}{@link #FLAG_LOCK}, if there is a live wallpaper
     * on lock screen, or if the lock screen and home screen share the same wallpaper engine,
     * {@code null} is returned.
     * </p>
     * <p>
     * {@link #getWallpaperInfo(int)} can be used to determine whether there is a live wallpaper
     * on a specified screen type.
     * </p>
     *
     *
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
     *     IllegalArgumentException if an invalid wallpaper is requested.
     *     IllegalArgumentException if an invalid wallpaper is requested.
     * @return Returns a Drawable object that will draw the requested wallpaper,
     * @return A Drawable object for 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.
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
@@ -943,7 +956,8 @@ public class WallpaperManager {
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable getDrawable(@SetWallpaperFlags int which) {
    public Drawable getDrawable(@SetWallpaperFlags int which) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, which, cmProxy);
        boolean returnDefault = which != FLAG_LOCK;
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, returnDefault, which, cmProxy);
        if (bm != null) {
        if (bm != null) {
            Drawable dr = new BitmapDrawable(mContext.getResources(), bm);
            Drawable dr = new BitmapDrawable(mContext.getResources(), bm);
            dr.setDither(false);
            dr.setDither(false);
@@ -1175,15 +1189,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * Retrieve the current system wallpaper; if there is no wallpaper set,
     * <p>
     * a null pointer is returned. This is returned as an
     * Equivalent to {@link #getDrawable()}.
     * abstract Drawable that you can install in a View to display whatever
     * </p>
     * wallpaper the user has currently set.
     *
     * @return A Drawable object for the requested wallpaper.
     *
     *
     * @return Returns a Drawable object that will draw the wallpaper or a
     * @see #getDrawable()
     * null pointer if wallpaper is unset.
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
@@ -1206,31 +1219,23 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * Retrieve the requested wallpaper; if there is no wallpaper set,
     * <p>
     * a null pointer is returned. This is returned as an
     * Equivalent to {@link #getDrawable(int)}.
     * abstract Drawable that you can install in a View to display whatever
     * </p>
     * wallpaper the user has currently set.
     *
     *
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type. Throws
     *     IllegalArgumentException if an invalid wallpaper is requested.
     *     IllegalArgumentException if an invalid wallpaper is requested.
     * @return Returns a Drawable object that will draw the wallpaper or a null pointer if
     * @return A Drawable object for the requested wallpaper.
     * wallpaper is unset.
     *
     * @see #getDrawable(int)
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
    @Nullable
    @Nullable
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable peekDrawable(@SetWallpaperFlags int which) {
    public Drawable peekDrawable(@SetWallpaperFlags int which) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        return getDrawable(which);
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, which, cmProxy);
        if (bm != null) {
            Drawable dr = new BitmapDrawable(mContext.getResources(), bm);
            dr.setDither(false);
            return dr;
        }
        return null;
    }
    }


    /**
    /**
@@ -1246,19 +1251,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * Like {@link #getDrawable()}, but the returned Drawable has a number
     * <p>
     * of limitations to reduce its overhead as much as possible. It will
     * Equivalent to {@link #getFastDrawable(int)} with {@code which=}{@link #FLAG_SYSTEM}.
     * never scale the wallpaper (only centering it if the requested bounds
     * </p>
     * do match the bitmap bounds, which should not be typical), doesn't
     *
     * allow setting an alpha, color filter, or other attributes, etc.  The
     * @return A Drawable object for the requested wallpaper.
     * 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).
     *
     *
     * @return Returns a Drawable object that will draw the wallpaper.
     * @see #getFastDrawable(int)
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
@@ -1295,7 +1295,8 @@ public class WallpaperManager {
     *
     *
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type.  Throws
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type.  Throws
     *     IllegalArgumentException if an invalid wallpaper is requested.
     *     IllegalArgumentException if an invalid wallpaper is requested.
     * @return Returns a Drawable object that will draw the wallpaper.
     * @return An optimized Drawable object for the requested wallpaper, or {@code null}
     *     in some cases as specified in {@link #getDrawable(int)}.
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
@@ -1303,7 +1304,8 @@ public class WallpaperManager {
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable getFastDrawable(@SetWallpaperFlags int which) {
    public Drawable getFastDrawable(@SetWallpaperFlags int which) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, which, cmProxy);
        boolean returnDefault = which != FLAG_LOCK;
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, returnDefault, which, cmProxy);
        if (bm != null) {
        if (bm != null) {
            return new FastBitmapDrawable(bm);
            return new FastBitmapDrawable(bm);
        }
        }
@@ -1323,13 +1325,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * Like {@link #getFastDrawable()}, but if there is no wallpaper set,
     * <p>
     * a null pointer is returned.
     * Equivalent to {@link #getFastDrawable()}.
     * </p>
     *
     * @return An optimized Drawable object for the requested wallpaper.
     *
     *
     * @return Returns an optimized Drawable object that will draw the
     * @see #getFastDrawable()
     * wallpaper or a null pointer if these is none.
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
@@ -1352,31 +1355,29 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * </ul>
     * <br>
     *
     *
     * Like {@link #getFastDrawable()}, but if there is no wallpaper set,
     * <p>
     * a null pointer is returned.
     * Equivalent to {@link #getFastDrawable(int)}.
     * </p>
     *
     *
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type.  Throws
     * @param which The {@code FLAG_*} identifier of a valid wallpaper type.  Throws
     *     IllegalArgumentException if an invalid wallpaper is requested.
     *     IllegalArgumentException if an invalid wallpaper is requested.
     * @return Returns an optimized Drawable object that will draw the
     * @return An optimized Drawable object for the requested wallpaper.
     * wallpaper or a null pointer if these is none.
     *
     *
     * @throws SecurityException as described in the note
     * @throws SecurityException as described in the note
     */
     */
    @Nullable
    @Nullable
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable peekFastDrawable(@SetWallpaperFlags int which) {
    public Drawable peekFastDrawable(@SetWallpaperFlags int which) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        return getFastDrawable(which);
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, which, cmProxy);
        if (bm != null) {
            return new FastBitmapDrawable(bm);
        }
        return null;
    }
    }


    /**
    /**
     * Whether the wallpaper supports Wide Color Gamut or not.
     * Whether the wallpaper supports Wide Color Gamut or not. This is only meant to be used by
     * ImageWallpaper, and will always return false if the wallpaper for the specified screen
     * is not an ImageWallpaper. This will also return false when called with {@link #FLAG_LOCK} if
     * the lock and home screen share the same wallpaper engine.
     *
     * @param which The wallpaper whose image file is to be retrieved. Must be a single
     * @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}.
     *     defined kind of wallpaper, either {@link #FLAG_SYSTEM} or {@link #FLAG_LOCK}.
     * @return true when supported.
     * @return true when supported.
@@ -1422,7 +1423,7 @@ public class WallpaperManager {
    }
    }


    /**
    /**
     * Like {@link #getDrawable()} but returns a Bitmap.
     * Like {@link #getDrawable(int)} but returns a Bitmap.
     *
     *
     * @param hardware Asks for a hardware backed bitmap.
     * @param hardware Asks for a hardware backed bitmap.
     * @param which Specifies home or lock screen
     * @param which Specifies home or lock screen
@@ -1445,7 +1446,7 @@ public class WallpaperManager {
    }
    }


    /**
    /**
     * Like {@link #getDrawable()} but returns a Bitmap for the provided user.
     * Like {@link #getDrawable(int)} but returns a Bitmap for the provided user.
     *
     *
     * @param which Specifies home or lock screen
     * @param which Specifies home or lock screen
     * @hide
     * @hide
@@ -1453,12 +1454,29 @@ public class WallpaperManager {
    @TestApi
    @TestApi
    @Nullable
    @Nullable
    public Bitmap getBitmapAsUser(int userId, boolean hardware, @SetWallpaperFlags int which) {
    public Bitmap getBitmapAsUser(int userId, boolean hardware, @SetWallpaperFlags int which) {
        boolean returnDefault = which != FLAG_LOCK;
        return getBitmapAsUser(userId, hardware, which, returnDefault);
    }

    /**
     * Overload of {@link #getBitmapAsUser(int, boolean, int)} with a returnDefault argument.
     *
     * @param returnDefault If true, return the default static wallpaper if no custom static
     *                      wallpaper is set on the specified screen.
     *                      If false, return {@code null} in that case.
     * @hide
     */
    @Nullable
    public Bitmap getBitmapAsUser(int userId, boolean hardware,
            @SetWallpaperFlags int which, boolean returnDefault) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        return sGlobals.peekWallpaperBitmap(mContext, true, which, userId, hardware, cmProxy);
        return sGlobals.peekWallpaperBitmap(mContext, returnDefault,
                which, userId, hardware, cmProxy);
    }
    }


    /**
    /**
     * Peek the dimensions of system wallpaper of the user without decoding it.
     * Peek the dimensions of system wallpaper of the user without decoding it.
     * Equivalent to {@link #peekBitmapDimensions(int)} with {@code which=}{@link #FLAG_SYSTEM}.
     *
     *
     * @return the dimensions of system wallpaper
     * @return the dimensions of system wallpaper
     * @hide
     * @hide
@@ -1472,16 +1490,45 @@ public class WallpaperManager {
    /**
    /**
     * Peek the dimensions of given wallpaper of the user without decoding it.
     * Peek the dimensions of given wallpaper of the user without decoding it.
     *
     *
     * @param which Wallpaper type. Must be either {@link #FLAG_SYSTEM} or
     * <p>
     *     {@link #FLAG_LOCK}.
     * When called with {@code which=}{@link #FLAG_SYSTEM}, if there is a live wallpaper on
     * @return the dimensions of system wallpaper
     * home screen, the built-in default wallpaper dimensions are returned.
     * </p>
     * <p>
     * When called with {@code which=}{@link #FLAG_LOCK}, if there is a live wallpaper
     * on lock screen, or if the lock screen and home screen share the same wallpaper engine,
     * {@code null} is returned.
     * </p>
     * <p>
     * {@link #getWallpaperInfo(int)} can be used to determine whether there is a live wallpaper
     * on a specified screen type.
     * </p>
     *
     * @param which Wallpaper type. Must be either {@link #FLAG_SYSTEM} or {@link #FLAG_LOCK}.
     * @return the dimensions of specified wallpaper
     * @hide
     * @hide
     */
     */
    @TestApi
    @TestApi
    @Nullable
    @Nullable
    public Rect peekBitmapDimensions(@SetWallpaperFlags int which) {
    public Rect peekBitmapDimensions(@SetWallpaperFlags int which) {
        boolean returnDefault = which != FLAG_LOCK;
        return peekBitmapDimensions(which, returnDefault);
    }

    /**
     * Overload of {@link #peekBitmapDimensions(int)} with a returnDefault argument.
     *
     * @param which Wallpaper type. Must be either {@link #FLAG_SYSTEM} or {@link #FLAG_LOCK}.
     * @param returnDefault If true, always return the default static wallpaper dimensions
     *                      if no custom static wallpaper is set on the specified screen.
     *                      If false, always return {@code null} in that case.
     * @return the dimensions of specified wallpaper
     * @hide
     */
    @Nullable
    public Rect peekBitmapDimensions(@SetWallpaperFlags int which, boolean returnDefault) {
        checkExactlyOneWallpaperFlagSet(which);
        checkExactlyOneWallpaperFlagSet(which);
        return sGlobals.peekWallpaperDimensions(mContext, true /* returnDefault */, which,
        return sGlobals.peekWallpaperDimensions(mContext, returnDefault, which,
                mContext.getUserId());
                mContext.getUserId());
    }
    }


+3 −3
Original line number Original line Diff line number Diff line
@@ -173,7 +173,7 @@ public class ImageWallpaper extends WallpaperService {
                    .isLockscreenLiveWallpaperEnabled();
                    .isLockscreenLiveWallpaperEnabled();
            mSurfaceHolder = surfaceHolder;
            mSurfaceHolder = surfaceHolder;
            Rect dimensions = mIsLockscreenLiveWallpaperEnabled
            Rect dimensions = mIsLockscreenLiveWallpaperEnabled
                    ? mWallpaperManager.peekBitmapDimensions(getSourceFlag())
                    ? mWallpaperManager.peekBitmapDimensions(getSourceFlag(), true)
                    : mWallpaperManager.peekBitmapDimensions();
                    : mWallpaperManager.peekBitmapDimensions();
            int width = Math.max(MIN_SURFACE_WIDTH, dimensions.width());
            int width = Math.max(MIN_SURFACE_WIDTH, dimensions.width());
            int height = Math.max(MIN_SURFACE_HEIGHT, dimensions.height());
            int height = Math.max(MIN_SURFACE_HEIGHT, dimensions.height());
@@ -325,7 +325,7 @@ public class ImageWallpaper extends WallpaperService {
            try {
            try {
                bitmap = mIsLockscreenLiveWallpaperEnabled
                bitmap = mIsLockscreenLiveWallpaperEnabled
                        ? mWallpaperManager.getBitmapAsUser(
                        ? mWallpaperManager.getBitmapAsUser(
                                mUserTracker.getUserId(), false, getSourceFlag())
                                mUserTracker.getUserId(), false, getSourceFlag(), true)
                        : mWallpaperManager.getBitmapAsUser(mUserTracker.getUserId(), false);
                        : mWallpaperManager.getBitmapAsUser(mUserTracker.getUserId(), false);
                if (bitmap != null
                if (bitmap != null
                        && bitmap.getByteCount() > RecordingCanvas.MAX_BITMAP_SIZE) {
                        && bitmap.getByteCount() > RecordingCanvas.MAX_BITMAP_SIZE) {
@@ -347,7 +347,7 @@ public class ImageWallpaper extends WallpaperService {
                try {
                try {
                    bitmap = mIsLockscreenLiveWallpaperEnabled
                    bitmap = mIsLockscreenLiveWallpaperEnabled
                            ? mWallpaperManager.getBitmapAsUser(
                            ? mWallpaperManager.getBitmapAsUser(
                                    mUserTracker.getUserId(), false, getSourceFlag())
                                    mUserTracker.getUserId(), false, getSourceFlag(), true)
                            : mWallpaperManager.getBitmapAsUser(mUserTracker.getUserId(), false);
                            : mWallpaperManager.getBitmapAsUser(mUserTracker.getUserId(), false);
                } catch (RuntimeException | OutOfMemoryError e) {
                } catch (RuntimeException | OutOfMemoryError e) {
                    Log.w(TAG, "Unable to load default wallpaper!", e);
                    Log.w(TAG, "Unable to load default wallpaper!", e);
+14 −0
Original line number Original line Diff line number Diff line
@@ -2788,6 +2788,20 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        }
        }
    }
    }


    /**
     * Returns true if there is a static wallpaper on the specified screen. With which=FLAG_LOCK,
     * always return false if the lockscreen doesn't run its own wallpaper engine.
     */
    @Override
    public boolean isStaticWallpaper(int which) {
        synchronized (mLock) {
            WallpaperData wallpaperData = (which == FLAG_LOCK ? mLockWallpaperMap : mWallpaperMap)
                    .get(mCurrentUserId);
            if (wallpaperData == null) return false;
            return mImageWallpaper.equals(wallpaperData.wallpaperComponent);
        }
    }

    /**
    /**
     * Sets wallpaper dim amount for the calling UID. This applies to all destinations (home, lock)
     * Sets wallpaper dim amount for the calling UID. This applies to all destinations (home, lock)
     * with an active wallpaper engine.
     * with an active wallpaper engine.