am c33f94e2: Merge "Fix API review bugs." into jb-mr1-dev

* commit 'c33f94e2a50c9b03cb771237e8672743da8b1314':
  Fix API review bugs.
This commit is contained in:
Dianne Hackborn
2012-09-17 18:25:00 -07:00
committed by Android Git Automerger
10 changed files with 122 additions and 77 deletions

View File

@@ -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;
@@ -621,6 +649,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
@@ -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);

View File

@@ -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

View File

@@ -204,6 +204,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
@@ -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);

View File

@@ -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);

View File

@@ -22,6 +22,7 @@ import java.util.HashSet;
/**
* Per-user state information about a package.
* @hide
*/
public class PackageUserState {
public boolean stopped;

View File

@@ -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() {