diff options
-rw-r--r-- | api/current.txt | 29 | ||||
-rw-r--r-- | core/java/android/app/PendingIntent.java | 52 | ||||
-rw-r--r-- | core/java/android/content/Context.java | 71 | ||||
-rw-r--r-- | core/java/android/content/IntentSender.java | 20 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 6 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageUserState.java | 1 | ||||
-rw-r--r-- | core/java/android/os/UserManager.java | 5 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 8 | ||||
-rw-r--r-- | core/res/res/values/attrs_manifest.xml | 5 | ||||
-rw-r--r-- | services/java/com/android/server/AlarmManagerService.java | 2 |
10 files changed, 122 insertions, 77 deletions
diff --git a/api/current.txt b/api/current.txt index f0148b4..e0736b6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -62,21 +62,17 @@ package android { field public static final java.lang.String INJECT_EVENTS = "android.permission.INJECT_EVENTS"; field public static final java.lang.String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER"; field public static final java.lang.String INSTALL_PACKAGES = "android.permission.INSTALL_PACKAGES"; - field public static final java.lang.String INTERACT_ACROSS_USERS = "android.permission.INTERACT_ACROSS_USERS"; field public static final java.lang.String INTERNAL_SYSTEM_WINDOW = "android.permission.INTERNAL_SYSTEM_WINDOW"; field public static final java.lang.String INTERNET = "android.permission.INTERNET"; field public static final java.lang.String KILL_BACKGROUND_PROCESSES = "android.permission.KILL_BACKGROUND_PROCESSES"; field public static final java.lang.String MANAGE_ACCOUNTS = "android.permission.MANAGE_ACCOUNTS"; field public static final java.lang.String MANAGE_APP_TOKENS = "android.permission.MANAGE_APP_TOKENS"; - field public static final java.lang.String MANAGE_USERS = "android.permission.MANAGE_USERS"; field public static final java.lang.String MASTER_CLEAR = "android.permission.MASTER_CLEAR"; field public static final java.lang.String MODIFY_AUDIO_SETTINGS = "android.permission.MODIFY_AUDIO_SETTINGS"; field public static final java.lang.String MODIFY_PHONE_STATE = "android.permission.MODIFY_PHONE_STATE"; field public static final java.lang.String MOUNT_FORMAT_FILESYSTEMS = "android.permission.MOUNT_FORMAT_FILESYSTEMS"; field public static final java.lang.String MOUNT_UNMOUNT_FILESYSTEMS = "android.permission.MOUNT_UNMOUNT_FILESYSTEMS"; - field public static final java.lang.String NET_TUNNELING = "android.permission.NET_TUNNELING"; field public static final java.lang.String NFC = "android.permission.NFC"; - field public static final java.lang.String PACKAGE_VERIFICATION_AGENT = "android.permission.PACKAGE_VERIFICATION_AGENT"; field public static final deprecated java.lang.String PERSISTENT_ACTIVITY = "android.permission.PERSISTENT_ACTIVITY"; field public static final java.lang.String PROCESS_OUTGOING_CALLS = "android.permission.PROCESS_OUTGOING_CALLS"; field public static final java.lang.String READ_CALENDAR = "android.permission.READ_CALENDAR"; @@ -3901,11 +3897,12 @@ package android.app { method public static android.app.PendingIntent getActivity(android.content.Context, int, android.content.Intent, int); method public static android.app.PendingIntent getActivity(android.content.Context, int, android.content.Intent, int, android.os.Bundle); method public static android.app.PendingIntent getBroadcast(android.content.Context, int, android.content.Intent, int); + method public java.lang.String getCreatorPackage(); + method public int getCreatorUid(); + method public android.os.UserHandle getCreatorUserHandle(); 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 android.os.UserHandle getTargetUserHandle(); + method public deprecated java.lang.String getTargetPackage(); 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; @@ -6060,9 +6057,10 @@ 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 android.os.UserHandle getTargetUserHandle(); + method public java.lang.String getCreatorPackage(); + method public int getCreatorUid(); + method public android.os.UserHandle getCreatorUserHandle(); + method public deprecated java.lang.String getTargetPackage(); 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; @@ -6705,17 +6703,6 @@ package android.content.pm { field public java.lang.String packageName; } - public class PackageUserState { - ctor public PackageUserState(); - ctor public PackageUserState(android.content.pm.PackageUserState); - field public java.util.HashSet disabledComponents; - field public int enabled; - field public java.util.HashSet enabledComponents; - field public boolean installed; - field public boolean notLaunched; - field public boolean stopped; - } - public class PathPermission extends android.os.PatternMatcher { ctor public PathPermission(java.lang.String, int, java.lang.String, java.lang.String); ctor public PathPermission(android.os.Parcel); diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index a3c1838..e7cea57 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -32,8 +32,8 @@ import android.util.AndroidException; /** * A description of an Intent and target action to perform with it. Instances - * of this class are created with {@link #getActivity}, - * {@link #getBroadcast}, {@link #getService}; the returned object can be + * of this class are created with {@link #getActivity}, {@link #getActivities}, + * {@link #getBroadcast}, and {@link #getService}; the returned object can be * handed to other applications so that they can perform the action you * described on your behalf at a later time. * @@ -54,6 +54,34 @@ import android.util.AndroidException; * categories, and components, and same flags), it will receive a PendingIntent * representing the same token if that is still valid, and can thus call * {@link #cancel} to remove it. + * + * <p>Because of this behavior, it is important to know when two Intents + * are considered to be the same for purposes of retrieving a PendingIntent. + * A common mistake people make is to create multiple PendingIntent objects + * with Intents that only vary in their "extra" contents, expecting to get + * a different PendingIntent each time. This does <em>not</em> happen. The + * parts of the Intent that are used for matching are the same ones defined + * by {@link Intent#filterEquals(Intent) Intent.filterEquals}. If you use two + * Intent objects that are equivalent as per + * {@link Intent#filterEquals(Intent) Intent.filterEquals}, then you will get + * the same PendingIntent for both of them. + * + * <p>There are two typical ways to deal with this. + * + * <p>If you truly need multiple distinct PendingIntent objects active at + * the same time (such as to use as two notifications that are both shown + * at the same time), then you will need to ensure there is something that + * is different about them to associate them with different PendingIntents. + * This may be any of the Intent attributes considered by + * {@link Intent#filterEquals(Intent) Intent.filterEquals}, or different + * request code integers supplied to {@link #getActivity}, {@link #getActivities}, + * {@link #getBroadcast}, or {@link #getService}. + * + * <p>If you only need one PendingIntent active at a time for any of the + * Intents you will use, then you can alternatively use the flags + * {@link #FLAG_CANCEL_CURRENT} or {@link #FLAG_UPDATE_CURRENT} to either + * cancel or modify whatever current PendingIntent is associated with the + * Intent you are supplying. */ public final class PendingIntent implements Parcelable { private final IIntentSender mTarget; @@ -622,6 +650,20 @@ public final class PendingIntent implements Parcelable { } /** + * @deprecated Renamed to {@link #getCreatorPackage()}. + */ + @Deprecated + public String getTargetPackage() { + try { + return ActivityManagerNative.getDefault() + .getPackageForIntentSender(mTarget); + } catch (RemoteException e) { + // Should never happen. + return null; + } + } + + /** * Return the package name of the application that created this * PendingIntent, that is the identity under which you will actually be * sending the Intent. The returned string is supplied by the system, so @@ -630,7 +672,7 @@ public final class PendingIntent implements Parcelable { * @return The package name of the PendingIntent, or null if there is * none associated with it. */ - public String getTargetPackage() { + public String getCreatorPackage() { try { return ActivityManagerNative.getDefault() .getPackageForIntentSender(mTarget); @@ -649,7 +691,7 @@ public final class PendingIntent implements Parcelable { * @return The uid of the PendingIntent, or -1 if there is * none associated with it. */ - public int getTargetUid() { + public int getCreatorUid() { try { return ActivityManagerNative.getDefault() .getUidForIntentSender(mTarget); @@ -670,7 +712,7 @@ public final class PendingIntent implements Parcelable { * @return The user handle of the PendingIntent, or null if there is * none associated with it. */ - public UserHandle getTargetUserHandle() { + public UserHandle getCreatorUserHandle() { try { int uid = ActivityManagerNative.getDefault() .getUidForIntentSender(mTarget); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 7438ba8..161670f 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -856,8 +856,10 @@ public abstract class Context { public abstract void startActivity(Intent intent); /** - * Same as {@link #startActivity(Intent)}, but for a specific user. It requires holding - * the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission. + * Version of {@link #startActivity(Intent)} that allows you to specify the + * user the activity will be started for. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS_FULL permission. * @param intent The description of the activity to start. * @param user The UserHandle of the user to start this activity for. * @throws ActivityNotFoundException @@ -895,8 +897,10 @@ public abstract class Context { public abstract void startActivity(Intent intent, Bundle options); /** - * Same as {@link #startActivity(Intent, Bundle)}, but for a specific user. It requires holding - * the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission. + * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the + * user the activity will be started for. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS_FULL permission. * @param intent The description of the activity to start. * @param options Additional options for how the Activity should be started. * May be null if there are no options. See {@link android.app.ActivityOptions} @@ -1118,10 +1122,10 @@ public abstract class Context { Bundle initialExtras); /** - * Same as {@link #sendBroadcast(Intent)}, but for a specific user. This broadcast - * can only be sent to receivers that are part of the calling application. It - * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} - * permission. + * Version of {@link #sendBroadcast(Intent)} that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. * @param intent The intent to broadcast * @param user UserHandle to send the intent to. * @see #sendBroadcast(Intent) @@ -1129,10 +1133,10 @@ public abstract class Context { public abstract void sendBroadcastAsUser(Intent intent, UserHandle user); /** - * Same as {@link #sendBroadcast(Intent, String)}, but for a specific user. This broadcast - * can only be sent to receivers that are part of the calling application. It - * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} - * permission. + * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. * * @param intent The Intent to broadcast; all receivers matching this * Intent will receive the broadcast. @@ -1147,12 +1151,12 @@ public abstract class Context { String receiverPermission); /** - * Same as - * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}, - * but for a specific user. This broadcast - * can only be sent to receivers that are part of the calling application. It - * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} - * permission. + * Version of + * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} + * that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. * * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. * @@ -1261,11 +1265,10 @@ public abstract class Context { public abstract void removeStickyBroadcast(Intent intent); /** - * Same as {@link #sendStickyBroadcast(Intent)}, - * but for a specific user. This broadcast - * can only be sent to receivers that are part of the calling application. It - * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} - * permission. + * Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. * * @param intent The Intent to broadcast; all receivers matching this * Intent will receive the broadcast, and the Intent will be held to @@ -1277,12 +1280,12 @@ public abstract class Context { public abstract void sendStickyBroadcastAsUser(Intent intent, UserHandle user); /** - * Same as - * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) - * but for a specific user. This broadcast - * can only be sent to receivers that are part of the calling application. It - * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} - * permission. + * Version of + * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} + * that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. * * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. * @@ -1309,12 +1312,10 @@ public abstract class Context { Bundle initialExtras); /** - * Same as - * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) - * but for a specific user. This broadcast - * can only be sent to receivers that are part of the calling application. It - * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} - * permission. + * Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. * * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} * permission in order to use this API. If you do not hold that diff --git a/core/java/android/content/IntentSender.java b/core/java/android/content/IntentSender.java index 6c3cf99..166495b 100644 --- a/core/java/android/content/IntentSender.java +++ b/core/java/android/content/IntentSender.java @@ -205,6 +205,20 @@ public class IntentSender implements Parcelable { } /** + * @deprecated Renamed to {@link #getCreatorPackage()}. + */ + @Deprecated + public String getTargetPackage() { + try { + return ActivityManagerNative.getDefault() + .getPackageForIntentSender(mTarget); + } catch (RemoteException e) { + // Should never happen. + return null; + } + } + + /** * Return the package name of the application that created this * IntentSender, that is the identity under which you will actually be * sending the Intent. The returned string is supplied by the system, so @@ -213,7 +227,7 @@ public class IntentSender implements Parcelable { * @return The package name of the PendingIntent, or null if there is * none associated with it. */ - public String getTargetPackage() { + public String getCreatorPackage() { try { return ActivityManagerNative.getDefault() .getPackageForIntentSender(mTarget); @@ -232,7 +246,7 @@ public class IntentSender implements Parcelable { * @return The uid of the PendingIntent, or -1 if there is * none associated with it. */ - public int getTargetUid() { + public int getCreatorUid() { try { return ActivityManagerNative.getDefault() .getUidForIntentSender(mTarget); @@ -253,7 +267,7 @@ public class IntentSender implements Parcelable { * @return The user handle of the PendingIntent, or null if there is * none associated with it. */ - public UserHandle getTargetUserHandle() { + public UserHandle getCreatorUserHandle() { try { int uid = ActivityManagerNative.getDefault() .getUidForIntentSender(mTarget); diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 4784d7f..fd488ae 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -2434,8 +2434,7 @@ public abstract class PackageManager { * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} * or {@link PackageManager#VERIFICATION_REJECT}. * @throws SecurityException if the caller does not have the - * {@link android.Manifest.permission#PACKAGE_VERIFICATION_AGENT} - * permission. + * PACKAGE_VERIFICATION_AGENT permission. */ public abstract void verifyPendingInstall(int id, int verificationCode); @@ -2469,8 +2468,7 @@ public abstract class PackageManager { * bounds value; namely, 0 or * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. * @throws SecurityException if the caller does not have the - * {@link android.Manifest.permission#PACKAGE_VERIFICATION_AGENT} - * permission. + * PACKAGE_VERIFICATION_AGENT permission. */ public abstract void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay); diff --git a/core/java/android/content/pm/PackageUserState.java b/core/java/android/content/pm/PackageUserState.java index 1a71bfb..3579977 100644 --- a/core/java/android/content/pm/PackageUserState.java +++ b/core/java/android/content/pm/PackageUserState.java @@ -22,6 +22,7 @@ import java.util.HashSet; /** * Per-user state information about a package. + * @hide */ public class PackageUserState { public boolean stopped; diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index cac1e07..daec7ea 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -55,8 +55,9 @@ public class UserManager { } /** - * Returns the user name of the user making this call. - * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. + * Returns the user name of the user making this call. This call is only + * available to applications on the system image; it requires the + * MANAGE_USERS permission. * @return the user name */ public String getUserName() { diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 0bc09aa..89d78b6 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -981,7 +981,7 @@ android:protectionLevel="dangerous" android:label="@string/permlab_getTasks" android:description="@string/permdesc_getTasks" /> - <!-- Allows an application to call APIs that allow it to do interactions + <!-- @hide Allows an application to call APIs that allow it to do interactions across the users on the device, using singleton services and user-targeted broadcasts. This permission is not available to third party applications. --> @@ -1000,7 +1000,7 @@ android:label="@string/permlab_interactAcrossUsersFull" android:description="@string/permdesc_interactAcrossUsersFull" /> - <!-- Allows an application to call APIs that allow it to query and manage + <!-- @hide Allows an application to call APIs that allow it to query and manage users on the device. This permission is not available to third party applications. --> <permission android:name="android.permission.MANAGE_USERS" @@ -1769,7 +1769,7 @@ android:description="@string/permdesc_devicePower" android:protectionLevel="signature" /> - <!-- Allows low-level access to tun tap driver --> + <!-- @hide Allows low-level access to tun tap driver --> <permission android:name="android.permission.NET_TUNNELING" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signature" /> @@ -1981,7 +1981,7 @@ android:protectionLevel="signature" /> <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE"/> - <!-- Package verifier needs to have this permission before the PackageManager will + <!-- @hide Package verifier needs to have this permission before the PackageManager will trust it to verify packages. --> <permission android:name="android.permission.PACKAGE_VERIFICATION_AGENT" diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 3c0c0a7..7209e4e 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -299,8 +299,9 @@ with this component (by binding to a service for example) those processes will always interact with the instance running for user 0. Enabling single user mode forces "exported" of the component to be false, to - help avoid introducing multi-user security bugs. You must hold the - permission {@link android.Manifest.permission#INTERACT_ACROSS_USERS} in order + help avoid introducing multi-user security bugs. This feature is only + available to applications built in to the system image; you must hold the + permission INTERACT_ACROSS_USERS in order to use this feature. This flag can only be used with services, receivers, and providers; it can not be used with activities. --> <attr name="singleUser" format="boolean" /> diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index f4ad756..f960833 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -353,7 +353,7 @@ class AlarmManagerService extends IAlarmManager.Stub { while (it.hasNext()) { Alarm alarm = it.next(); - if (UserHandle.getUserId(alarm.operation.getTargetUid()) == userHandle) { + if (UserHandle.getUserId(alarm.operation.getCreatorUid()) == userHandle) { it.remove(); } } |