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

Commit 5cdb2480 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am abac0cd1: Merge "Add PendingIntent and IntentSender APIs to get user handle." into jb-mr1-dev

* commit 'abac0cd1':
  Add PendingIntent and IntentSender APIs to get user handle.
parents aeb35ff5 abac0cd1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3870,6 +3870,8 @@ package android.app {
    method public android.content.IntentSender getIntentSender();
    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 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;
@@ -5986,6 +5988,8 @@ package android.content {
  public class IntentSender implements android.os.Parcelable {
    method public int describeContents();
    method public java.lang.String getTargetPackage();
    method public int getTargetUid();
    method public int 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;
+42 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserId;
import android.util.AndroidException;

/**
@@ -616,6 +617,47 @@ public final class PendingIntent implements Parcelable {
        }
    }

    /**
     * Return the uid of the application that created this
     * PendingIntent, that is the identity under which you will actually be
     * sending the Intent.  The returned integer is supplied by the system, so
     * that an application can not spoof its uid.
     *
     * @return The uid of the PendingIntent, or -1 if there is
     * none associated with it.
     */
    public int getTargetUid() {
        try {
            return ActivityManagerNative.getDefault()
                .getUidForIntentSender(mTarget);
        } catch (RemoteException e) {
            // Should never happen.
            return -1;
        }
    }

    /**
     * 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
     * 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
     * none associated with it.
     */
    public int getTargetUserHandle() {
        try {
            int uid = ActivityManagerNative.getDefault()
                .getUidForIntentSender(mTarget);
            return uid > 0 ? UserId.getUserId(uid) : -1;
        } catch (RemoteException e) {
            // Should never happen.
            return -1;
        }
    }

    /**
     * @hide
     * Check to verify that this PendingIntent targets a specific package.
+42 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserId;
import android.util.AndroidException;


@@ -222,6 +223,47 @@ public class IntentSender implements Parcelable {
        }
    }

    /**
     * Return the uid of the application that created this
     * PendingIntent, that is the identity under which you will actually be
     * sending the Intent.  The returned integer is supplied by the system, so
     * that an application can not spoof its uid.
     *
     * @return The uid of the PendingIntent, or -1 if there is
     * none associated with it.
     */
    public int getTargetUid() {
        try {
            return ActivityManagerNative.getDefault()
                .getUidForIntentSender(mTarget);
        } catch (RemoteException e) {
            // Should never happen.
            return -1;
        }
    }

    /**
     * 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
     * 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
     * none associated with it.
     */
    public int getTargetUserHandle() {
        try {
            int uid = ActivityManagerNative.getDefault()
                .getUidForIntentSender(mTarget);
            return uid > 0 ? UserId.getUserId(uid) : -1;
        } catch (RemoteException e) {
            // Should never happen.
            return -1;
        }
    }

    /**
     * Comparison operator on two IntentSender objects, such that true
     * is returned then they both represent the same operation from the