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

Commit 6ea4abd4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10088597 from fe92c4b2 to udc-qpr1-release

Change-Id: Ic1a9b1070100db23ba097a446a12de87aef2f469
parents 4fec80e5 fe92c4b2
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -102,6 +102,43 @@ interface IActivityManager {
    void registerUidObserver(in IUidObserver observer, int which, int cutpoint,
            String callingPackage);
    void unregisterUidObserver(in IUidObserver observer);

    /**
     * Registers a UidObserver with a uid filter.
     *
     * @param observer The UidObserver implementation to register.
     * @param which    A bitmask of events to observe. See ActivityManager.UID_OBSERVER_*.
     * @param cutpoint The cutpoint for onUidStateChanged events. When the state crosses this
     *                 threshold in either direction, onUidStateChanged will be called.
     * @param callingPackage The name of the calling package.
     * @param uids     A list of uids to watch. If all uids are to be watched, use
     *                 registerUidObserver instead.
     * @throws RemoteException
     * @return Returns A binder token identifying the UidObserver registration.
     */
    IBinder registerUidObserverForUids(in IUidObserver observer, int which, int cutpoint,
            String callingPackage, in int[] uids);

    /**
     * Adds a uid to the list of uids that a UidObserver will receive updates about.
     *
     * @param observerToken  The binder token identifying the UidObserver registration.
     * @param callingPackage The name of the calling package.
     * @param uid            The uid to watch.
     * @throws RemoteException
     */
    void addUidToObserver(in IBinder observerToken, String callingPackage, int uid);

    /**
     * Removes a uid from the list of uids that a UidObserver will receive updates about.
     *
     * @param observerToken  The binder token identifying the UidObserver registration.
     * @param callingPackage The name of the calling package.
     * @param uid            The uid to stop watching.
     * @throws RemoteException
     */
    void removeUidFromObserver(in IBinder observerToken, String callingPackage, int uid);

    boolean isUidActive(int uid, String callingPackage);
    @JavaPassthrough(annotation=
            "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)")
+8 −0
Original line number Diff line number Diff line
@@ -258,6 +258,14 @@ interface IWallpaperManager {
     */
    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.
     * Return true if the lockscreen wallpaper always uses a WallpaperService, not a static image.
+152 −105
Original line number Diff line number Diff line
@@ -658,15 +658,8 @@ public class WallpaperManager {
                    return currentWallpaper;
                }
            }
            if (returnDefault) {
                Bitmap defaultWallpaper = mDefaultWallpaper;
                if (defaultWallpaper == null || defaultWallpaper.isRecycled()) {
                    defaultWallpaper = getDefaultWallpaper(context, which);
                    synchronized (this) {
                        mDefaultWallpaper = defaultWallpaper;
                    }
                }
                return defaultWallpaper;
            if (returnDefault || (which == FLAG_LOCK && isStaticWallpaper(FLAG_LOCK))) {
                return getDefaultWallpaper(context, which);
            }
            return null;
        }
@@ -705,7 +698,7 @@ public class WallpaperManager {
            }
            // If user wallpaper is unavailable, may be the default one instead.
            if ((dimensions == null || dimensions.width() == 0 || dimensions.height() == 0)
                    && returnDefault) {
                    && (returnDefault || (which == FLAG_LOCK && isStaticWallpaper(FLAG_LOCK)))) {
                InputStream is = openDefaultWallpaper(context, which);
                if (is != null) {
                    try {
@@ -769,18 +762,39 @@ public class WallpaperManager {
        }

        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) {
                try {
                        BitmapFactory.Options options = new BitmapFactory.Options();
                    return BitmapFactory.decodeStream(is, null, options);
                } catch (OutOfMemoryError e) {
                        defaultWallpaper = BitmapFactory.decodeStream(is, null, options);
                    }
                } catch (OutOfMemoryError | IOException 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}
     *     can still access the real wallpaper on all versions. </li>
     * </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>
     * 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.
     * Equivalent to {@link #getDrawable(int)} with {@code which=}{@link #FLAG_SYSTEM}.
     * </p>
     *
     * @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.
     * @return A Drawable object for the requested wallpaper.
     *
     * @see #getDrawable(int)
     *
     * @throws SecurityException as described in the note
     */
@@ -919,23 +926,29 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     * </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>
     * 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.
     * Retrieve the requested wallpaper for the specified wallpaper type if the wallpaper is not
     * a live wallpaper. This method should not be used to display the user wallpaper on an app:
     * {@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
     *     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.
     * @return A Drawable object for the requested wallpaper.
     *
     * @throws SecurityException as described in the note
     */
@@ -943,7 +956,8 @@ public class WallpaperManager {
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable getDrawable(@SetWallpaperFlags int which) {
        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) {
            Drawable dr = new BitmapDrawable(mContext.getResources(), bm);
            dr.setDither(false);
@@ -1175,15 +1189,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * <br>
     *
     * Retrieve the current system 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.
     * <p>
     * Equivalent to {@link #getDrawable()}.
     * </p>
     *
     * @return A Drawable object for the requested wallpaper.
     *
     * @return Returns a Drawable object that will draw the wallpaper or a
     * null pointer if wallpaper is unset.
     * @see #getDrawable()
     *
     * @throws SecurityException as described in the note
     */
@@ -1206,31 +1219,23 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * <br>
     *
     * 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.
     * <p>
     * Equivalent to {@link #getDrawable(int)}.
     * </p>
     *
     * @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
     * wallpaper is unset.
     * @return A Drawable object for the requested wallpaper.
     *
     * @see #getDrawable(int)
     *
     * @throws SecurityException as described in the note
     */
    @Nullable
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable peekDrawable(@SetWallpaperFlags int which) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        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;
        return getDrawable(which);
    }

    /**
@@ -1246,19 +1251,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * <br>
     *
     * 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
     * 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).
     * <p>
     * Equivalent to {@link #getFastDrawable(int)} with {@code which=}{@link #FLAG_SYSTEM}.
     * </p>
     *
     * @return A Drawable object for the requested wallpaper.
     *
     * @return Returns a Drawable object that will draw the wallpaper.
     * @see #getFastDrawable(int)
     *
     * @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
     *     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
     */
@@ -1303,7 +1304,8 @@ public class WallpaperManager {
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable getFastDrawable(@SetWallpaperFlags int which) {
        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) {
            return new FastBitmapDrawable(bm);
        }
@@ -1323,13 +1325,14 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * <br>
     *
     * Like {@link #getFastDrawable()}, but if there is no wallpaper set,
     * a null pointer is returned.
     * <p>
     * Equivalent to {@link #getFastDrawable()}.
     * </p>
     *
     * @return An optimized Drawable object for the requested wallpaper.
     *
     * @return Returns an optimized Drawable object that will draw the
     * wallpaper or a null pointer if these is none.
     * @see #getFastDrawable()
     *
     * @throws SecurityException as described in the note
     */
@@ -1352,31 +1355,29 @@ public class WallpaperManager {
     *     <li> Apps with {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE}
     *     can still access the real wallpaper on all versions. </li>
     * </ul>
     * <br>
     *
     * Like {@link #getFastDrawable()}, but if there is no wallpaper set,
     * a null pointer is returned.
     * <p>
     * Equivalent to {@link #getFastDrawable(int)}.
     * </p>
     *
     * @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.
     * @return An optimized Drawable object for the requested wallpaper.
     *
     * @throws SecurityException as described in the note
     */
    @Nullable
    @RequiresPermission(anyOf = {MANAGE_EXTERNAL_STORAGE, READ_WALLPAPER_INTERNAL})
    public Drawable peekFastDrawable(@SetWallpaperFlags int which) {
        final ColorManagementProxy cmProxy = getColorManagementProxy();
        Bitmap bm = sGlobals.peekWallpaperBitmap(mContext, true, which, cmProxy);
        if (bm != null) {
            return new FastBitmapDrawable(bm);
        }
        return null;
        return getFastDrawable(which);
    }

    /**
     * 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
     *     defined kind of wallpaper, either {@link #FLAG_SYSTEM} or {@link #FLAG_LOCK}.
     * @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 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
     * @hide
@@ -1453,12 +1454,29 @@ public class WallpaperManager {
    @TestApi
    @Nullable
    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();
        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.
     * Equivalent to {@link #peekBitmapDimensions(int)} with {@code which=}{@link #FLAG_SYSTEM}.
     *
     * @return the dimensions of system wallpaper
     * @hide
@@ -1472,16 +1490,45 @@ public class WallpaperManager {
    /**
     * Peek the dimensions of given wallpaper of the user without decoding it.
     *
     * @param which Wallpaper type. Must be either {@link #FLAG_SYSTEM} or
     *     {@link #FLAG_LOCK}.
     * @return the dimensions of system wallpaper
     * <p>
     * When called with {@code which=}{@link #FLAG_SYSTEM}, if there is a live wallpaper on
     * 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
     */
    @TestApi
    @Nullable
    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);
        return sGlobals.peekWallpaperDimensions(mContext, true /* returnDefault */, which,
        return sGlobals.peekWallpaperDimensions(mContext, returnDefault, which,
                mContext.getUserId());
    }

+9 −7
Original line number Diff line number Diff line
@@ -3036,9 +3036,7 @@ public final class Settings {
        public void destroy() {
            try {
                // If this process is the system server process, mArray is the same object as
                // the memory int array kept inside SettingsProvider, so skipping the close()
                if (!Settings.isInSystemServer() && !mArray.isClosed()) {
                if (!mArray.isClosed()) {
                    mArray.close();
                }
            } catch (IOException e) {
@@ -3218,8 +3216,9 @@ public final class Settings {
        @UnsupportedAppUsage
        public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
            final boolean isSelf = (userHandle == UserHandle.myUserId());
            final boolean useCache = isSelf && !isInSystemServer();
            boolean needsGenerationTracker = false;
            if (isSelf) {
            if (useCache) {
                synchronized (NameValueCache.this) {
                    final GenerationTracker generationTracker = mGenerationTrackers.get(name);
                    if (generationTracker != null) {
@@ -3365,10 +3364,13 @@ public final class Settings {
                                }
                            }
                        } else {
                            if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
                            if (DEBUG || LOCAL_LOGV) {
                                Log.i(TAG, "call-query of user " + userHandle
                                        + " by " + UserHandle.myUserId()
                                        + (isInSystemServer() ? " in system_server" : "")
                                        + " so not updating cache");
                            }
                        }
                        return value;
                    }
                    // If the response Bundle is null, we fall through
+31 −17

File changed.

Preview size limit exceeded, changes collapsed.

Loading