Skip to content

Commit c33f94e

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix API review bugs." into jb-mr1-dev
2 parents 82f385a + 8832c18 commit c33f94e

File tree

10 files changed

+122
-77
lines changed

10 files changed

+122
-77
lines changed

api/current.txt

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,17 @@ package android {
6262
field public static final java.lang.String INJECT_EVENTS = "android.permission.INJECT_EVENTS";
6363
field public static final java.lang.String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER";
6464
field public static final java.lang.String INSTALL_PACKAGES = "android.permission.INSTALL_PACKAGES";
65-
field public static final java.lang.String INTERACT_ACROSS_USERS = "android.permission.INTERACT_ACROSS_USERS";
6665
field public static final java.lang.String INTERNAL_SYSTEM_WINDOW = "android.permission.INTERNAL_SYSTEM_WINDOW";
6766
field public static final java.lang.String INTERNET = "android.permission.INTERNET";
6867
field public static final java.lang.String KILL_BACKGROUND_PROCESSES = "android.permission.KILL_BACKGROUND_PROCESSES";
6968
field public static final java.lang.String MANAGE_ACCOUNTS = "android.permission.MANAGE_ACCOUNTS";
7069
field public static final java.lang.String MANAGE_APP_TOKENS = "android.permission.MANAGE_APP_TOKENS";
71-
field public static final java.lang.String MANAGE_USERS = "android.permission.MANAGE_USERS";
7270
field public static final java.lang.String MASTER_CLEAR = "android.permission.MASTER_CLEAR";
7371
field public static final java.lang.String MODIFY_AUDIO_SETTINGS = "android.permission.MODIFY_AUDIO_SETTINGS";
7472
field public static final java.lang.String MODIFY_PHONE_STATE = "android.permission.MODIFY_PHONE_STATE";
7573
field public static final java.lang.String MOUNT_FORMAT_FILESYSTEMS = "android.permission.MOUNT_FORMAT_FILESYSTEMS";
7674
field public static final java.lang.String MOUNT_UNMOUNT_FILESYSTEMS = "android.permission.MOUNT_UNMOUNT_FILESYSTEMS";
77-
field public static final java.lang.String NET_TUNNELING = "android.permission.NET_TUNNELING";
7875
field public static final java.lang.String NFC = "android.permission.NFC";
79-
field public static final java.lang.String PACKAGE_VERIFICATION_AGENT = "android.permission.PACKAGE_VERIFICATION_AGENT";
8076
field public static final deprecated java.lang.String PERSISTENT_ACTIVITY = "android.permission.PERSISTENT_ACTIVITY";
8177
field public static final java.lang.String PROCESS_OUTGOING_CALLS = "android.permission.PROCESS_OUTGOING_CALLS";
8278
field public static final java.lang.String READ_CALENDAR = "android.permission.READ_CALENDAR";
@@ -3901,11 +3897,12 @@ package android.app {
39013897
method public static android.app.PendingIntent getActivity(android.content.Context, int, android.content.Intent, int);
39023898
method public static android.app.PendingIntent getActivity(android.content.Context, int, android.content.Intent, int, android.os.Bundle);
39033899
method public static android.app.PendingIntent getBroadcast(android.content.Context, int, android.content.Intent, int);
3900+
method public java.lang.String getCreatorPackage();
3901+
method public int getCreatorUid();
3902+
method public android.os.UserHandle getCreatorUserHandle();
39043903
method public android.content.IntentSender getIntentSender();
39053904
method public static android.app.PendingIntent getService(android.content.Context, int, android.content.Intent, int);
3906-
method public java.lang.String getTargetPackage();
3907-
method public int getTargetUid();
3908-
method public android.os.UserHandle getTargetUserHandle();
3905+
method public deprecated java.lang.String getTargetPackage();
39093906
method public static android.app.PendingIntent readPendingIntentOrNullFromParcel(android.os.Parcel);
39103907
method public void send() throws android.app.PendingIntent.CanceledException;
39113908
method public void send(int) throws android.app.PendingIntent.CanceledException;
@@ -6060,9 +6057,10 @@ package android.content {
60606057

60616058
public class IntentSender implements android.os.Parcelable {
60626059
method public int describeContents();
6063-
method public java.lang.String getTargetPackage();
6064-
method public int getTargetUid();
6065-
method public android.os.UserHandle getTargetUserHandle();
6060+
method public java.lang.String getCreatorPackage();
6061+
method public int getCreatorUid();
6062+
method public android.os.UserHandle getCreatorUserHandle();
6063+
method public deprecated java.lang.String getTargetPackage();
60666064
method public static android.content.IntentSender readIntentSenderOrNullFromParcel(android.os.Parcel);
60676065
method public void sendIntent(android.content.Context, int, android.content.Intent, android.content.IntentSender.OnFinished, android.os.Handler) throws android.content.IntentSender.SendIntentException;
60686066
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 {
67056703
field public java.lang.String packageName;
67066704
}
67076705

6708-
public class PackageUserState {
6709-
ctor public PackageUserState();
6710-
ctor public PackageUserState(android.content.pm.PackageUserState);
6711-
field public java.util.HashSet disabledComponents;
6712-
field public int enabled;
6713-
field public java.util.HashSet enabledComponents;
6714-
field public boolean installed;
6715-
field public boolean notLaunched;
6716-
field public boolean stopped;
6717-
}
6718-
67196706
public class PathPermission extends android.os.PatternMatcher {
67206707
ctor public PathPermission(java.lang.String, int, java.lang.String, java.lang.String);
67216708
ctor public PathPermission(android.os.Parcel);

core/java/android/app/PendingIntent.java

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
/**
3434
* A description of an Intent and target action to perform with it. Instances
35-
* of this class are created with {@link #getActivity},
36-
* {@link #getBroadcast}, {@link #getService}; the returned object can be
35+
* of this class are created with {@link #getActivity}, {@link #getActivities},
36+
* {@link #getBroadcast}, and {@link #getService}; the returned object can be
3737
* handed to other applications so that they can perform the action you
3838
* described on your behalf at a later time.
3939
*
@@ -54,6 +54,34 @@
5454
* categories, and components, and same flags), it will receive a PendingIntent
5555
* representing the same token if that is still valid, and can thus call
5656
* {@link #cancel} to remove it.
57+
*
58+
* <p>Because of this behavior, it is important to know when two Intents
59+
* are considered to be the same for purposes of retrieving a PendingIntent.
60+
* A common mistake people make is to create multiple PendingIntent objects
61+
* with Intents that only vary in their "extra" contents, expecting to get
62+
* a different PendingIntent each time. This does <em>not</em> happen. The
63+
* parts of the Intent that are used for matching are the same ones defined
64+
* by {@link Intent#filterEquals(Intent) Intent.filterEquals}. If you use two
65+
* Intent objects that are equivalent as per
66+
* {@link Intent#filterEquals(Intent) Intent.filterEquals}, then you will get
67+
* the same PendingIntent for both of them.
68+
*
69+
* <p>There are two typical ways to deal with this.
70+
*
71+
* <p>If you truly need multiple distinct PendingIntent objects active at
72+
* the same time (such as to use as two notifications that are both shown
73+
* at the same time), then you will need to ensure there is something that
74+
* is different about them to associate them with different PendingIntents.
75+
* This may be any of the Intent attributes considered by
76+
* {@link Intent#filterEquals(Intent) Intent.filterEquals}, or different
77+
* request code integers supplied to {@link #getActivity}, {@link #getActivities},
78+
* {@link #getBroadcast}, or {@link #getService}.
79+
*
80+
* <p>If you only need one PendingIntent active at a time for any of the
81+
* Intents you will use, then you can alternatively use the flags
82+
* {@link #FLAG_CANCEL_CURRENT} or {@link #FLAG_UPDATE_CURRENT} to either
83+
* cancel or modify whatever current PendingIntent is associated with the
84+
* Intent you are supplying.
5785
*/
5886
public final class PendingIntent implements Parcelable {
5987
private final IIntentSender mTarget;
@@ -621,6 +649,20 @@ public void send(Context context, int code, Intent intent,
621649
}
622650
}
623651

652+
/**
653+
* @deprecated Renamed to {@link #getCreatorPackage()}.
654+
*/
655+
@Deprecated
656+
public String getTargetPackage() {
657+
try {
658+
return ActivityManagerNative.getDefault()
659+
.getPackageForIntentSender(mTarget);
660+
} catch (RemoteException e) {
661+
// Should never happen.
662+
return null;
663+
}
664+
}
665+
624666
/**
625667
* Return the package name of the application that created this
626668
* PendingIntent, that is the identity under which you will actually be
@@ -630,7 +672,7 @@ public void send(Context context, int code, Intent intent,
630672
* @return The package name of the PendingIntent, or null if there is
631673
* none associated with it.
632674
*/
633-
public String getTargetPackage() {
675+
public String getCreatorPackage() {
634676
try {
635677
return ActivityManagerNative.getDefault()
636678
.getPackageForIntentSender(mTarget);
@@ -649,7 +691,7 @@ public String getTargetPackage() {
649691
* @return The uid of the PendingIntent, or -1 if there is
650692
* none associated with it.
651693
*/
652-
public int getTargetUid() {
694+
public int getCreatorUid() {
653695
try {
654696
return ActivityManagerNative.getDefault()
655697
.getUidForIntentSender(mTarget);
@@ -670,7 +712,7 @@ public int getTargetUid() {
670712
* @return The user handle of the PendingIntent, or null if there is
671713
* none associated with it.
672714
*/
673-
public UserHandle getTargetUserHandle() {
715+
public UserHandle getCreatorUserHandle() {
674716
try {
675717
int uid = ActivityManagerNative.getDefault()
676718
.getUidForIntentSender(mTarget);

core/java/android/content/Context.java

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,10 @@ public abstract SQLiteDatabase openOrCreateDatabase(String name,
856856
public abstract void startActivity(Intent intent);
857857

858858
/**
859-
* Same as {@link #startActivity(Intent)}, but for a specific user. It requires holding
860-
* the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission.
859+
* Version of {@link #startActivity(Intent)} that allows you to specify the
860+
* user the activity will be started for. This is not available to applications
861+
* that are not pre-installed on the system image. Using it requires holding
862+
* the INTERACT_ACROSS_USERS_FULL permission.
861863
* @param intent The description of the activity to start.
862864
* @param user The UserHandle of the user to start this activity for.
863865
* @throws ActivityNotFoundException
@@ -895,8 +897,10 @@ public void startActivityAsUser(Intent intent, UserHandle user) {
895897
public abstract void startActivity(Intent intent, Bundle options);
896898

897899
/**
898-
* Same as {@link #startActivity(Intent, Bundle)}, but for a specific user. It requires holding
899-
* the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission.
900+
* Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the
901+
* user the activity will be started for. This is not available to applications
902+
* that are not pre-installed on the system image. Using it requires holding
903+
* the INTERACT_ACROSS_USERS_FULL permission.
900904
* @param intent The description of the activity to start.
901905
* @param options Additional options for how the Activity should be started.
902906
* May be null if there are no options. See {@link android.app.ActivityOptions}
@@ -1118,21 +1122,21 @@ public abstract void sendOrderedBroadcast(Intent intent,
11181122
Bundle initialExtras);
11191123

11201124
/**
1121-
* Same as {@link #sendBroadcast(Intent)}, but for a specific user. This broadcast
1122-
* can only be sent to receivers that are part of the calling application. It
1123-
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
1124-
* permission.
1125+
* Version of {@link #sendBroadcast(Intent)} that allows you to specify the
1126+
* user the broadcast will be sent to. This is not available to applications
1127+
* that are not pre-installed on the system image. Using it requires holding
1128+
* the INTERACT_ACROSS_USERS permission.
11251129
* @param intent The intent to broadcast
11261130
* @param user UserHandle to send the intent to.
11271131
* @see #sendBroadcast(Intent)
11281132
*/
11291133
public abstract void sendBroadcastAsUser(Intent intent, UserHandle user);
11301134

11311135
/**
1132-
* Same as {@link #sendBroadcast(Intent, String)}, but for a specific user. This broadcast
1133-
* can only be sent to receivers that are part of the calling application. It
1134-
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
1135-
* permission.
1136+
* Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
1137+
* user the broadcast will be sent to. This is not available to applications
1138+
* that are not pre-installed on the system image. Using it requires holding
1139+
* the INTERACT_ACROSS_USERS permission.
11361140
*
11371141
* @param intent The Intent to broadcast; all receivers matching this
11381142
* Intent will receive the broadcast.
@@ -1147,12 +1151,12 @@ public abstract void sendBroadcastAsUser(Intent intent, UserHandle user,
11471151
String receiverPermission);
11481152

11491153
/**
1150-
* Same as
1151-
* {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)},
1152-
* but for a specific user. This broadcast
1153-
* can only be sent to receivers that are part of the calling application. It
1154-
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
1155-
* permission.
1154+
* Version of
1155+
* {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}
1156+
* that allows you to specify the
1157+
* user the broadcast will be sent to. This is not available to applications
1158+
* that are not pre-installed on the system image. Using it requires holding
1159+
* the INTERACT_ACROSS_USERS permission.
11561160
*
11571161
* <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
11581162
*
@@ -1261,11 +1265,10 @@ public abstract void sendStickyOrderedBroadcast(Intent intent,
12611265
public abstract void removeStickyBroadcast(Intent intent);
12621266

12631267
/**
1264-
* Same as {@link #sendStickyBroadcast(Intent)},
1265-
* but for a specific user. This broadcast
1266-
* can only be sent to receivers that are part of the calling application. It
1267-
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
1268-
* permission.
1268+
* Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the
1269+
* user the broadcast will be sent to. This is not available to applications
1270+
* that are not pre-installed on the system image. Using it requires holding
1271+
* the INTERACT_ACROSS_USERS permission.
12691272
*
12701273
* @param intent The Intent to broadcast; all receivers matching this
12711274
* Intent will receive the broadcast, and the Intent will be held to
@@ -1277,12 +1280,12 @@ public abstract void sendStickyOrderedBroadcast(Intent intent,
12771280
public abstract void sendStickyBroadcastAsUser(Intent intent, UserHandle user);
12781281

12791282
/**
1280-
* Same as
1281-
* {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
1282-
* but for a specific user. This broadcast
1283-
* can only be sent to receivers that are part of the calling application. It
1284-
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
1285-
* permission.
1283+
* Version of
1284+
* {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)}
1285+
* that allows you to specify the
1286+
* user the broadcast will be sent to. This is not available to applications
1287+
* that are not pre-installed on the system image. Using it requires holding
1288+
* the INTERACT_ACROSS_USERS permission.
12861289
*
12871290
* <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
12881291
*
@@ -1309,12 +1312,10 @@ public abstract void sendStickyOrderedBroadcastAsUser(Intent intent,
13091312
Bundle initialExtras);
13101313

13111314
/**
1312-
* Same as
1313-
* {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
1314-
* but for a specific user. This broadcast
1315-
* can only be sent to receivers that are part of the calling application. It
1316-
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
1317-
* permission.
1315+
* Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the
1316+
* user the broadcast will be sent to. This is not available to applications
1317+
* that are not pre-installed on the system image. Using it requires holding
1318+
* the INTERACT_ACROSS_USERS permission.
13181319
*
13191320
* <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
13201321
* permission in order to use this API. If you do not hold that

core/java/android/content/IntentSender.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ public void sendIntent(Context context, int code, Intent intent,
204204
}
205205
}
206206

207+
/**
208+
* @deprecated Renamed to {@link #getCreatorPackage()}.
209+
*/
210+
@Deprecated
211+
public String getTargetPackage() {
212+
try {
213+
return ActivityManagerNative.getDefault()
214+
.getPackageForIntentSender(mTarget);
215+
} catch (RemoteException e) {
216+
// Should never happen.
217+
return null;
218+
}
219+
}
220+
207221
/**
208222
* Return the package name of the application that created this
209223
* IntentSender, that is the identity under which you will actually be
@@ -213,7 +227,7 @@ public void sendIntent(Context context, int code, Intent intent,
213227
* @return The package name of the PendingIntent, or null if there is
214228
* none associated with it.
215229
*/
216-
public String getTargetPackage() {
230+
public String getCreatorPackage() {
217231
try {
218232
return ActivityManagerNative.getDefault()
219233
.getPackageForIntentSender(mTarget);
@@ -232,7 +246,7 @@ public String getTargetPackage() {
232246
* @return The uid of the PendingIntent, or -1 if there is
233247
* none associated with it.
234248
*/
235-
public int getTargetUid() {
249+
public int getCreatorUid() {
236250
try {
237251
return ActivityManagerNative.getDefault()
238252
.getUidForIntentSender(mTarget);
@@ -253,7 +267,7 @@ public int getTargetUid() {
253267
* @return The user handle of the PendingIntent, or null if there is
254268
* none associated with it.
255269
*/
256-
public UserHandle getTargetUserHandle() {
270+
public UserHandle getCreatorUserHandle() {
257271
try {
258272
int uid = ActivityManagerNative.getDefault()
259273
.getUidForIntentSender(mTarget);

core/java/android/content/pm/PackageManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,8 +2434,7 @@ public abstract int installExistingPackage(String packageName)
24342434
* @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
24352435
* or {@link PackageManager#VERIFICATION_REJECT}.
24362436
* @throws SecurityException if the caller does not have the
2437-
* {@link android.Manifest.permission#PACKAGE_VERIFICATION_AGENT}
2438-
* permission.
2437+
* PACKAGE_VERIFICATION_AGENT permission.
24392438
*/
24402439
public abstract void verifyPendingInstall(int id, int verificationCode);
24412440

@@ -2469,8 +2468,7 @@ public abstract int installExistingPackage(String packageName)
24692468
* bounds value; namely, 0 or
24702469
* {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
24712470
* @throws SecurityException if the caller does not have the
2472-
* {@link android.Manifest.permission#PACKAGE_VERIFICATION_AGENT}
2473-
* permission.
2471+
* PACKAGE_VERIFICATION_AGENT permission.
24742472
*/
24752473
public abstract void extendVerificationTimeout(int id,
24762474
int verificationCodeAtTimeout, long millisecondsToDelay);

core/java/android/content/pm/PackageUserState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/**
2424
* Per-user state information about a package.
25+
* @hide
2526
*/
2627
public class PackageUserState {
2728
public boolean stopped;

0 commit comments

Comments
 (0)