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

Commit 73c4e53f authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am 79af1dd5: Switch public APIs to use new UserHandle class for identifying users.

* commit '79af1dd5':
  Switch public APIs to use new UserHandle class for identifying users.
parents 0dc70504 79af1dd5
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -3872,7 +3872,7 @@ package android.app {
    method public static android.app.PendingIntent getService(android.content.Context, int, android.content.Intent, int);
    method public java.lang.String getTargetPackage();
    method public int getTargetUid();
    method public int getTargetUserHandle();
    method public android.os.UserHandle getTargetUserHandle();
    method public static android.app.PendingIntent readPendingIntentOrNullFromParcel(android.os.Parcel);
    method public void send() throws android.app.PendingIntent.CanceledException;
    method public void send(int) throws android.app.PendingIntent.CanceledException;
@@ -5324,10 +5324,10 @@ package android.content {
    method public abstract void revokeUriPermission(android.net.Uri, int);
    method public abstract void sendBroadcast(android.content.Intent);
    method public abstract void sendBroadcast(android.content.Intent, java.lang.String);
    method public abstract void sendBroadcastToUser(android.content.Intent, int);
    method public abstract void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle);
    method public abstract void sendOrderedBroadcast(android.content.Intent, java.lang.String);
    method public abstract void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public abstract void sendOrderedBroadcastToUser(android.content.Intent, int, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public abstract void sendOrderedBroadcastAsUser(android.content.Intent, android.os.UserHandle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public abstract void sendStickyBroadcast(android.content.Intent);
    method public abstract void sendStickyOrderedBroadcast(android.content.Intent, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public abstract void setTheme(int);
@@ -5461,10 +5461,10 @@ package android.content {
    method public void revokeUriPermission(android.net.Uri, int);
    method public void sendBroadcast(android.content.Intent);
    method public void sendBroadcast(android.content.Intent, java.lang.String);
    method public void sendBroadcastToUser(android.content.Intent, int);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcastToUser(android.content.Intent, int, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcastAsUser(android.content.Intent, android.os.UserHandle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendStickyBroadcast(android.content.Intent);
    method public void sendStickyOrderedBroadcast(android.content.Intent, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void setTheme(int);
@@ -5990,7 +5990,7 @@ package android.content {
    method public int describeContents();
    method public java.lang.String getTargetPackage();
    method public int getTargetUid();
    method public int getTargetUserHandle();
    method public android.os.UserHandle getTargetUserHandle();
    method public static android.content.IntentSender readIntentSenderOrNullFromParcel(android.os.Parcel);
    method public void sendIntent(android.content.Context, int, android.content.Intent, android.content.IntentSender.OnFinished, android.os.Handler) throws android.content.IntentSender.SendIntentException;
    method public void sendIntent(android.content.Context, int, android.content.Intent, android.content.IntentSender.OnFinished, android.os.Handler, java.lang.String) throws android.content.IntentSender.SendIntentException;
@@ -16302,7 +16302,7 @@ package android.os {
    method public static final int myPid();
    method public static final int myTid();
    method public static final int myUid();
    method public static final int myUserHandle();
    method public static final android.os.UserHandle myUserHandle();
    method public static final void sendSignal(int, int);
    method public static final void setThreadPriority(int, int) throws java.lang.IllegalArgumentException, java.lang.SecurityException;
    method public static final void setThreadPriority(int) throws java.lang.IllegalArgumentException, java.lang.SecurityException;
@@ -16457,6 +16457,15 @@ package android.os {
    ctor public TransactionTooLargeException();
  }
  public final class UserHandle implements android.os.Parcelable {
    ctor public UserHandle(android.os.Parcel);
    method public int describeContents();
    method public static android.os.UserHandle readFromParcel(android.os.Parcel);
    method public void writeToParcel(android.os.Parcel, int);
    method public static void writeToParcel(android.os.UserHandle, android.os.Parcel);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public class UserManager {
    method public java.lang.String getUserName();
    method public boolean supportsMultipleUsers();
@@ -21206,10 +21215,10 @@ package android.test.mock {
    method public void revokeUriPermission(android.net.Uri, int);
    method public void sendBroadcast(android.content.Intent);
    method public void sendBroadcast(android.content.Intent, java.lang.String);
    method public void sendBroadcastToUser(android.content.Intent, int);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcastToUser(android.content.Intent, int, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcastAsUser(android.content.Intent, android.os.UserHandle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendStickyBroadcast(android.content.Intent);
    method public void sendStickyOrderedBroadcast(android.content.Intent, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void setTheme(int);
+1 −1
Original line number Diff line number Diff line
@@ -900,7 +900,7 @@ public class AccountManagerService
    private void sendAccountsChangedBroadcast(int userId) {
        Log.i(TAG, "the accounts changed, sending broadcast of "
                + ACCOUNTS_CHANGED_INTENT.getAction());
        mContext.sendBroadcastToUser(ACCOUNTS_CHANGED_INTENT, userId);
        mContext.sendBroadcastAsUser(ACCOUNTS_CHANGED_INTENT, new UserHandle(userId));
    }

    public void clearPassword(Account account) {
+10 −8
Original line number Diff line number Diff line
@@ -906,12 +906,13 @@ class ContextImpl extends Context {

    /** @hide */
    @Override
    public void startActivityAsUser(Intent intent, int userId) {
    public void startActivityAsUser(Intent intent, UserHandle user) {
        try {
            ActivityManagerNative.getDefault().startActivityAsUser(
                mMainThread.getApplicationThread(), intent,
                intent.resolveTypeIfNeeded(getContentResolver()),
                null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, null, userId);
                null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, null,
                user.getIdentifier());
        } catch (RemoteException re) {
        }
    }
@@ -931,12 +932,13 @@ class ContextImpl extends Context {

    /** @hide */
    @Override
    public void startActivityAsUser(Intent intent, Bundle options, int userId) {
    public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) {
        try {
            ActivityManagerNative.getDefault().startActivityAsUser(
                mMainThread.getApplicationThread(), intent,
                intent.resolveTypeIfNeeded(getContentResolver()),
                null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, options, userId);
                null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, options,
                user.getIdentifier());
        } catch (RemoteException re) {
        }
    }
@@ -1062,19 +1064,19 @@ class ContextImpl extends Context {
    }

    @Override
    public void sendBroadcastToUser(Intent intent, int userHandle) {
    public void sendBroadcastAsUser(Intent intent, UserHandle user) {
        String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
        try {
            intent.setAllowFds(false);
            ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread(),
                    intent, resolvedType, null, Activity.RESULT_OK, null, null, null, false, false,
                    userHandle);
                    user.getIdentifier());
        } catch (RemoteException e) {
        }
    }

    @Override
    public void sendOrderedBroadcastToUser(Intent intent, int userHandle,
    public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
            BroadcastReceiver resultReceiver, Handler scheduler,
            int initialCode, String initialData, Bundle initialExtras) {
        IIntentReceiver rd = null;
@@ -1100,7 +1102,7 @@ class ContextImpl extends Context {
            ActivityManagerNative.getDefault().broadcastIntent(
                mMainThread.getApplicationThread(), intent, resolvedType, rd,
                initialCode, initialData, initialExtras, null,
                true, false, userHandle);
                true, false, user.getIdentifier());
        } catch (RemoteException e) {
        }
    }
+5 −5
Original line number Diff line number Diff line
@@ -639,22 +639,22 @@ public final class PendingIntent implements Parcelable {
    /**
     * Return the user handle of the application that created this
     * PendingIntent, that is the user under which you will actually be
     * sending the Intent.  The returned integer is supplied by the system, so
     * sending the Intent.  The returned UserHandle is supplied by the system, so
     * that an application can not spoof its user.  See
     * {@link android.os.Process#myUserHandle() Process.myUserHandle()} for
     * more explanation of user handles.
     *
     * @return The user handle of the PendingIntent, or -1 if there is
     * @return The user handle of the PendingIntent, or null if there is
     * none associated with it.
     */
    public int getTargetUserHandle() {
    public UserHandle getTargetUserHandle() {
        try {
            int uid = ActivityManagerNative.getDefault()
                .getUidForIntentSender(mTarget);
            return uid > 0 ? UserHandle.getUserId(uid) : -1;
            return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
        } catch (RemoteException e) {
            // Should never happen.
            return -1;
            return null;
        }
    }

+9 −8
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.util.AttributeSet;

import java.io.File;
@@ -855,11 +856,11 @@ public abstract class Context {
     * Same as {@link #startActivity(Intent)}, but for a specific user. It requires holding
     * the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission.
     * @param intent The description of the activity to start.
     * @param userId The user id of the user to start this activity for.
     * @param user The UserHandle of the user to start this activity for.
     * @throws ActivityNotFoundException
     * @hide
     */
    public void startActivityAsUser(Intent intent, int userId) {
    public void startActivityAsUser(Intent intent, UserHandle user) {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

@@ -898,11 +899,11 @@ public abstract class Context {
     * May be null if there are no options.  See {@link android.app.ActivityOptions}
     * for how to build the Bundle supplied here; there are no supported definitions
     * for building it manually.
     * @param userId The user id of the user to start this activity for.
     * @param user The UserHandle of the user to start this activity for.
     * @throws ActivityNotFoundException
     * @hide
     */
    public void startActivityAsUser(Intent intent, Bundle options, int userId) {
    public void startActivityAsUser(Intent intent, Bundle options, UserHandle userId) {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

@@ -1119,10 +1120,10 @@ public abstract class Context {
     * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
     * permission.
     * @param intent The intent to broadcast
     * @param userHandle User to send the intent to.
     * @param user UserHandle to send the intent to.
     * @see #sendBroadcast(Intent)
     */
    public abstract void sendBroadcastToUser(Intent intent, int userHandle);
    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user);

    /**
     * Same as
@@ -1136,7 +1137,7 @@ public abstract class Context {
     *
     * @param intent The Intent to broadcast; all receivers matching this
     *               Intent will receive the broadcast.
     * @param userHandle User to send the intent to.
     * @param user UserHandle to send the intent to.
     * @param resultReceiver Your own BroadcastReceiver to treat as the final
     *                       receiver of the broadcast.
     * @param scheduler A custom Handler with which to schedule the
@@ -1151,7 +1152,7 @@ public abstract class Context {
     *
     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
     */
    public abstract void sendOrderedBroadcastToUser(Intent intent, int userHandle,
    public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
            BroadcastReceiver resultReceiver, Handler scheduler,
            int initialCode, String initialData, Bundle initialExtras);

Loading