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

Commit 6610524e authored by Xiaoyu Jin's avatar Xiaoyu Jin
Browse files

Change registerContentObserverForAllUsers to registerContentObserverAsUser

Make the change based on API council's suggestion.

Bug: 206743591
Test: Manual testing to verify the
observer can get notifications for
all the users.

Change-Id: I725307f65c288c4fc8bc3acf923cd7092ccc2f97
parent 51f6e1fc
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ package android.content {
    method @NonNull public static android.net.Uri createContentUriForUser(@NonNull android.net.Uri, @NonNull android.os.UserHandle);
  }

  public abstract class ContentResolver {
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public final void registerContentObserverAsUser(@NonNull android.net.Uri, boolean, @NonNull android.database.ContentObserver, @NonNull android.os.UserHandle);
  }

  public abstract class Context {
    method @NonNull public android.os.UserHandle getUser();
    field public static final String PAC_PROXY_SERVICE = "pac_proxy";
+0 −1
Original line number Diff line number Diff line
@@ -2440,7 +2440,6 @@ package android.content {
    method @NonNull public static java.io.File encodeToFile(@NonNull android.net.Uri);
    method @Nullable @RequiresPermission("android.permission.CACHE_CONTENT") public android.os.Bundle getCache(@NonNull android.net.Uri);
    method @RequiresPermission("android.permission.CACHE_CONTENT") public void putCache(@NonNull android.net.Uri, @Nullable android.os.Bundle);
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public final void registerContentObserverForAllUsers(@NonNull android.net.Uri, boolean, @NonNull android.database.ContentObserver);
  }
  public abstract class Context {
+9 −5
Original line number Diff line number Diff line
@@ -2666,7 +2666,7 @@ public abstract class ContentResolver implements ContentInterface {

    /**
     * Same as {@link #registerContentObserver(Uri, boolean, ContentObserver)}, but the observer
     * registered will get content change notifications from all users.
     * registered will get content change notifications for the specified user.
     * {@link ContentObserver#onChange(boolean, Collection, int, UserHandle)} should be
     * overwritten to get the corresponding {@link UserHandle} for that notification.
     *
@@ -2679,21 +2679,25 @@ public abstract class ContentResolver implements ContentInterface {
     *                             whenever a change occurs to the URI's descendants in the path
     *                             hierarchy.
     * @param observer             The object that receives callbacks when changes occur.
     * @param userHandle           The UserHandle of the user the content change notifications are
     *                             for.
     * @hide
     * @see #unregisterContentObserver
     */
    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
    @SystemApi
    public final void registerContentObserverForAllUsers(@NonNull Uri uri,
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public final void registerContentObserverAsUser(@NonNull Uri uri,
            boolean notifyForDescendants,
            @NonNull ContentObserver observer) {
            @NonNull ContentObserver observer,
            @NonNull UserHandle userHandle) {
        Objects.requireNonNull(uri, "uri");
        Objects.requireNonNull(observer, "observer");
        Objects.requireNonNull(userHandle, "userHandle");
        registerContentObserver(
                ContentProvider.getUriWithoutUserId(uri),
                notifyForDescendants,
                observer,
                UserHandle.USER_ALL);
                userHandle.getIdentifier());
    }

    /** @hide - designated user version */