Merge "Proposal: Reduce the number of IPCs in PendingIntent" into sc-dev am: 2409543ce8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13618861 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Id60d79df1fd4222b3f0ca85656a730156f3735de
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
parcelable ActivityManager.MemoryInfo;
|
parcelable ActivityManager.MemoryInfo;
|
||||||
|
parcelable ActivityManager.PendingIntentInfo;
|
||||||
parcelable ActivityManager.ProcessErrorStateInfo;
|
parcelable ActivityManager.ProcessErrorStateInfo;
|
||||||
parcelable ActivityManager.RecentTaskInfo;
|
parcelable ActivityManager.RecentTaskInfo;
|
||||||
parcelable ActivityManager.TaskDescription;
|
parcelable ActivityManager.TaskDescription;
|
||||||
|
|||||||
@@ -4776,4 +4776,71 @@ public class ActivityManager {
|
|||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A subset of immutable pending intent information suitable for caching on the client side.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final class PendingIntentInfo implements Parcelable {
|
||||||
|
|
||||||
|
private final String mCreatorPackage;
|
||||||
|
private final int mCreatorUid;
|
||||||
|
private final boolean mImmutable;
|
||||||
|
private final int mIntentSenderType;
|
||||||
|
|
||||||
|
public PendingIntentInfo(String creatorPackage, int creatorUid, boolean immutable,
|
||||||
|
int intentSenderType) {
|
||||||
|
mCreatorPackage = creatorPackage;
|
||||||
|
mCreatorUid = creatorUid;
|
||||||
|
mImmutable = immutable;
|
||||||
|
mIntentSenderType = intentSenderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatorPackage() {
|
||||||
|
return mCreatorPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreatorUid() {
|
||||||
|
return mCreatorUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isImmutable() {
|
||||||
|
return mImmutable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIntentSenderType() {
|
||||||
|
return mIntentSenderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel parcel, int flags) {
|
||||||
|
parcel.writeString(mCreatorPackage);
|
||||||
|
parcel.writeInt(mCreatorUid);
|
||||||
|
parcel.writeBoolean(mImmutable);
|
||||||
|
parcel.writeInt(mIntentSenderType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final @NonNull Creator<PendingIntentInfo> CREATOR =
|
||||||
|
new Creator<PendingIntentInfo>() {
|
||||||
|
@Override
|
||||||
|
public PendingIntentInfo createFromParcel(Parcel in) {
|
||||||
|
return new PendingIntentInfo(
|
||||||
|
/* creatorPackage= */ in.readString(),
|
||||||
|
/* creatorUid= */ in.readInt(),
|
||||||
|
/* immutable= */ in.readBoolean(),
|
||||||
|
/* intentSenderType= */ in.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PendingIntentInfo[] newArray(int size) {
|
||||||
|
return new PendingIntentInfo[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.ActivityManager.PendingIntentInfo;
|
||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
import android.app.ApplicationErrorReport;
|
import android.app.ApplicationErrorReport;
|
||||||
import android.app.ApplicationExitInfo;
|
import android.app.ApplicationExitInfo;
|
||||||
@@ -248,7 +249,7 @@ interface IActivityManager {
|
|||||||
in IBinder token, in String resultWho, int requestCode, in Intent[] intents,
|
in IBinder token, in String resultWho, int requestCode, in Intent[] intents,
|
||||||
in String[] resolvedTypes, int flags, in Bundle options, int userId);
|
in String[] resolvedTypes, int flags, in Bundle options, int userId);
|
||||||
void cancelIntentSender(in IIntentSender sender);
|
void cancelIntentSender(in IIntentSender sender);
|
||||||
String getPackageForIntentSender(in IIntentSender sender);
|
ActivityManager.PendingIntentInfo getInfoForIntentSender(in IIntentSender sender);
|
||||||
void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
|
void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
|
||||||
void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
|
void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
|
||||||
void enterSafeMode();
|
void enterSafeMode();
|
||||||
@@ -293,7 +294,6 @@ interface IActivityManager {
|
|||||||
int operationType);
|
int operationType);
|
||||||
void backupAgentCreated(in String packageName, in IBinder agent, int userId);
|
void backupAgentCreated(in String packageName, in IBinder agent, int userId);
|
||||||
void unbindBackupAgent(in ApplicationInfo appInfo);
|
void unbindBackupAgent(in ApplicationInfo appInfo);
|
||||||
int getUidForIntentSender(in IIntentSender sender);
|
|
||||||
int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
|
int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
|
||||||
boolean requireFull, in String name, in String callerPackage);
|
boolean requireFull, in String name, in String callerPackage);
|
||||||
void addPackageDependency(in String packageName);
|
void addPackageDependency(in String packageName);
|
||||||
@@ -345,7 +345,6 @@ interface IActivityManager {
|
|||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
void unregisterProcessObserver(in IProcessObserver observer);
|
void unregisterProcessObserver(in IProcessObserver observer);
|
||||||
boolean isIntentSenderTargetedToPackage(in IIntentSender sender);
|
boolean isIntentSenderTargetedToPackage(in IIntentSender sender);
|
||||||
boolean isIntentSenderImmutable(in IIntentSender sender);
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
void updatePersistentConfiguration(in Configuration values);
|
void updatePersistentConfiguration(in Configuration values);
|
||||||
void updatePersistentConfigurationWithAttribution(in Configuration values,
|
void updatePersistentConfigurationWithAttribution(in Configuration values,
|
||||||
@@ -375,8 +374,6 @@ interface IActivityManager {
|
|||||||
void unstableProviderDied(in IBinder connection);
|
void unstableProviderDied(in IBinder connection);
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
boolean isIntentSenderAnActivity(in IIntentSender sender);
|
boolean isIntentSenderAnActivity(in IIntentSender sender);
|
||||||
boolean isIntentSenderAForegroundService(in IIntentSender sender);
|
|
||||||
boolean isIntentSenderABroadcast(in IIntentSender sender);
|
|
||||||
/** @deprecated Use {@link startActivityAsUserWithFeature} instead */
|
/** @deprecated Use {@link startActivityAsUserWithFeature} instead */
|
||||||
@UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead")
|
@UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead")
|
||||||
int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
|
int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
|
||||||
@@ -710,6 +707,4 @@ interface IActivityManager {
|
|||||||
|
|
||||||
/** Called by PendingIntent.queryIntentComponents() */
|
/** Called by PendingIntent.queryIntentComponents() */
|
||||||
List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags);
|
List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags);
|
||||||
|
|
||||||
boolean isIntentSenderAService(in IIntentSender sender);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
|
import static android.app.ActivityManager.INTENT_SENDER_ACTIVITY;
|
||||||
|
import static android.app.ActivityManager.INTENT_SENDER_BROADCAST;
|
||||||
|
import static android.app.ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE;
|
||||||
|
import static android.app.ActivityManager.INTENT_SENDER_SERVICE;
|
||||||
|
|
||||||
import android.Manifest.permission;
|
import android.Manifest.permission;
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -25,6 +30,7 @@ import android.annotation.SuppressLint;
|
|||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SystemApi.Client;
|
import android.annotation.SystemApi.Client;
|
||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
|
import android.app.ActivityManager.PendingIntentInfo;
|
||||||
import android.compat.Compatibility;
|
import android.compat.Compatibility;
|
||||||
import android.compat.annotation.ChangeId;
|
import android.compat.annotation.ChangeId;
|
||||||
import android.compat.annotation.EnabledAfter;
|
import android.compat.annotation.EnabledAfter;
|
||||||
@@ -122,6 +128,9 @@ public final class PendingIntent implements Parcelable {
|
|||||||
private IBinder mWhitelistToken;
|
private IBinder mWhitelistToken;
|
||||||
private ArraySet<CancelListener> mCancelListeners;
|
private ArraySet<CancelListener> mCancelListeners;
|
||||||
|
|
||||||
|
// cached pending intent information
|
||||||
|
private @Nullable PendingIntentInfo mCachedInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It is now required to specify either {@link #FLAG_IMMUTABLE}
|
* It is now required to specify either {@link #FLAG_IMMUTABLE}
|
||||||
* or {@link #FLAG_MUTABLE} when creating a PendingIntent.
|
* or {@link #FLAG_MUTABLE} when creating a PendingIntent.
|
||||||
@@ -463,7 +472,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
intent.prepareToLeaveProcess(context);
|
intent.prepareToLeaveProcess(context);
|
||||||
IIntentSender target =
|
IIntentSender target =
|
||||||
ActivityManager.getService().getIntentSenderWithFeature(
|
ActivityManager.getService().getIntentSenderWithFeature(
|
||||||
ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
|
INTENT_SENDER_ACTIVITY, packageName,
|
||||||
context.getAttributionTag(), null, null, requestCode, new Intent[] { intent },
|
context.getAttributionTag(), null, null, requestCode, new Intent[] { intent },
|
||||||
resolvedType != null ? new String[] { resolvedType } : null,
|
resolvedType != null ? new String[] { resolvedType } : null,
|
||||||
flags, options, user.getIdentifier());
|
flags, options, user.getIdentifier());
|
||||||
@@ -596,7 +605,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
try {
|
try {
|
||||||
IIntentSender target =
|
IIntentSender target =
|
||||||
ActivityManager.getService().getIntentSenderWithFeature(
|
ActivityManager.getService().getIntentSenderWithFeature(
|
||||||
ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
|
INTENT_SENDER_ACTIVITY, packageName,
|
||||||
context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes,
|
context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes,
|
||||||
flags, options, user.getIdentifier());
|
flags, options, user.getIdentifier());
|
||||||
return target != null ? new PendingIntent(target) : null;
|
return target != null ? new PendingIntent(target) : null;
|
||||||
@@ -650,7 +659,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
intent.prepareToLeaveProcess(context);
|
intent.prepareToLeaveProcess(context);
|
||||||
IIntentSender target =
|
IIntentSender target =
|
||||||
ActivityManager.getService().getIntentSenderWithFeature(
|
ActivityManager.getService().getIntentSenderWithFeature(
|
||||||
ActivityManager.INTENT_SENDER_BROADCAST, packageName,
|
INTENT_SENDER_BROADCAST, packageName,
|
||||||
context.getAttributionTag(), null, null, requestCode, new Intent[] { intent },
|
context.getAttributionTag(), null, null, requestCode, new Intent[] { intent },
|
||||||
resolvedType != null ? new String[] { resolvedType } : null,
|
resolvedType != null ? new String[] { resolvedType } : null,
|
||||||
flags, null, userHandle.getIdentifier());
|
flags, null, userHandle.getIdentifier());
|
||||||
@@ -687,7 +696,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
public static PendingIntent getService(Context context, int requestCode,
|
public static PendingIntent getService(Context context, int requestCode,
|
||||||
@NonNull Intent intent, @Flags int flags) {
|
@NonNull Intent intent, @Flags int flags) {
|
||||||
return buildServicePendingIntent(context, requestCode, intent, flags,
|
return buildServicePendingIntent(context, requestCode, intent, flags,
|
||||||
ActivityManager.INTENT_SENDER_SERVICE);
|
INTENT_SENDER_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -717,7 +726,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
public static PendingIntent getForegroundService(Context context, int requestCode,
|
public static PendingIntent getForegroundService(Context context, int requestCode,
|
||||||
@NonNull Intent intent, @Flags int flags) {
|
@NonNull Intent intent, @Flags int flags) {
|
||||||
return buildServicePendingIntent(context, requestCode, intent, flags,
|
return buildServicePendingIntent(context, requestCode, intent, flags,
|
||||||
ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE);
|
INTENT_SENDER_FOREGROUND_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PendingIntent buildServicePendingIntent(Context context, int requestCode,
|
private static PendingIntent buildServicePendingIntent(Context context, int requestCode,
|
||||||
@@ -1001,12 +1010,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTargetPackage() {
|
public String getTargetPackage() {
|
||||||
try {
|
return getCreatorPackage();
|
||||||
return ActivityManager.getService()
|
|
||||||
.getPackageForIntentSender(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1029,12 +1033,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getCreatorPackage() {
|
public String getCreatorPackage() {
|
||||||
try {
|
return getCachedInfo().getCreatorPackage();
|
||||||
return ActivityManager.getService()
|
|
||||||
.getPackageForIntentSender(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1056,12 +1055,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
* none associated with it.
|
* none associated with it.
|
||||||
*/
|
*/
|
||||||
public int getCreatorUid() {
|
public int getCreatorUid() {
|
||||||
try {
|
return getCachedInfo().getCreatorUid();
|
||||||
return ActivityManager.getService()
|
|
||||||
.getUidForIntentSender(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1154,13 +1148,8 @@ public final class PendingIntent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public UserHandle getCreatorUserHandle() {
|
public UserHandle getCreatorUserHandle() {
|
||||||
try {
|
int uid = getCachedInfo().getCreatorUid();
|
||||||
int uid = ActivityManager.getService()
|
return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
|
||||||
.getUidForIntentSender(mTarget);
|
|
||||||
return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1180,12 +1169,7 @@ public final class PendingIntent implements Parcelable {
|
|||||||
* Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}.
|
* Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}.
|
||||||
*/
|
*/
|
||||||
public boolean isImmutable() {
|
public boolean isImmutable() {
|
||||||
try {
|
return getCachedInfo().isImmutable();
|
||||||
return ActivityManager.getService()
|
|
||||||
.isIntentSenderImmutable(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1193,48 +1177,28 @@ public final class PendingIntent implements Parcelable {
|
|||||||
* {@link #getActivity} or {@link #getActivities}.
|
* {@link #getActivity} or {@link #getActivities}.
|
||||||
*/
|
*/
|
||||||
public boolean isActivity() {
|
public boolean isActivity() {
|
||||||
try {
|
return getCachedInfo().getIntentSenderType() == INTENT_SENDER_ACTIVITY;
|
||||||
return ActivityManager.getService()
|
|
||||||
.isIntentSenderAnActivity(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}.
|
* @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}.
|
||||||
*/
|
*/
|
||||||
public boolean isForegroundService() {
|
public boolean isForegroundService() {
|
||||||
try {
|
return getCachedInfo().getIntentSenderType() == INTENT_SENDER_FOREGROUND_SERVICE;
|
||||||
return ActivityManager.getService()
|
|
||||||
.isIntentSenderAForegroundService(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this {@link PendingIntent} was created with {@link #getService}.
|
* @return TRUE if this {@link PendingIntent} was created with {@link #getService}.
|
||||||
*/
|
*/
|
||||||
public boolean isService() {
|
public boolean isService() {
|
||||||
try {
|
return getCachedInfo().getIntentSenderType() == INTENT_SENDER_SERVICE;
|
||||||
return ActivityManager.getService()
|
|
||||||
.isIntentSenderAService(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}.
|
* @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}.
|
||||||
*/
|
*/
|
||||||
public boolean isBroadcast() {
|
public boolean isBroadcast() {
|
||||||
try {
|
return getCachedInfo().getIntentSenderType() == INTENT_SENDER_BROADCAST;
|
||||||
return ActivityManager.getService()
|
|
||||||
.isIntentSenderABroadcast(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1433,4 +1397,16 @@ public final class PendingIntent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
void onCancelled(PendingIntent intent);
|
void onCancelled(PendingIntent intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PendingIntentInfo getCachedInfo() {
|
||||||
|
if (mCachedInfo == null) {
|
||||||
|
try {
|
||||||
|
mCachedInfo = ActivityManager.getService().getInfoForIntentSender(mTarget);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mCachedInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.content;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.ActivityManager.PendingIntentInfo;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -60,6 +61,9 @@ public class IntentSender implements Parcelable {
|
|||||||
private final IIntentSender mTarget;
|
private final IIntentSender mTarget;
|
||||||
IBinder mWhitelistToken;
|
IBinder mWhitelistToken;
|
||||||
|
|
||||||
|
// cached pending intent information
|
||||||
|
private @Nullable PendingIntentInfo mCachedInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when trying to send through a PendingIntent that
|
* Exception thrown when trying to send through a PendingIntent that
|
||||||
* has been canceled or is otherwise no longer able to execute the request.
|
* has been canceled or is otherwise no longer able to execute the request.
|
||||||
@@ -209,13 +213,7 @@ public class IntentSender implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTargetPackage() {
|
public String getTargetPackage() {
|
||||||
try {
|
return getCreatorPackage();
|
||||||
return ActivityManager.getService()
|
|
||||||
.getPackageForIntentSender(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// Should never happen.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,13 +226,7 @@ public class IntentSender implements Parcelable {
|
|||||||
* none associated with it.
|
* none associated with it.
|
||||||
*/
|
*/
|
||||||
public String getCreatorPackage() {
|
public String getCreatorPackage() {
|
||||||
try {
|
return getCachedInfo().getCreatorPackage();
|
||||||
return ActivityManager.getService()
|
|
||||||
.getPackageForIntentSender(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// Should never happen.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -247,13 +239,7 @@ public class IntentSender implements Parcelable {
|
|||||||
* none associated with it.
|
* none associated with it.
|
||||||
*/
|
*/
|
||||||
public int getCreatorUid() {
|
public int getCreatorUid() {
|
||||||
try {
|
return getCachedInfo().getCreatorUid();
|
||||||
return ActivityManager.getService()
|
|
||||||
.getUidForIntentSender(mTarget);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// Should never happen.
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,14 +254,8 @@ public class IntentSender implements Parcelable {
|
|||||||
* none associated with it.
|
* none associated with it.
|
||||||
*/
|
*/
|
||||||
public UserHandle getCreatorUserHandle() {
|
public UserHandle getCreatorUserHandle() {
|
||||||
try {
|
int uid = getCachedInfo().getCreatorUid();
|
||||||
int uid = ActivityManager.getService()
|
return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
|
||||||
.getUidForIntentSender(mTarget);
|
|
||||||
return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// Should never happen.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -384,4 +364,16 @@ public class IntentSender implements Parcelable {
|
|||||||
public IntentSender(IBinder target) {
|
public IntentSender(IBinder target) {
|
||||||
mTarget = IIntentSender.Stub.asInterface(target);
|
mTarget = IIntentSender.Stub.asInterface(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PendingIntentInfo getCachedInfo() {
|
||||||
|
if (mCachedInfo == null) {
|
||||||
|
try {
|
||||||
|
mCachedInfo = ActivityManager.getService().getInfoForIntentSender(mTarget);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mCachedInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ import android.annotation.UserIdInt;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityClient;
|
import android.app.ActivityClient;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.ActivityManager.PendingIntentInfo;
|
||||||
import android.app.ActivityManager.RunningTaskInfo;
|
import android.app.ActivityManager.RunningTaskInfo;
|
||||||
import android.app.ActivityManagerInternal;
|
import android.app.ActivityManagerInternal;
|
||||||
import android.app.ActivityTaskManager.RootTaskInfo;
|
import android.app.ActivityTaskManager.RootTaskInfo;
|
||||||
@@ -4857,19 +4858,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
mPendingIntentController.cancelIntentSender(sender);
|
mPendingIntentController.cancelIntentSender(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPackageForIntentSender(IIntentSender pendingResult) {
|
|
||||||
if (!(pendingResult instanceof PendingIntentRecord)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
PendingIntentRecord res = (PendingIntentRecord)pendingResult;
|
|
||||||
return res.key.packageName;
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerIntentSenderCancelListener(IIntentSender sender, IResultReceiver receiver) {
|
public void registerIntentSenderCancelListener(IIntentSender sender, IResultReceiver receiver) {
|
||||||
mPendingIntentController.registerIntentSenderCancelListener(sender, receiver);
|
mPendingIntentController.registerIntentSenderCancelListener(sender, receiver);
|
||||||
@@ -4882,15 +4870,17 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUidForIntentSender(IIntentSender sender) {
|
public PendingIntentInfo getInfoForIntentSender(IIntentSender sender) {
|
||||||
if (sender instanceof PendingIntentRecord) {
|
if (sender instanceof PendingIntentRecord) {
|
||||||
try {
|
PendingIntentRecord res = (PendingIntentRecord) sender;
|
||||||
PendingIntentRecord res = (PendingIntentRecord)sender;
|
return new PendingIntentInfo(
|
||||||
return res.uid;
|
res.key.packageName,
|
||||||
} catch (ClassCastException e) {
|
res.uid,
|
||||||
}
|
(res.key.flags & PendingIntent.FLAG_IMMUTABLE) != 0,
|
||||||
|
res.key.type);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4915,15 +4905,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isIntentSenderImmutable(IIntentSender pendingResult) {
|
|
||||||
if (pendingResult instanceof PendingIntentRecord) {
|
|
||||||
final PendingIntentRecord res = (PendingIntentRecord) pendingResult;
|
|
||||||
return (res.key.flags & PendingIntent.FLAG_IMMUTABLE) != 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isIntentSenderAnActivity(IIntentSender pendingResult) {
|
public boolean isIntentSenderAnActivity(IIntentSender pendingResult) {
|
||||||
if (!(pendingResult instanceof PendingIntentRecord)) {
|
if (!(pendingResult instanceof PendingIntentRecord)) {
|
||||||
@@ -4940,33 +4921,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isIntentSenderAForegroundService(IIntentSender pendingResult) {
|
|
||||||
if (pendingResult instanceof PendingIntentRecord) {
|
|
||||||
final PendingIntentRecord res = (PendingIntentRecord) pendingResult;
|
|
||||||
return res.key.type == ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isIntentSenderAService(IIntentSender pendingResult) {
|
|
||||||
if (pendingResult instanceof PendingIntentRecord) {
|
|
||||||
final PendingIntentRecord res = (PendingIntentRecord) pendingResult;
|
|
||||||
return res.key.type == ActivityManager.INTENT_SENDER_SERVICE;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isIntentSenderABroadcast(IIntentSender pendingResult) {
|
|
||||||
if (pendingResult instanceof PendingIntentRecord) {
|
|
||||||
final PendingIntentRecord res = (PendingIntentRecord) pendingResult;
|
|
||||||
return res.key.type == ActivityManager.INTENT_SENDER_BROADCAST;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent getIntentForIntentSender(IIntentSender pendingResult) {
|
public Intent getIntentForIntentSender(IIntentSender pendingResult) {
|
||||||
enforceCallingPermission(Manifest.permission.GET_INTENT_SENDER_INTENT,
|
enforceCallingPermission(Manifest.permission.GET_INTENT_SENDER_INTENT,
|
||||||
|
|||||||
Reference in New Issue
Block a user