summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2020-02-10 08:46:26 -0800
committerPhilip P. Moltmann <moltmann@google.com>2020-02-12 18:51:53 +0000
commitee29509ecd73c3910011b2bdc12d1ef28fcb5a3d (patch)
tree88289fe02f2ffd203dd0468e829e42b56ea9118f
parent998c6ad176d4c419f52184842692c3009379d3f5 (diff)
Revert "Revert "Activity start: Send featureId from context->AppOpsManager""
This reverts commit e7421e92d947b09ca3cb9e6dfb66bbb27b9ed114. Exempt-From-Owner-Approval: revert-revert and only piping anyway Test: 1:1 revert-revert Bug: 136595429 Change-Id: I44e5fa2019f5604c6e2c08bdd1967129c64a90a7
-rw-r--r--apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java2
-rw-r--r--core/java/android/app/Activity.java10
-rw-r--r--core/java/android/app/ActivityManager.java4
-rw-r--r--core/java/android/app/ActivityManagerInternal.java15
-rw-r--r--core/java/android/app/ContextImpl.java85
-rw-r--r--core/java/android/app/IActivityManager.aidl35
-rw-r--r--core/java/android/app/IActivityTaskManager.aidl39
-rw-r--r--core/java/android/app/IAppTask.aidl2
-rw-r--r--core/java/android/app/Instrumentation.java15
-rw-r--r--core/java/android/app/PendingIntent.java24
-rw-r--r--core/java/android/content/pm/CrossProfileApps.java5
-rw-r--r--core/java/android/content/pm/ICrossProfileApps.aidl7
-rw-r--r--core/java/android/content/pm/ILauncherApps.aidl12
-rw-r--r--core/java/android/content/pm/InstantAppRequest.java10
-rw-r--r--core/java/android/content/pm/LauncherApps.java14
-rw-r--r--core/java/android/service/voice/VoiceInteractionSession.java4
-rw-r--r--core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java2
-rw-r--r--services/core/java/android/content/pm/PackageManagerInternal.java4
-rw-r--r--services/core/java/com/android/server/UiModeManagerService.java5
-rw-r--r--services/core/java/com/android/server/am/ActiveServices.java27
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java210
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerShellCommand.java15
-rw-r--r--services/core/java/com/android/server/am/BroadcastFilter.java4
-rw-r--r--services/core/java/com/android/server/am/BroadcastQueue.java38
-rw-r--r--services/core/java/com/android/server/am/BroadcastRecord.java11
-rw-r--r--services/core/java/com/android/server/am/PendingIntentController.java11
-rw-r--r--services/core/java/com/android/server/am/PendingIntentRecord.java43
-rw-r--r--services/core/java/com/android/server/am/PreBootBroadcaster.java4
-rw-r--r--services/core/java/com/android/server/am/UserController.java8
-rw-r--r--services/core/java/com/android/server/om/OverlayManagerService.java6
-rw-r--r--services/core/java/com/android/server/pm/CrossProfileAppsServiceImpl.java23
-rw-r--r--services/core/java/com/android/server/pm/InstantAppResolver.java12
-rw-r--r--services/core/java/com/android/server/pm/LauncherAppsService.java29
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java39
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java6
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java28
-rw-r--r--services/core/java/com/android/server/wm/ActivityStack.java11
-rw-r--r--services/core/java/com/android/server/wm/ActivityStackSupervisor.java45
-rw-r--r--services/core/java/com/android/server/wm/ActivityStartController.java41
-rw-r--r--services/core/java/com/android/server/wm/ActivityStartInterceptor.java9
-rw-r--r--services/core/java/com/android/server/wm/ActivityStarter.java42
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java25
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerService.java138
-rw-r--r--services/core/java/com/android/server/wm/AppTaskImpl.java3
-rw-r--r--services/core/java/com/android/server/wm/RecentTasks.java9
-rw-r--r--services/core/java/com/android/server/wm/RecentsAnimation.java7
-rw-r--r--services/core/java/com/android/server/wm/Task.java46
-rw-r--r--services/core/java/com/android/server/wm/TaskTile.java9
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java5
-rw-r--r--services/tests/servicestests/src/com/android/server/am/BroadcastRecordTest.java1
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java3
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/CrossProfileAppsServiceImplTest.java27
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java4
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java14
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java18
-rw-r--r--tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java3
65 files changed, 789 insertions, 516 deletions
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
index 661f32f35cb2..c458d1190e51 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
@@ -670,7 +670,7 @@ public class UserLifecycleTests {
private void startApp(int userId, String packageName) throws RemoteException {
final Context context = InstrumentationRegistry.getContext();
final WaitResult result = ActivityTaskManager.getService().startActivityAndWait(null,
- context.getPackageName(),
+ context.getPackageName(), context.getFeatureId(),
context.getPackageManager().getLaunchIntentForPackage(packageName), null, null,
null, 0, 0, null, null, userId);
attestTrue("User " + userId + " failed to start " + packageName,
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 642f51b6bb63..2319dd2c168f 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -5810,9 +5810,9 @@ public class Activity extends ContextThemeWrapper
intent.prepareToLeaveProcess(this);
result = ActivityTaskManager.getService()
.startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
- intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken,
- mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED,
- null, options);
+ getFeatureId(), intent,
+ intent.resolveTypeIfNeeded(getContentResolver()), mToken, mEmbeddedID,
+ requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, options);
} catch (RemoteException e) {
// Empty
}
@@ -6606,8 +6606,8 @@ public class Activity extends ContextThemeWrapper
try {
data.prepareToLeaveProcess(this);
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName, getFeatureId(),
mParent == null ? mToken : mParent.mToken,
mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null,
getUserId());
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 7ee44053d4d5..2838ad829f6b 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -4316,8 +4316,8 @@ public class ActivityManager {
*/
public static void broadcastStickyIntent(Intent intent, int appOp, int userId) {
try {
- getService().broadcastIntent(
- null, intent, null, null, Activity.RESULT_OK, null, null,
+ getService().broadcastIntentWithFeature(
+ null, null, intent, null, null, Activity.RESULT_OK, null, null,
null /*permission*/, appOp, null, false, true, userId);
} catch (RemoteException ex) {
}
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index c60f7bd29ce8..ec110435d95c 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -269,13 +269,16 @@ public abstract class ActivityManagerInternal {
public abstract void tempWhitelistForPendingIntent(int callerPid, int callerUid, int targetUid,
long duration, String tag);
- public abstract int broadcastIntentInPackage(String packageName, int uid, int realCallingUid,
- int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo,
- int resultCode, String resultData, Bundle resultExtras, String requiredPermission,
- Bundle bOptions, boolean serialized, boolean sticky, @UserIdInt int userId,
- boolean allowBackgroundActivityStarts);
+
+ public abstract int broadcastIntentInPackage(String packageName, @Nullable String featureId,
+ int uid, int realCallingUid, int realCallingPid, Intent intent, String resolvedType,
+ IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras,
+ String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky,
+ @UserIdInt int userId, boolean allowBackgroundActivityStarts);
+
public abstract ComponentName startServiceInPackage(int uid, Intent service,
- String resolvedType, boolean fgRequired, String callingPackage, @UserIdInt int userId,
+ String resolvedType, boolean fgRequired, String callingPackage,
+ @Nullable String callingFeatureId, @UserIdInt int userId,
boolean allowBackgroundActivityStarts) throws TransactionTooLargeException;
public abstract void disconnectActivityFromServices(Object connectionHolder);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 57cd8941a398..6b5bfda92cd0 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1020,7 +1020,7 @@ class ContextImpl extends Context {
public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) {
try {
ActivityTaskManager.getService().startActivityAsUser(
- mMainThread.getApplicationThread(), getBasePackageName(), intent,
+ mMainThread.getApplicationThread(), getBasePackageName(), getFeatureId(), intent,
intent.resolveTypeIfNeeded(getContentResolver()),
null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options,
user.getIdentifier());
@@ -1102,8 +1102,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, false,
getUserId());
} catch (RemoteException e) {
@@ -1119,8 +1119,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
null, false, false, getUserId());
} catch (RemoteException e) {
@@ -1134,8 +1134,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
null, false, false, getUserId());
} catch (RemoteException e) {
@@ -1149,8 +1149,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
null, false, false, user.getIdentifier());
} catch (RemoteException e) {
@@ -1166,8 +1166,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
options, false, false, getUserId());
} catch (RemoteException e) {
@@ -1183,8 +1183,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false,
getUserId());
} catch (RemoteException e) {
@@ -1200,8 +1200,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
null, true, false, getUserId());
} catch (RemoteException e) {
@@ -1263,8 +1263,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, rd,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd,
initialCode, initialData, initialExtras, receiverPermissions, appOp,
options, true, false, getUserId());
} catch (RemoteException e) {
@@ -1277,9 +1277,10 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(mMainThread.getApplicationThread(),
- intent, resolvedType, null, Activity.RESULT_OK, null, null, null,
- AppOpsManager.OP_NONE, null, false, false, user.getIdentifier());
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
+ Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, false,
+ user.getIdentifier());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1299,8 +1300,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
options, false, false, user.getIdentifier());
} catch (RemoteException e) {
@@ -1316,8 +1317,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false,
user.getIdentifier());
} catch (RemoteException e) {
@@ -1367,8 +1368,8 @@ class ContextImpl extends Context {
: new String[] {receiverPermission};
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, rd,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd,
initialCode, initialData, initialExtras, receiverPermissions,
appOp, options, true, false, user.getIdentifier());
} catch (RemoteException e) {
@@ -1408,8 +1409,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, true,
getUserId());
} catch (RemoteException e) {
@@ -1444,8 +1445,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, rd,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd,
initialCode, initialData, initialExtras, null,
AppOpsManager.OP_NONE, null, true, true, getUserId());
} catch (RemoteException e) {
@@ -1476,8 +1477,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, true,
user.getIdentifier());
} catch (RemoteException e) {
@@ -1491,8 +1492,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, null,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null,
Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, options, false, true,
user.getIdentifier());
} catch (RemoteException e) {
@@ -1526,8 +1527,8 @@ class ContextImpl extends Context {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.prepareToLeaveProcess(this);
- ActivityManager.getService().broadcastIntent(
- mMainThread.getApplicationThread(), intent, resolvedType, rd,
+ ActivityManager.getService().broadcastIntentWithFeature(
+ mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd,
initialCode, initialData, initialExtras, null,
AppOpsManager.OP_NONE, null, true, true, user.getIdentifier());
} catch (RemoteException e) {
@@ -1612,9 +1613,9 @@ class ContextImpl extends Context {
}
}
try {
- final Intent intent = ActivityManager.getService().registerReceiver(
- mMainThread.getApplicationThread(), mBasePackageName, rd, filter,
- broadcastPermission, userId, flags);
+ final Intent intent = ActivityManager.getService().registerReceiverWithFeature(
+ mMainThread.getApplicationThread(), mBasePackageName, getFeatureId(), rd,
+ filter, broadcastPermission, userId, flags);
if (intent != null) {
intent.setExtrasClassLoader(getClassLoader());
intent.prepareToEnterProcess();
@@ -1687,9 +1688,9 @@ class ContextImpl extends Context {
validateServiceIntent(service);
service.prepareToLeaveProcess(this);
ComponentName cn = ActivityManager.getService().startService(
- mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(
- getContentResolver()), requireForeground,
- getOpPackageName(), user.getIdentifier());
+ mMainThread.getApplicationThread(), service,
+ service.resolveTypeIfNeeded(getContentResolver()), requireForeground,
+ getOpPackageName(), getFeatureId(), user.getIdentifier());
if (cn != null) {
if (cn.getPackageName().equals("!")) {
throw new SecurityException(
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index cb6a476fb617..83fa9d7ea796 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -104,25 +104,38 @@ interface IActivityManager {
// Special low-level communication with activity manager.
void handleApplicationCrash(in IBinder app,
in ApplicationErrorReport.ParcelableCrashInfo crashInfo);
- @UnsupportedAppUsage
+ /** @deprecated Use {@link #startActivityWithFeature} instead */
+ @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link android.content.Context#startActivity(android.content.Intent)} instead")
int startActivity(in IApplicationThread caller, in String callingPackage, in Intent intent,
in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
int flags, in ProfilerInfo profilerInfo, in Bundle options);
+ int startActivityWithFeature(in IApplicationThread caller, in String callingPackage,
+ in String callingFeatureId, in Intent intent, in String resolvedType,
+ in IBinder resultTo, in String resultWho, int requestCode, int flags,
+ in ProfilerInfo profilerInfo, in Bundle options);
@UnsupportedAppUsage
void unhandledBack();
@UnsupportedAppUsage
boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)} instead")
Intent registerReceiver(in IApplicationThread caller, in String callerPackage,
in IIntentReceiver receiver, in IntentFilter filter,
in String requiredPermission, int userId, int flags);
+ Intent registerReceiverWithFeature(in IApplicationThread caller, in String callerPackage,
+ in String callingFeatureId, in IIntentReceiver receiver, in IntentFilter filter,
+ in String requiredPermission, int userId, int flags);
@UnsupportedAppUsage
void unregisterReceiver(in IIntentReceiver receiver);
- @UnsupportedAppUsage
+ /** @deprecated Use {@link #broadcastIntentWithFeature} instead */
+ @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link android.content.Context#sendBroadcast(android.content.Intent)} instead")
int broadcastIntent(in IApplicationThread caller, in Intent intent,
in String resolvedType, in IIntentReceiver resultTo, int resultCode,
in String resultData, in Bundle map, in String[] requiredPermissions,
int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
+ int broadcastIntentWithFeature(in IApplicationThread caller, in String callingFeatureId,
+ in Intent intent, in String resolvedType, in IIntentReceiver resultTo, int resultCode,
+ in String resultData, in Bundle map, in String[] requiredPermissions,
+ int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
void unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId);
@UnsupportedAppUsage
oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
@@ -145,7 +158,8 @@ interface IActivityManager {
boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta);
PendingIntent getRunningServiceControlPanel(in ComponentName service);
ComponentName startService(in IApplicationThread caller, in Intent service,
- in String resolvedType, boolean requireForeground, in String callingPackage, int userId);
+ in String resolvedType, boolean requireForeground, in String callingPackage,
+ in String callingFeatureId, int userId);
@UnsupportedAppUsage
int stopService(in IApplicationThread caller, in Intent service,
in String resolvedType, int userId);
@@ -226,10 +240,14 @@ interface IActivityManager {
ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
@UnsupportedAppUsage
oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res);
- @UnsupportedAppUsage
+ /** @deprecated Use {@link #getIntentSenderWithFeature} instead */
+ @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link PendingIntent#getIntentSender()} instead")
IIntentSender getIntentSender(int type, in String packageName, in IBinder token,
in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes,
int flags, in Bundle options, int userId);
+ IIntentSender getIntentSenderWithFeature(int type, in String packageName, in String featureId,
+ in IBinder token, in String resultWho, int requestCode, in Intent[] intents,
+ in String[] resolvedTypes, int flags, in Bundle options, int userId);
void cancelIntentSender(in IIntentSender sender);
String getPackageForIntentSender(in IIntentSender sender);
void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
@@ -355,11 +373,16 @@ interface IActivityManager {
boolean isIntentSenderAnActivity(in IIntentSender sender);
boolean isIntentSenderAForegroundService(in IIntentSender sender);
boolean isIntentSenderABroadcast(in IIntentSender sender);
- @UnsupportedAppUsage
+ /** @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")
int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
int requestCode, int flags, in ProfilerInfo profilerInfo,
in Bundle options, int userId);
+ int startActivityAsUserWithFeature(in IApplicationThread caller, in String callingPackage,
+ in String callingFeatureId, in Intent intent, in String resolvedType,
+ in IBinder resultTo, in String resultWho, int requestCode, int flags,
+ in ProfilerInfo profilerInfo, in Bundle options, int userId);
@UnsupportedAppUsage
int stopUser(int userid, boolean force, in IStopUserCallback callback);
/**
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
index be2f144c2fe8..180507cd7e9c 100644
--- a/core/java/android/app/IActivityTaskManager.aidl
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -85,16 +85,17 @@ import java.util.List;
* {@hide}
*/
interface IActivityTaskManager {
- int startActivity(in IApplicationThread caller, in String callingPackage, in Intent intent,
- in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
+ int startActivity(in IApplicationThread caller, in String callingPackage,
+ in String callingFeatureId, in Intent intent, in String resolvedType,
+ in IBinder resultTo, in String resultWho, int requestCode,
int flags, in ProfilerInfo profilerInfo, in Bundle options);
int startActivities(in IApplicationThread caller, in String callingPackage,
- in Intent[] intents, in String[] resolvedTypes, in IBinder resultTo,
- in Bundle options, int userId);
+ in String callingFeatureId, in Intent[] intents, in String[] resolvedTypes,
+ in IBinder resultTo, in Bundle options, int userId);
int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
- in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
- int requestCode, int flags, in ProfilerInfo profilerInfo,
- in Bundle options, int userId);
+ in String callingFeatureId, in Intent intent, in String resolvedType,
+ in IBinder resultTo, in String resultWho, int requestCode, int flags,
+ in ProfilerInfo profilerInfo, in Bundle options, int userId);
boolean startNextMatchingActivity(in IBinder callingActivity,
in Intent intent, in Bundle options);
int startActivityIntentSender(in IApplicationThread caller,
@@ -102,19 +103,19 @@ interface IActivityTaskManager {
in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
int flagsMask, int flagsValues, in Bundle options);
WaitResult startActivityAndWait(in IApplicationThread caller, in String callingPackage,
- in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
- int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options,
- int userId);
+ in String callingFeatureId, in Intent intent, in String resolvedType,
+ in IBinder resultTo, in String resultWho, int requestCode, int flags,
+ in ProfilerInfo profilerInfo, in Bundle options, int userId);
int startActivityWithConfig(in IApplicationThread caller, in String callingPackage,
- in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
- int requestCode, int startFlags, in Configuration newConfig,
- in Bundle options, int userId);
- int startVoiceActivity(in String callingPackage, int callingPid, int callingUid,
- in Intent intent, in String resolvedType, in IVoiceInteractionSession session,
- in IVoiceInteractor interactor, int flags, in ProfilerInfo profilerInfo,
- in Bundle options, int userId);
- int startAssistantActivity(in String callingPackage, int callingPid, int callingUid,
- in Intent intent, in String resolvedType, in Bundle options, int userId);
+ in String callingFeatureId, in Intent intent, in String resolvedType,
+ in IBinder resultTo, in String resultWho, int requestCode, int startFlags,
+ in Configuration newConfig, in Bundle options, int userId);
+ int startVoiceActivity(in String callingPackage, in String callingFeatureId, int callingPid,
+ int callingUid, in Intent intent, in String resolvedType,
+ in IVoiceInteractionSession session, in IVoiceInteractor interactor, int flags,
+ in ProfilerInfo profilerInfo, in Bundle options, int userId);
+ int startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid,
+ int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId);
void startRecentsActivity(in Intent intent, in IAssistDataReceiver assistDataReceiver,
in IRecentsAnimationRunner recentsAnimationRunner);
int startActivityFromRecents(int taskId, in Bundle options);
diff --git a/core/java/android/app/IAppTask.aidl b/core/java/android/app/IAppTask.aidl
index 3ce71908bbfd..f41d705e2ba7 100644
--- a/core/java/android/app/IAppTask.aidl
+++ b/core/java/android/app/IAppTask.aidl
@@ -27,7 +27,7 @@ interface IAppTask {
@UnsupportedAppUsage
ActivityManager.RecentTaskInfo getTaskInfo();
void moveToFront(in IApplicationThread appThread, in String callingPackage);
- int startActivity(IBinder whoThread, String callingPackage,
+ int startActivity(IBinder whoThread, String callingPackage, String callingFeatureId,
in Intent intent, String resolvedType, in Bundle options);
void setExcludeFromRecents(boolean exclude);
}
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index 62c905d8c2c6..18932c6b0784 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1721,7 +1721,7 @@ public class Instrumentation {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
int result = ActivityTaskManager.getService()
- .startActivity(whoThread, who.getBasePackageName(), intent,
+ .startActivity(whoThread, who.getBasePackageName(), who.getFeatureId(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
requestCode, 0, null, options);
@@ -1794,8 +1794,8 @@ public class Instrumentation {
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
}
int result = ActivityTaskManager.getService()
- .startActivities(whoThread, who.getBasePackageName(), intents, resolvedTypes,
- token, options, userId);
+ .startActivities(whoThread, who.getBasePackageName(), who.getFeatureId(), intents,
+ resolvedTypes, token, options, userId);
checkStartActivityResult(result, intents[0]);
return result;
} catch (RemoteException e) {
@@ -1861,7 +1861,7 @@ public class Instrumentation {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
int result = ActivityTaskManager.getService()
- .startActivity(whoThread, who.getBasePackageName(), intent,
+ .startActivity(whoThread, who.getBasePackageName(), who.getFeatureId(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target, requestCode, 0, null, options);
checkStartActivityResult(result, intent);
@@ -1928,8 +1928,8 @@ public class Instrumentation {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
int result = ActivityTaskManager.getService()
- .startActivityAsUser(whoThread, who.getBasePackageName(), intent,
- intent.resolveTypeIfNeeded(who.getContentResolver()),
+ .startActivityAsUser(whoThread, who.getBasePackageName(), who.getFeatureId(),
+ intent, intent.resolveTypeIfNeeded(who.getContentResolver()),
token, resultWho,
requestCode, 0, null, options, user.getIdentifier());
checkStartActivityResult(result, intent);
@@ -2022,7 +2022,8 @@ public class Instrumentation {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
int result = appTask.startActivity(whoThread.asBinder(), who.getBasePackageName(),
- intent, intent.resolveTypeIfNeeded(who.getContentResolver()), options);
+ who.getFeatureId(), intent,
+ intent.resolveTypeIfNeeded(who.getContentResolver()), options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
throw new RuntimeException("Failure from system", e);
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index b8348c7d4f22..f68c929144c8 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -354,8 +354,8 @@ public final class PendingIntent implements Parcelable {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(context);
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(),
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null,
flags, options, context.getUserId());
@@ -380,8 +380,8 @@ public final class PendingIntent implements Parcelable {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(context);
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(),
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null,
flags, options, user.getIdentifier());
@@ -497,8 +497,8 @@ public final class PendingIntent implements Parcelable {
}
try {
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(),
null, null, requestCode, intents, resolvedTypes, flags, options,
context.getUserId());
return target != null ? new PendingIntent(target) : null;
@@ -523,8 +523,8 @@ public final class PendingIntent implements Parcelable {
}
try {
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(),
null, null, requestCode, intents, resolvedTypes,
flags, options, user.getIdentifier());
return target != null ? new PendingIntent(target) : null;
@@ -575,8 +575,8 @@ public final class PendingIntent implements Parcelable {
try {
intent.prepareToLeaveProcess(context);
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- ActivityManager.INTENT_SENDER_BROADCAST, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ ActivityManager.INTENT_SENDER_BROADCAST, packageName, context.getFeatureId(),
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null,
flags, null, userHandle.getIdentifier());
@@ -654,8 +654,8 @@ public final class PendingIntent implements Parcelable {
try {
intent.prepareToLeaveProcess(context);
IIntentSender target =
- ActivityManager.getService().getIntentSender(
- serviceKind, packageName,
+ ActivityManager.getService().getIntentSenderWithFeature(
+ serviceKind, packageName, context.getFeatureId(),
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null,
flags, null, context.getUserId());
diff --git a/core/java/android/content/pm/CrossProfileApps.java b/core/java/android/content/pm/CrossProfileApps.java
index edc20d9f65ad..2ba2840d8c70 100644
--- a/core/java/android/content/pm/CrossProfileApps.java
+++ b/core/java/android/content/pm/CrossProfileApps.java
@@ -87,6 +87,7 @@ public class CrossProfileApps {
mService.startActivityAsUser(
mContext.getIApplicationThread(),
mContext.getPackageName(),
+ mContext.getFeatureId(),
component,
targetUser.getIdentifier(),
true);
@@ -114,6 +115,7 @@ public class CrossProfileApps {
mService.startActivityAsUserByIntent(
mContext.getIApplicationThread(),
mContext.getPackageName(),
+ mContext.getFeatureId(),
intent,
targetUser.getIdentifier());
} catch (RemoteException ex) {
@@ -139,7 +141,8 @@ public class CrossProfileApps {
public void startActivity(@NonNull ComponentName component, @NonNull UserHandle targetUser) {
try {
mService.startActivityAsUser(mContext.getIApplicationThread(),
- mContext.getPackageName(), component, targetUser.getIdentifier(), false);
+ mContext.getPackageName(), mContext.getFeatureId(), component,
+ targetUser.getIdentifier(), false);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
diff --git a/core/java/android/content/pm/ICrossProfileApps.aidl b/core/java/android/content/pm/ICrossProfileApps.aidl
index a69b9881aa01..98bf2ddd0e1b 100644
--- a/core/java/android/content/pm/ICrossProfileApps.aidl
+++ b/core/java/android/content/pm/ICrossProfileApps.aidl
@@ -28,13 +28,14 @@ import android.os.UserHandle;
*/
interface ICrossProfileApps {
void startActivityAsUser(in IApplicationThread caller, in String callingPackage,
- in ComponentName component, int userId, boolean launchMainActivity);
+ in String callingFeatureId, in ComponentName component, int userId,
+ boolean launchMainActivity);
void startActivityAsUserByIntent(in IApplicationThread caller, in String callingPackage,
- in Intent intent, int userId);
+ in String callingFeatureId, in Intent intent, int userId);
List<UserHandle> getTargetUserProfiles(in String callingPackage);
boolean canInteractAcrossProfiles(in String callingPackage);
boolean canRequestInteractAcrossProfiles(in String callingPackage);
void setInteractAcrossProfilesAppOp(in String packageName, int newMode);
boolean canConfigureInteractAcrossProfiles(in String packageName);
void resetInteractAcrossProfilesAppOps(in List<String> packageNames);
-} \ No newline at end of file
+}
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl
index 38a9ac4a0d05..b5f4f806d244 100644
--- a/core/java/android/content/pm/ILauncherApps.aidl
+++ b/core/java/android/content/pm/ILauncherApps.aidl
@@ -49,13 +49,13 @@ interface ILauncherApps {
ActivityInfo resolveActivity(
String callingPackage, in ComponentName component, in UserHandle user);
void startSessionDetailsActivityAsUser(in IApplicationThread caller, String callingPackage,
- in PackageInstaller.SessionInfo sessionInfo, in Rect sourceBounds, in Bundle opts,
- in UserHandle user);
+ String callingFeatureId, in PackageInstaller.SessionInfo sessionInfo,
+ in Rect sourceBounds, in Bundle opts, in UserHandle user);
void startActivityAsUser(in IApplicationThread caller, String callingPackage,
- in ComponentName component, in Rect sourceBounds,
+ String callingFeatureId, in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
- void showAppDetailsAsUser(in IApplicationThread caller,
- String callingPackage, in ComponentName component, in Rect sourceBounds,
+ void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage,
+ String callingFeatureId, in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
boolean isPackageEnabled(String callingPackage, String packageName, in UserHandle user);
Bundle getSuspendedPackageLauncherExtras(String packageName, in UserHandle user);
@@ -72,7 +72,7 @@ interface ILauncherApps {
int flags, in UserHandle user);
void pinShortcuts(String callingPackage, String packageName, in List<String> shortcutIds,
in UserHandle user);
- boolean startShortcut(String callingPackage, String packageName, String id,
+ boolean startShortcut(String callingPackage, String packageName, String featureId, String id,
in Rect sourceBounds, in Bundle startActivityOptions, int userId);
int getShortcutIconResId(String callingPackage, String packageName, String id,
diff --git a/core/java/android/content/pm/InstantAppRequest.java b/core/java/android/content/pm/InstantAppRequest.java
index f692db1f0443..84f5021f0538 100644
--- a/core/java/android/content/pm/InstantAppRequest.java
+++ b/core/java/android/content/pm/InstantAppRequest.java
@@ -35,6 +35,8 @@ public final class InstantAppRequest {
public final String resolvedType;
/** The name of the package requesting the instant application */
public final String callingPackage;
+ /** The feature in the package requesting the instant application */
+ public final String callingFeatureId;
/** Whether or not the requesting package was an instant app */
public final boolean isRequesterInstantApp;
/** ID of the user requesting the instant application */
@@ -57,13 +59,15 @@ public final class InstantAppRequest {
public final String token;
public InstantAppRequest(AuxiliaryResolveInfo responseObj, Intent origIntent,
- String resolvedType, String callingPackage, boolean isRequesterInstantApp,
- int userId, Bundle verificationBundle, boolean resolveForStart,
- @Nullable int[] hostDigestPrefixSecure, @NonNull String token) {
+ String resolvedType, String callingPackage, @Nullable String callingFeatureId,
+ boolean isRequesterInstantApp, int userId, Bundle verificationBundle,
+ boolean resolveForStart, @Nullable int[] hostDigestPrefixSecure,
+ @NonNull String token) {
this.responseObj = responseObj;
this.origIntent = origIntent;
this.resolvedType = resolvedType;
this.callingPackage = callingPackage;
+ this.callingFeatureId = callingFeatureId;
this.isRequesterInstantApp = isRequesterInstantApp;
this.userId = userId;
this.verificationBundle = verificationBundle;
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index d2532783f47c..271d5e44d5db 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -715,7 +715,7 @@ public class LauncherApps {
}
try {
mService.startActivityAsUser(mContext.getIApplicationThread(),
- mContext.getPackageName(),
+ mContext.getPackageName(), mContext.getFeatureId(),
component, sourceBounds, opts, user);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
@@ -733,8 +733,8 @@ public class LauncherApps {
@Nullable Rect sourceBounds, @Nullable Bundle opts) {
try {
mService.startSessionDetailsActivityAsUser(mContext.getIApplicationThread(),
- mContext.getPackageName(), sessionInfo, sourceBounds, opts,
- sessionInfo.getUser());
+ mContext.getPackageName(), mContext.getFeatureId(), sessionInfo, sourceBounds,
+ opts, sessionInfo.getUser());
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -754,7 +754,7 @@ public class LauncherApps {
logErrorForInvalidProfileAccess(user);
try {
mService.showAppDetailsAsUser(mContext.getIApplicationThread(),
- mContext.getPackageName(),
+ mContext.getPackageName(), mContext.getFeatureId(),
component, sourceBounds, opts, user);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
@@ -1346,9 +1346,9 @@ public class LauncherApps {
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
int userId) {
try {
- final boolean success =
- mService.startShortcut(mContext.getPackageName(), packageName, shortcutId,
- sourceBounds, startActivityOptions, userId);
+ final boolean success = mService.startShortcut(mContext.getPackageName(), packageName,
+ null /* default featureId */, shortcutId, sourceBounds, startActivityOptions,
+ userId);
if (!success) {
throw new ActivityNotFoundException("Shortcut could not be started");
}
diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java
index 36f2c6267622..8e6f77b2fd0c 100644
--- a/core/java/android/service/voice/VoiceInteractionSession.java
+++ b/core/java/android/service/voice/VoiceInteractionSession.java
@@ -1314,7 +1314,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(mContext);
int res = mSystemService.startVoiceActivity(mToken, intent,
- intent.resolveType(mContext.getContentResolver()));
+ intent.resolveType(mContext.getContentResolver()), mContext.getFeatureId());
Instrumentation.checkStartActivityResult(res, intent);
} catch (RemoteException e) {
}
@@ -1342,7 +1342,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(mContext);
int res = mSystemService.startAssistantActivity(mToken, intent,
- intent.resolveType(mContext.getContentResolver()));
+ intent.resolveType(mContext.getContentResolver()), mContext.getFeatureId());
Instrumentation.checkStartActivityResult(res, intent);
} catch (RemoteException e) {
}
diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
index f3b6d292623d..417e23f56448 100644
--- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
+++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
@@ -38,8 +38,10 @@ interface IVoiceInteractionManagerService {
IVoiceInteractor interactor);
boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags);
boolean hideSessionFromSession(IBinder token);
- int startVoiceActivity(IBinder token, in Intent intent, String resolvedType);
- int startAssistantActivity(IBinder token, in Intent intent, String resolvedType);
+ int startVoiceActivity(IBinder token, in Intent intent, String resolvedType,
+ String callingFeatureId);
+ int startAssistantActivity(IBinder token, in Intent intent, String resolvedType,
+ String callingFeatureId);
void setKeepAwake(IBinder token, boolean keepAwake);
void closeSystemDialogs(IBinder token);
void finish(IBinder token);
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
index 6498b9161be7..ae380b72f5e0 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
@@ -93,6 +93,7 @@ public class WorkLockActivityController {
return mIatm.startActivityAsUser(
mContext.getIApplicationThread() /*caller*/,
mContext.getBasePackageName() /*callingPackage*/,
+ mContext.getFeatureId() /*callingFeatureId*/,
intent /*intent*/,
intent.resolveTypeIfNeeded(mContext.getContentResolver()) /*resolvedType*/,
null /*resultTo*/,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index d3e44eaf17b1..72dfa18ca991 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -492,7 +492,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
try {
result = ActivityTaskManager.getService().startActivityAsUser(
null, getContext().getBasePackageName(),
- intent,
+ getContext().getFeatureId(), intent,
intent.resolveTypeIfNeeded(getContext().getContentResolver()),
null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, o.toBundle(),
UserHandle.CURRENT.getIdentifier());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index c68d9942419b..4f01cc191acd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -2567,7 +2567,7 @@ public class StatusBar extends SystemUI implements DemoMode,
}
try {
result = ActivityTaskManager.getService().startActivityAsUser(
- null, mContext.getBasePackageName(),
+ null, mContext.getBasePackageName(), mContext.getFeatureId(),
intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
index d26ae6aaad79..3439fe53c48f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
@@ -119,6 +119,7 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
doReturn(code).when(mIActivityTaskManager).startActivityAsUser(
eq((IApplicationThread) null),
eq((String) null),
+ eq((String) null),
any(Intent.class),
eq((String) null),
eq((IBinder) null),
@@ -134,6 +135,7 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
verify(mIActivityTaskManager).startActivityAsUser(
eq((IApplicationThread) null),
eq((String) null),
+ eq((String) null),
any(Intent.class),
eq((String) null),
eq((IBinder) null),
diff --git a/services/core/java/android/content/pm/PackageManagerInternal.java b/services/core/java/android/content/pm/PackageManagerInternal.java
index bdcd832e4f4a..63d092456a26 100644
--- a/services/core/java/android/content/pm/PackageManagerInternal.java
+++ b/services/core/java/android/content/pm/PackageManagerInternal.java
@@ -396,6 +396,7 @@ public abstract class PackageManagerInternal {
* @param origIntent The original intent that triggered ephemeral resolution
* @param resolvedType The resolved type of the intent
* @param callingPkg The app requesting the ephemeral application
+ * @param callingFeatureId The feature in the package
* @param isRequesterInstantApp Whether or not the app requesting the ephemeral application
* is an instant app
* @param verificationBundle Optional bundle to pass to the installer for additional
@@ -404,7 +405,8 @@ public abstract class PackageManagerInternal {
*/
public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
Intent origIntent, String resolvedType, String callingPkg,
- boolean isRequesterInstantApp, Bundle verificationBundle, int userId);
+ @Nullable String callingFeatureId, boolean isRequesterInstantApp,
+ Bundle verificationBundle, int userId);
/**
* Grants implicit access based on an interaction between two apps. This grants the target app
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java
index b994e6c58e64..0eedf8a1f468 100644
--- a/services/core/java/com/android/server/UiModeManagerService.java
+++ b/services/core/java/com/android/server/UiModeManagerService.java
@@ -1261,8 +1261,9 @@ final class UiModeManagerService extends SystemService {
if (Sandman.shouldStartDockApp(getContext(), homeIntent)) {
try {
int result = ActivityTaskManager.getService().startActivityWithConfig(
- null, getContext().getBasePackageName(), homeIntent, null, null, null,
- 0, 0, mConfiguration, null, UserHandle.USER_CURRENT);
+ null, getContext().getBasePackageName(), getContext().getFeatureId(),
+ homeIntent, null, null, null, 0, 0, mConfiguration, null,
+ UserHandle.USER_CURRENT);
if (ActivityManager.isStartResultSuccessful(result)) {
dockAppStarted = true;
} else if (result != ActivityManager.START_INTENT_NOT_RESOLVED) {
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 982466d82d38..97b5eaaca756 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -417,22 +417,23 @@ public final class ActiveServices {
}
private boolean appRestrictedAnyInBackground(final int uid, final String packageName) {
- final int mode = mAm.mAppOpsService.checkOperation(
+ final int mode = mAm.getAppOpsManager().checkOpNoThrow(
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName);
return (mode != AppOpsManager.MODE_ALLOWED);
}
ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType,
- int callingPid, int callingUid, boolean fgRequired, String callingPackage, final int userId)
+ int callingPid, int callingUid, boolean fgRequired, String callingPackage,
+ @Nullable String callingFeatureId, final int userId)
throws TransactionTooLargeException {
return startServiceLocked(caller, service, resolvedType, callingPid, callingUid, fgRequired,
- callingPackage, userId, false);
+ callingPackage, callingFeatureId, userId, false);
}
ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType,
int callingPid, int callingUid, boolean fgRequired, String callingPackage,
- final int userId, boolean allowBackgroundActivityStarts)
- throws TransactionTooLargeException {
+ @Nullable String callingFeatureId, final int userId,
+ boolean allowBackgroundActivityStarts) throws TransactionTooLargeException {
if (DEBUG_DELAYED_STARTS) Slog.v(TAG_SERVICE, "startService: " + service
+ " type=" + resolvedType + " args=" + service.getExtras());
@@ -488,7 +489,7 @@ public final class ActiveServices {
// If this is a direct-to-foreground start, make sure it is allowed as per the app op.
boolean forceSilentAbort = false;
if (fgRequired) {
- final int mode = mAm.mAppOpsService.checkOperation(
+ final int mode = mAm.getAppOpsManager().checkOpNoThrow(
AppOpsManager.OP_START_FOREGROUND, r.appInfo.uid, r.packageName);
switch (mode) {
case AppOpsManager.MODE_ALLOWED:
@@ -566,7 +567,7 @@ public final class ActiveServices {
// review is completed.
// XXX This is not dealing with fgRequired!
- if (!requestStartTargetPermissionsReviewIfNeededLocked(r, callingPackage,
+ if (!requestStartTargetPermissionsReviewIfNeededLocked(r, callingPackage, callingFeatureId,
callingUid, service, callerFg, userId)) {
return null;
}
@@ -673,8 +674,8 @@ public final class ActiveServices {
}
private boolean requestStartTargetPermissionsReviewIfNeededLocked(ServiceRecord r,
- String callingPackage, int callingUid, Intent service, boolean callerFg,
- final int userId) {
+ String callingPackage, @Nullable String callingFeatureId, int callingUid,
+ Intent service, boolean callerFg, final int userId) {
if (mAm.getPackageManagerInternalLocked().isPermissionsReviewRequired(
r.packageName, r.userId)) {
@@ -686,7 +687,7 @@ public final class ActiveServices {
}
IIntentSender target = mAm.mPendingIntentController.getIntentSender(
- ActivityManager.INTENT_SENDER_SERVICE, callingPackage,
+ ActivityManager.INTENT_SENDER_SERVICE, callingPackage, callingFeatureId,
callingUid, userId, null, null, 0, new Intent[]{service},
new String[]{service.resolveType(mAm.mContext.getContentResolver())},
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT
@@ -1287,7 +1288,7 @@ public final class ActiveServices {
}
// Instant apps need permission to create foreground services.
if (r.appInfo.isInstantApp()) {
- final int mode = mAm.mAppOpsService.checkOperation(
+ final int mode = mAm.getAppOpsManager().checkOpNoThrow(
AppOpsManager.OP_INSTANT_APP_START_FOREGROUND,
r.appInfo.uid,
r.appInfo.packageName);
@@ -1354,7 +1355,7 @@ public final class ActiveServices {
try {
boolean ignoreForeground = false;
- final int mode = mAm.mAppOpsService.checkOperation(
+ final int mode = mAm.getAppOpsManager().checkOpNoThrow(
AppOpsManager.OP_START_FOREGROUND, r.appInfo.uid, r.packageName);
switch (mode) {
case AppOpsManager.MODE_ALLOWED:
@@ -2289,7 +2290,7 @@ public final class ActiveServices {
return new ServiceLookupResult(null, r.permission);
} else if (r.permission != null && callingPackage != null) {
final int opCode = AppOpsManager.permissionToOpCode(r.permission);
- if (opCode != AppOpsManager.OP_NONE && mAm.mAppOpsService.checkOperation(
+ if (opCode != AppOpsManager.OP_NONE && mAm.getAppOpsManager().checkOpNoThrow(
opCode, callingUid, callingPackage) != AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: Accessing service " + r.shortInstanceName
+ " from pid=" + callingPid
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 0686e3e99b2f..46a20c971884 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1231,6 +1231,7 @@ public class ActivityManagerService extends IActivityManager.Stub
* Information about and control over application operations
*/
final AppOpsService mAppOpsService;
+ private AppOpsManager mAppOpsManager;
/**
* List of initialization arguments to pass to all processes when binding applications to them.
@@ -2100,7 +2101,7 @@ public class ActivityManagerService extends IActivityManager.Stub
new IAppOpsCallback.Stub() {
@Override public void opChanged(int op, int uid, String packageName) {
if (op == AppOpsManager.OP_RUN_IN_BACKGROUND && packageName != null) {
- if (mAppOpsService.checkOperation(op, uid, packageName)
+ if (getAppOpsManager().checkOpNoThrow(op, uid, packageName)
!= AppOpsManager.MODE_ALLOWED) {
runInBackgroundDisabled(uid);
}
@@ -2391,6 +2392,13 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
+ AppOpsManager getAppOpsManager() {
+ if (mAppOpsManager == null) {
+ mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
+ }
+ return mAppOpsManager;
+ }
+
/**
* Provides the basic functionality for activity task related tests when a handler thread is
* given to initialize the dependency members.
@@ -2899,7 +2907,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void batterySendBroadcast(Intent intent) {
synchronized (this) {
- broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null,
+ broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
OP_NONE, null, false, false, -1, SYSTEM_UID, Binder.getCallingUid(),
Binder.getCallingPid(), UserHandle.USER_ALL);
}
@@ -3503,30 +3511,56 @@ public class ActivityManagerService extends IActivityManager.Stub
}
+ /**
+ * @deprecated use {@link #startActivityWithFeature} instead
+ */
+ @Deprecated
@Override
public int startActivity(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) {
- return mActivityTaskManager.startActivity(caller, callingPackage, intent, resolvedType,
- resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions);
+ return mActivityTaskManager.startActivity(caller, callingPackage, null, intent,
+ resolvedType, resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions);
}
@Override
+ public int startActivityWithFeature(IApplicationThread caller, String callingPackage,
+ String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo,
+ Bundle bOptions) {
+ return mActivityTaskManager.startActivity(caller, callingPackage, callingFeatureId, intent,
+ resolvedType, resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions);
+ }
+
+ /**
+ * @deprecated use {@link #startActivityAsUserWithFeature} instead
+ */
+ @Deprecated
+ @Override
public final int startActivityAsUser(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
+ return startActivityAsUserWithFeature(caller, callingPackage, null, intent, resolvedType,
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions, userId);
+ }
- return mActivityTaskManager.startActivityAsUser(caller, callingPackage, intent,
- resolvedType, resultTo, resultWho, requestCode, startFlags, profilerInfo,
- bOptions, userId);
+ @Override
+ public final int startActivityAsUserWithFeature(IApplicationThread caller,
+ String callingPackage, String callingFeatureId, Intent intent, String resolvedType,
+ IBinder resultTo, String resultWho, int requestCode, int startFlags,
+ ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
+ return mActivityTaskManager.startActivityAsUser(caller, callingPackage,
+ callingFeatureId, intent, resolvedType, resultTo, resultWho, requestCode,
+ startFlags, profilerInfo, bOptions, userId);
}
WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
- return mActivityTaskManager.startActivityAndWait(caller, callingPackage, intent,
- resolvedType, resultTo, resultWho, requestCode, startFlags, profilerInfo,
- bOptions, userId);
+ @Nullable String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo,
+ Bundle bOptions, int userId) {
+ return mActivityTaskManager.startActivityAndWait(caller, callingPackage,
+ callingFeatureId, intent, resolvedType, resultTo, resultWho, requestCode,
+ startFlags, profilerInfo, bOptions, userId);
}
@Override
@@ -4097,12 +4131,12 @@ public class ActivityManagerService extends IActivityManager.Stub
intent.putExtra(Intent.EXTRA_USER_HANDLE, resolvedUserId);
if (isInstantApp) {
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);
- broadcastIntentInPackage("android", SYSTEM_UID, uid, pid, intent, null,
- null, 0, null, null, permission.ACCESS_INSTANT_APPS, null, false,
- false, resolvedUserId, false);
+ broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent,
+ null, null, 0, null, null, permission.ACCESS_INSTANT_APPS, null,
+ false, false, resolvedUserId, false);
} else {
- broadcastIntentInPackage("android", SYSTEM_UID, uid, pid, intent, null,
- null, 0, null, null, null, null, false, false, resolvedUserId,
+ broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent,
+ null, null, 0, null, null, null, null, false, false, resolvedUserId,
false);
}
@@ -4550,7 +4584,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
intent.putExtra(Intent.EXTRA_UID, uid);
intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(uid));
- broadcastIntentLocked(null, null, intent,
+ broadcastIntentLocked(null, null, null, intent,
null, null, 0, null, null, null, OP_NONE,
null, false, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(),
Binder.getCallingPid(), UserHandle.getUserId(uid));
@@ -5408,12 +5442,23 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
+ /**
+ * @deprecated Use {@link #getIntentSenderWithFeature} instead
+ */
+ @Deprecated
@Override
public IIntentSender getIntentSender(int type,
String packageName, IBinder token, String resultWho,
int requestCode, Intent[] intents, String[] resolvedTypes,
int flags, Bundle bOptions, int userId) {
+ return getIntentSenderWithFeature(type, packageName, null, token, resultWho, requestCode,
+ intents, resolvedTypes, flags, bOptions, userId);
+ }
+ @Override
+ public IIntentSender getIntentSenderWithFeature(int type, String packageName, String featureId,
+ IBinder token, String resultWho, int requestCode, Intent[] intents,
+ String[] resolvedTypes, int flags, Bundle bOptions, int userId) {
// NOTE: The service lock isn't held in this method because nothing in the method requires
// the service lock to be held.
@@ -5475,12 +5520,13 @@ public class ActivityManagerService extends IActivityManager.Stub
}
if (type == ActivityManager.INTENT_SENDER_ACTIVITY_RESULT) {
- return mAtmInternal.getIntentSender(type, packageName, callingUid, userId,
- token, resultWho, requestCode, intents, resolvedTypes, flags, bOptions);
+ return mAtmInternal.getIntentSender(type, packageName, featureId, callingUid,
+ userId, token, resultWho, requestCode, intents, resolvedTypes, flags,
+ bOptions);
}
- return mPendingIntentController.getIntentSender(type, packageName, callingUid,
- userId, token, resultWho, requestCode, intents, resolvedTypes, flags,
- bOptions);
+ return mPendingIntentController.getIntentSender(type, packageName, featureId,
+ callingUid, userId, token, resultWho, requestCode, intents, resolvedTypes,
+ flags, bOptions);
} catch (RemoteException e) {
throw new SecurityException(e);
}
@@ -6046,8 +6092,8 @@ public class ActivityManagerService extends IActivityManager.Stub
return ActivityManager.APP_START_MODE_DELAYED;
}
// Not in the RESTRICTED bucket so policy is based on AppOp check.
- int appop = mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,
- uid, packageName, null, false, "");
+ int appop = getAppOpsManager().noteOpNoThrow(AppOpsManager.OP_RUN_IN_BACKGROUND,
+ uid, packageName, null, "");
if (DEBUG_BACKGROUND_CHECK) {
Slog.i(TAG, "Legacy app " + uid + "/" + packageName + " bg appop " + appop);
}
@@ -7956,7 +8002,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
boolean isBackgroundRestrictedNoCheck(final int uid, final String packageName) {
- final int mode = mAppOpsService.checkOperation(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND,
+ final int mode = getAppOpsManager().checkOpNoThrow(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND,
uid, packageName);
return mode != AppOpsManager.MODE_ALLOWED;
}
@@ -9434,14 +9480,14 @@ public class ActivityManagerService extends IActivityManager.Stub
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
| Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
- broadcastIntentLocked(null, null, intent,
+ broadcastIntentLocked(null, null, null, intent,
null, null, 0, null, null, null, OP_NONE,
null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
currentUserId);
intent = new Intent(Intent.ACTION_USER_STARTING);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
- broadcastIntentLocked(null, null, intent, null,
+ broadcastIntentLocked(null, null, null, intent, null,
new IIntentReceiver.Stub() {
@Override
public void performReceive(Intent intent, int resultCode,
@@ -14608,7 +14654,8 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public ComponentName startService(IApplicationThread caller, Intent service,
- String resolvedType, boolean requireForeground, String callingPackage, int userId)
+ String resolvedType, boolean requireForeground, String callingPackage,
+ String callingFeatureId, int userId)
throws TransactionTooLargeException {
enforceNotIsolatedCaller("startService");
// Refuse possible leaked file descriptors
@@ -14630,7 +14677,7 @@ public class ActivityManagerService extends IActivityManager.Stub
try {
res = mServices.startServiceLocked(caller, service,
resolvedType, callingPid, callingUid,
- requireForeground, callingPackage, userId);
+ requireForeground, callingPackage, callingFeatureId, userId);
} finally {
Binder.restoreCallingIdentity(origId);
}
@@ -15108,9 +15155,20 @@ public class ActivityManagerService extends IActivityManager.Stub
return didSomething;
}
+ /**
+ * @deprecated Use {@link #registerReceiverWithFeature}
+ */
+ @Deprecated
public Intent registerReceiver(IApplicationThread caller, String callerPackage,
IIntentReceiver receiver, IntentFilter filter, String permission, int userId,
int flags) {
+ return registerReceiverWithFeature(caller, callerPackage, null, receiver, filter,
+ permission, userId, flags);
+ }
+
+ public Intent registerReceiverWithFeature(IApplicationThread caller, String callerPackage,
+ String callerFeatureId, IIntentReceiver receiver, IntentFilter filter,
+ String permission, int userId, int flags) {
enforceNotIsolatedCaller("registerReceiver");
ArrayList<Intent> stickyIntents = null;
ProcessRecord callerApp = null;
@@ -15246,7 +15304,7 @@ public class ActivityManagerService extends IActivityManager.Stub
+ " was previously registered for user " + rl.userId
+ " callerPackage is " + callerPackage);
}
- BroadcastFilter bf = new BroadcastFilter(filter, rl, callerPackage,
+ BroadcastFilter bf = new BroadcastFilter(filter, rl, callerPackage, callerFeatureId,
permission, callingUid, userId, instantApp, visibleToInstantApps);
if (rl.containsFilter(filter)) {
Slog.w(TAG, "Receiver with filter " + filter
@@ -15271,7 +15329,7 @@ public class ActivityManagerService extends IActivityManager.Stub
Intent intent = allSticky.get(i);
BroadcastQueue queue = broadcastQueueForIntent(intent);
BroadcastRecord r = new BroadcastRecord(queue, intent, null,
- null, -1, -1, false, null, null, OP_NONE, null, receivers,
+ null, null, -1, -1, false, null, null, OP_NONE, null, receivers,
null, 0, null, null, false, true, true, -1, false,
false /* only PRE_BOOT_COMPLETED should be exempt, no stickies */);
queue.enqueueParallelBroadcastLocked(r);
@@ -15501,20 +15559,20 @@ public class ActivityManagerService extends IActivityManager.Stub
@GuardedBy("this")
final int broadcastIntentLocked(ProcessRecord callerApp,
- String callerPackage, Intent intent, String resolvedType,
+ String callerPackage, String callerFeatureId, Intent intent, String resolvedType,
IIntentReceiver resultTo, int resultCode, String resultData,
Bundle resultExtras, String[] requiredPermissions, int appOp, Bundle bOptions,
boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid,
int realCallingPid, int userId) {
- return broadcastIntentLocked(callerApp, callerPackage, intent, resolvedType, resultTo,
- resultCode, resultData, resultExtras, requiredPermissions, appOp, bOptions, ordered,
- sticky, callingPid, callingUid, realCallingUid, realCallingPid, userId,
- false /* allowBackgroundActivityStarts */);
+ return broadcastIntentLocked(callerApp, callerPackage, callerFeatureId, intent,
+ resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermissions,
+ appOp, bOptions, ordered, sticky, callingPid, callingUid, realCallingUid,
+ realCallingPid, userId, false /* allowBackgroundActivityStarts */);
}
@GuardedBy("this")
- final int broadcastIntentLocked(ProcessRecord callerApp,
- String callerPackage, Intent intent, String resolvedType,
+ final int broadcastIntentLocked(ProcessRecord callerApp, String callerPackage,
+ @Nullable String callerFeatureId, Intent intent, String resolvedType,
IIntentReceiver resultTo, int resultCode, String resultData,
Bundle resultExtras, String[] requiredPermissions, int appOp, Bundle bOptions,
boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid,
@@ -16051,8 +16109,8 @@ public class ActivityManagerService extends IActivityManager.Stub
isProtectedBroadcast, registeredReceivers);
}
final BroadcastQueue queue = broadcastQueueForIntent(intent);
- BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp,
- callerPackage, callingPid, callingUid, callerInstantApp, resolvedType,
+ BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp, callerPackage,
+ callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
requiredPermissions, appOp, brOptions, registeredReceivers, resultTo,
resultCode, resultData, resultExtras, ordered, sticky, false, userId,
allowBackgroundActivityStarts, timeoutExempt);
@@ -16148,8 +16206,8 @@ public class ActivityManagerService extends IActivityManager.Stub
if ((receivers != null && receivers.size() > 0)
|| resultTo != null) {
BroadcastQueue queue = broadcastQueueForIntent(intent);
- BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp,
- callerPackage, callingPid, callingUid, callerInstantApp, resolvedType,
+ BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp, callerPackage,
+ callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
requiredPermissions, appOp, brOptions, receivers, resultTo, resultCode,
resultData, resultExtras, ordered, sticky, false, userId,
allowBackgroundActivityStarts, timeoutExempt);
@@ -16268,11 +16326,25 @@ public class ActivityManagerService extends IActivityManager.Stub
return intent;
}
+ /**
+ * @deprecated Use {@link #broadcastIntentWithFeature}
+ */
+ @Deprecated
public final int broadcastIntent(IApplicationThread caller,
Intent intent, String resolvedType, IIntentReceiver resultTo,
int resultCode, String resultData, Bundle resultExtras,
String[] requiredPermissions, int appOp, Bundle bOptions,
boolean serialized, boolean sticky, int userId) {
+ return broadcastIntentWithFeature(caller, null, intent, resolvedType, resultTo, resultCode,
+ resultData, resultExtras, requiredPermissions, appOp, bOptions, serialized, sticky,
+ userId);
+ }
+
+ public final int broadcastIntentWithFeature(IApplicationThread caller, String callingFeatureId,
+ Intent intent, String resolvedType, IIntentReceiver resultTo,
+ int resultCode, String resultData, Bundle resultExtras,
+ String[] requiredPermissions, int appOp, Bundle bOptions,
+ boolean serialized, boolean sticky, int userId) {
enforceNotIsolatedCaller("broadcastIntent");
synchronized(this) {
intent = verifyBroadcastLocked(intent);
@@ -16284,7 +16356,7 @@ public class ActivityManagerService extends IActivityManager.Stub
final long origId = Binder.clearCallingIdentity();
try {
return broadcastIntentLocked(callerApp,
- callerApp != null ? callerApp.info.packageName : null,
+ callerApp != null ? callerApp.info.packageName : null, callingFeatureId,
intent, resolvedType, resultTo, resultCode, resultData, resultExtras,
requiredPermissions, appOp, bOptions, serialized, sticky,
callingPid, callingUid, callingUid, callingPid, userId);
@@ -16294,9 +16366,9 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- int broadcastIntentInPackage(String packageName, int uid, int realCallingUid,
- int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo,
- int resultCode, String resultData, Bundle resultExtras,
+ int broadcastIntentInPackage(String packageName, @Nullable String featureId, int uid,
+ int realCallingUid, int realCallingPid, Intent intent, String resolvedType,
+ IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras,
String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky,
int userId, boolean allowBackgroundActivityStarts) {
synchronized(this) {
@@ -16306,11 +16378,10 @@ public class ActivityManagerService extends IActivityManager.Stub
String[] requiredPermissions = requiredPermission == null ? null
: new String[] {requiredPermission};
try {
- return broadcastIntentLocked(null, packageName, intent, resolvedType,
- resultTo, resultCode, resultData, resultExtras,
- requiredPermissions, OP_NONE, bOptions, serialized,
- sticky, -1, uid, realCallingUid, realCallingPid, userId,
- allowBackgroundActivityStarts);
+ return broadcastIntentLocked(null, packageName, featureId, intent, resolvedType,
+ resultTo, resultCode, resultData, resultExtras, requiredPermissions,
+ OP_NONE, bOptions, serialized, sticky, -1, uid, realCallingUid,
+ realCallingPid, userId, allowBackgroundActivityStarts);
} finally {
Binder.restoreCallingIdentity(origId);
}
@@ -18914,23 +18985,24 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public int broadcastIntentInPackage(String packageName, int uid, int realCallingUid,
- int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo,
- int resultCode, String resultData, Bundle resultExtras, String requiredPermission,
- Bundle bOptions, boolean serialized, boolean sticky, int userId,
- boolean allowBackgroundActivityStarts) {
+ public int broadcastIntentInPackage(String packageName, @Nullable String featureId, int uid,
+ int realCallingUid, int realCallingPid, Intent intent, String resolvedType,
+ IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras,
+ String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky,
+ int userId, boolean allowBackgroundActivityStarts) {
synchronized (ActivityManagerService.this) {
- return ActivityManagerService.this.broadcastIntentInPackage(packageName, uid,
- realCallingUid, realCallingPid, intent, resolvedType, resultTo, resultCode,
- resultData, resultExtras, requiredPermission, bOptions, serialized, sticky,
- userId, allowBackgroundActivityStarts);
+ return ActivityManagerService.this.broadcastIntentInPackage(packageName, featureId,
+ uid, realCallingUid, realCallingPid, intent, resolvedType, resultTo,
+ resultCode, resultData, resultExtras, requiredPermission, bOptions,
+ serialized, sticky, userId, allowBackgroundActivityStarts);
}
}
@Override
public ComponentName startServiceInPackage(int uid, Intent service, String resolvedType,
- boolean fgRequired, String callingPackage, int userId,
- boolean allowBackgroundActivityStarts) throws TransactionTooLargeException {
+ boolean fgRequired, String callingPackage, @Nullable String callingFeatureId,
+ int userId, boolean allowBackgroundActivityStarts)
+ throws TransactionTooLargeException {
synchronized(ActivityManagerService.this) {
if (DEBUG_SERVICE) Slog.v(TAG_SERVICE,
"startServiceInPackage: " + service + " type=" + resolvedType);
@@ -18938,8 +19010,8 @@ public class ActivityManagerService extends IActivityManager.Stub
ComponentName res;
try {
res = mServices.startServiceLocked(null, service,
- resolvedType, -1, uid, fgRequired, callingPackage, userId,
- allowBackgroundActivityStarts);
+ resolvedType, -1, uid, fgRequired, callingPackage,
+ callingFeatureId, userId, allowBackgroundActivityStarts);
} finally {
Binder.restoreCallingIdentity(origId);
}
@@ -19032,7 +19104,7 @@ public class ActivityManagerService extends IActivityManager.Stub
| Intent.FLAG_RECEIVER_REPLACE_PENDING
| Intent.FLAG_RECEIVER_FOREGROUND
| Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
- broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null,
+ broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
OP_NONE, null, false, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(),
Binder.getCallingPid(), UserHandle.USER_ALL);
if ((changes & ActivityInfo.CONFIG_LOCALE) != 0) {
@@ -19043,7 +19115,7 @@ public class ActivityManagerService extends IActivityManager.Stub
if (initLocale || !mProcessesReady) {
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
}
- broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null,
+ broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
OP_NONE, null, false, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(),
Binder.getCallingPid(), UserHandle.USER_ALL);
}
@@ -19058,7 +19130,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// Typically only app stores will have this permission.
String[] permissions =
new String[] { android.Manifest.permission.INSTALL_PACKAGES };
- broadcastIntentLocked(null, null, intent, null, null, 0, null, null,
+ broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null,
permissions, OP_NONE, null, false, false, MY_PID, SYSTEM_UID,
Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL);
}
@@ -19083,7 +19155,7 @@ public class ActivityManagerService extends IActivityManager.Stub
intent.putExtra("reason", reason);
}
- broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null,
+ broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
OP_NONE, null, false, false, -1, SYSTEM_UID, Binder.getCallingUid(),
Binder.getCallingPid(), UserHandle.USER_ALL);
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 53a967b0ce50..c0e98cd9b30a 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -534,13 +534,13 @@ final class ActivityManagerShellCommand extends ShellCommand {
options.setLockTaskEnabled(true);
}
if (mWaitOption) {
- result = mInternal.startActivityAndWait(null, SHELL_PACKAGE_NAME, intent, mimeType,
- null, null, 0, mStartFlags, profilerInfo,
+ result = mInternal.startActivityAndWait(null, SHELL_PACKAGE_NAME, null, intent,
+ mimeType, null, null, 0, mStartFlags, profilerInfo,
options != null ? options.toBundle() : null, mUserId);
res = result.result;
} else {
- res = mInternal.startActivityAsUser(null, SHELL_PACKAGE_NAME, intent, mimeType,
- null, null, 0, mStartFlags, profilerInfo,
+ res = mInternal.startActivityAsUserWithFeature(null, SHELL_PACKAGE_NAME, null,
+ intent, mimeType, null, null, 0, mStartFlags, profilerInfo,
options != null ? options.toBundle() : null, mUserId);
}
final long endTime = SystemClock.uptimeMillis();
@@ -652,7 +652,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
pw.println("Starting service: " + intent);
pw.flush();
ComponentName cn = mInterface.startService(null, intent, intent.getType(),
- asForeground, SHELL_PACKAGE_NAME, mUserId);
+ asForeground, SHELL_PACKAGE_NAME, null, mUserId);
if (cn == null) {
err.println("Error: Not found; no service started.");
return -1;
@@ -742,8 +742,9 @@ final class ActivityManagerShellCommand extends ShellCommand {
pw.println("Broadcasting: " + intent);
pw.flush();
Bundle bundle = mBroadcastOptions == null ? null : mBroadcastOptions.toBundle();
- mInterface.broadcastIntent(null, intent, null, receiver, 0, null, null, requiredPermissions,
- android.app.AppOpsManager.OP_NONE, bundle, true, false, mUserId);
+ mInterface.broadcastIntentWithFeature(null, null, intent, null, receiver, 0, null, null,
+ requiredPermissions, android.app.AppOpsManager.OP_NONE, bundle, true, false,
+ mUserId);
receiver.waitForFinish();
return 0;
}
diff --git a/services/core/java/com/android/server/am/BroadcastFilter.java b/services/core/java/com/android/server/am/BroadcastFilter.java
index 1ec8db0aeec9..578db6f9dba1 100644
--- a/services/core/java/com/android/server/am/BroadcastFilter.java
+++ b/services/core/java/com/android/server/am/BroadcastFilter.java
@@ -27,6 +27,7 @@ final class BroadcastFilter extends IntentFilter {
// Back-pointer to the list this filter is in.
final ReceiverList receiverList;
final String packageName;
+ final String featureId;
final String requiredPermission;
final int owningUid;
final int owningUserId;
@@ -34,11 +35,12 @@ final class BroadcastFilter extends IntentFilter {
final boolean visibleToInstantApp;
BroadcastFilter(IntentFilter _filter, ReceiverList _receiverList,
- String _packageName, String _requiredPermission, int _owningUid, int _userId,
+ String _packageName, String _featureId, String _requiredPermission, int _owningUid, int _userId,
boolean _instantApp, boolean _visibleToInstantApp) {
super(_filter);
receiverList = _receiverList;
packageName = _packageName;
+ featureId = _featureId;
requiredPermission = _requiredPermission;
owningUid = _owningUid;
owningUserId = _userId;
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java
index 6697b5ab7c85..26ef7073487d 100644
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -648,10 +648,10 @@ public final class BroadcastQueue {
skip = true;
} else {
final int opCode = AppOpsManager.permissionToOpCode(filter.requiredPermission);
- // TODO moltmann: Set featureId from caller
if (opCode != AppOpsManager.OP_NONE
- && mService.mAppOpsService.noteOperation(opCode, r.callingUid,
- r.callerPackage, null, false, "") != AppOpsManager.MODE_ALLOWED) {
+ && mService.getAppOpsManager().noteOpNoThrow(opCode, r.callingUid,
+ r.callerPackage, r.callerFeatureId, "")
+ != AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: broadcasting "
+ r.intent.toString()
+ " from " + r.callerPackage + " (pid="
@@ -681,10 +681,9 @@ public final class BroadcastQueue {
break;
}
int appOp = AppOpsManager.permissionToOpCode(requiredPermission);
- // TODO moltmann: Set featureId from caller
if (appOp != AppOpsManager.OP_NONE && appOp != r.appOp
- && mService.mAppOpsService.noteOperation(appOp,
- filter.receiverList.uid, filter.packageName, null, false, "")
+ && mService.getAppOpsManager().noteOpNoThrow(appOp,
+ filter.receiverList.uid, filter.packageName, filter.featureId, "")
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent.toString()
@@ -714,10 +713,9 @@ public final class BroadcastQueue {
skip = true;
}
}
- // TODO moltmann: Set featureId from caller
if (!skip && r.appOp != AppOpsManager.OP_NONE
- && mService.mAppOpsService.noteOperation(r.appOp,
- filter.receiverList.uid, filter.packageName, null, false, "")
+ && mService.getAppOpsManager().noteOpNoThrow(r.appOp,
+ filter.receiverList.uid, filter.packageName, filter.featureId, "")
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent.toString()
@@ -863,7 +861,8 @@ public final class BroadcastQueue {
if (callerForeground && receiverRecord.intent.getComponent() != null) {
IIntentSender target = mService.mPendingIntentController.getIntentSender(
ActivityManager.INTENT_SENDER_BROADCAST, receiverRecord.callerPackage,
- receiverRecord.callingUid, receiverRecord.userId, null, null, 0,
+ receiverRecord.callerFeatureId, receiverRecord.callingUid,
+ receiverRecord.userId, null, null, 0,
new Intent[]{receiverRecord.intent},
new String[]{receiverRecord.intent.resolveType(mService.mContext
.getContentResolver())},
@@ -1371,10 +1370,9 @@ public final class BroadcastQueue {
skip = true;
} else if (!skip && info.activityInfo.permission != null) {
final int opCode = AppOpsManager.permissionToOpCode(info.activityInfo.permission);
- // TODO moltmann: Set featureId from caller
if (opCode != AppOpsManager.OP_NONE
- && mService.mAppOpsService.noteOperation(opCode, r.callingUid, r.callerPackage,
- null, false, "") != AppOpsManager.MODE_ALLOWED) {
+ && mService.getAppOpsManager().noteOpNoThrow(opCode, r.callingUid, r.callerPackage,
+ r.callerFeatureId, "") != AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: broadcasting "
+ r.intent.toString()
+ " from " + r.callerPackage + " (pid="
@@ -1410,11 +1408,10 @@ public final class BroadcastQueue {
break;
}
int appOp = AppOpsManager.permissionToOpCode(requiredPermission);
- // TODO moltmann: Set featureId from caller
if (appOp != AppOpsManager.OP_NONE && appOp != r.appOp
- && mService.mAppOpsService.noteOperation(appOp,
- info.activityInfo.applicationInfo.uid, info.activityInfo.packageName, null,
- false, "")
+ && mService.getAppOpsManager().noteOpNoThrow(appOp,
+ info.activityInfo.applicationInfo.uid, info.activityInfo.packageName,
+ null /* default featureId */, "")
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent + " to "
@@ -1428,11 +1425,10 @@ public final class BroadcastQueue {
}
}
}
- // TODO moltmann: Set featureId from caller
if (!skip && r.appOp != AppOpsManager.OP_NONE
- && mService.mAppOpsService.noteOperation(r.appOp,
- info.activityInfo.applicationInfo.uid, info.activityInfo.packageName, null, false,
- "")
+ && mService.getAppOpsManager().noteOpNoThrow(r.appOp,
+ info.activityInfo.applicationInfo.uid, info.activityInfo.packageName,
+ null /* default featureId */, "")
!= AppOpsManager.MODE_ALLOWED) {
Slog.w(TAG, "Appop Denial: receiving "
+ r.intent + " to "
diff --git a/services/core/java/com/android/server/am/BroadcastRecord.java b/services/core/java/com/android/server/am/BroadcastRecord.java
index f2638861d39b..8ef67f97e8d4 100644
--- a/services/core/java/com/android/server/am/BroadcastRecord.java
+++ b/services/core/java/com/android/server/am/BroadcastRecord.java
@@ -16,6 +16,7 @@
package com.android.server.am;
+import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
import android.content.ComponentName;
@@ -51,6 +52,7 @@ final class BroadcastRecord extends Binder {
final ComponentName targetComp; // original component name set on the intent
final ProcessRecord callerApp; // process that sent this
final String callerPackage; // who sent this
+ final @Nullable String callerFeatureId; // which feature in the package sent this
final int callingPid; // the pid of who sent this
final int callingUid; // the uid of who sent this
final boolean callerInstantApp; // caller is an Instant App?
@@ -233,7 +235,8 @@ final class BroadcastRecord extends Binder {
BroadcastRecord(BroadcastQueue _queue,
Intent _intent, ProcessRecord _callerApp, String _callerPackage,
- int _callingPid, int _callingUid, boolean _callerInstantApp, String _resolvedType,
+ @Nullable String _callerFeatureId, int _callingPid, int _callingUid,
+ boolean _callerInstantApp, String _resolvedType,
String[] _requiredPermissions, int _appOp, BroadcastOptions _options, List _receivers,
IIntentReceiver _resultTo, int _resultCode, String _resultData, Bundle _resultExtras,
boolean _serialized, boolean _sticky, boolean _initialSticky, int _userId,
@@ -246,6 +249,7 @@ final class BroadcastRecord extends Binder {
targetComp = _intent.getComponent();
callerApp = _callerApp;
callerPackage = _callerPackage;
+ callerFeatureId = _callerFeatureId;
callingPid = _callingPid;
callingUid = _callingUid;
callerInstantApp = _callerInstantApp;
@@ -280,6 +284,7 @@ final class BroadcastRecord extends Binder {
callerApp = from.callerApp;
callerPackage = from.callerPackage;
+ callerFeatureId = from.callerFeatureId;
callingPid = from.callingPid;
callingUid = from.callingUid;
callerInstantApp = from.callerInstantApp;
@@ -343,8 +348,8 @@ final class BroadcastRecord extends Binder {
}
// build a new BroadcastRecord around that single-target list
- BroadcastRecord split = new BroadcastRecord(queue, intent, callerApp,
- callerPackage, callingPid, callingUid, callerInstantApp, resolvedType,
+ BroadcastRecord split = new BroadcastRecord(queue, intent, callerApp, callerPackage,
+ callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
requiredPermissions, appOp, options, splitReceivers, resultTo, resultCode,
resultData, resultExtras, ordered, sticky, initialSticky, userId,
allowBackgroundActivityStarts, timeoutExempt);
diff --git a/services/core/java/com/android/server/am/PendingIntentController.java b/services/core/java/com/android/server/am/PendingIntentController.java
index df76713d58a6..eacf08889b1d 100644
--- a/services/core/java/com/android/server/am/PendingIntentController.java
+++ b/services/core/java/com/android/server/am/PendingIntentController.java
@@ -23,6 +23,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_MU;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManagerInternal;
import android.app.AppGlobals;
@@ -88,9 +89,9 @@ public class PendingIntentController {
}
}
- public PendingIntentRecord getIntentSender(int type, String packageName, int callingUid,
- int userId, IBinder token, String resultWho, int requestCode, Intent[] intents,
- String[] resolvedTypes, int flags, Bundle bOptions) {
+ public PendingIntentRecord getIntentSender(int type, String packageName,
+ @Nullable String featureId, int callingUid, int userId, IBinder token, String resultWho,
+ int requestCode, Intent[] intents, String[] resolvedTypes, int flags, Bundle bOptions) {
synchronized (mLock) {
if (DEBUG_MU) Slog.v(TAG_MU, "getIntentSender(): uid=" + callingUid);
@@ -109,8 +110,8 @@ public class PendingIntentController {
flags &= ~(PendingIntent.FLAG_NO_CREATE | PendingIntent.FLAG_CANCEL_CURRENT
| PendingIntent.FLAG_UPDATE_CURRENT);
- PendingIntentRecord.Key key = new PendingIntentRecord.Key(type, packageName, token,
- resultWho, requestCode, intents, resolvedTypes, flags,
+ PendingIntentRecord.Key key = new PendingIntentRecord.Key(type, packageName, featureId,
+ token, resultWho, requestCode, intents, resolvedTypes, flags,
SafeActivityOptions.fromBundle(bOptions), userId);
WeakReference<PendingIntentRecord> ref;
ref = mIntentSenderRecords.get(key);
diff --git a/services/core/java/com/android/server/am/PendingIntentRecord.java b/services/core/java/com/android/server/am/PendingIntentRecord.java
index 3ba2210504d6..d54d2d7d2056 100644
--- a/services/core/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/core/java/com/android/server/am/PendingIntentRecord.java
@@ -17,14 +17,16 @@
package com.android.server.am;
import static android.app.ActivityManager.START_SUCCESS;
+
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityOptions;
-import android.content.IIntentSender;
-import android.content.IIntentReceiver;
import android.app.PendingIntent;
+import android.content.IIntentReceiver;
+import android.content.IIntentSender;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
@@ -72,6 +74,7 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
final static class Key {
final int type;
final String packageName;
+ final String featureId;
final IBinder activity;
final String who;
final int requestCode;
@@ -86,10 +89,11 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
private static final int ODD_PRIME_NUMBER = 37;
- Key(int _t, String _p, IBinder _a, String _w,
+ Key(int _t, String _p, @Nullable String _featureId, IBinder _a, String _w,
int _r, Intent[] _i, String[] _it, int _f, SafeActivityOptions _o, int _userId) {
type = _t;
packageName = _p;
+ featureId = _featureId;
activity = _a;
who = _w;
requestCode = _r;
@@ -140,6 +144,9 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
if (!Objects.equals(packageName, other.packageName)) {
return false;
}
+ if (!Objects.equals(featureId, other.featureId)) {
+ return false;
+ }
if (activity != other.activity) {
return false;
}
@@ -175,7 +182,8 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
}
public String toString() {
- return "Key{" + typeName() + " pkg=" + packageName
+ return "Key{" + typeName()
+ + " pkg=" + packageName + (featureId != null ? "/" + featureId : "")
+ " intent="
+ (requestIntent != null
? requestIntent.toShortString(false, true, false, false) : "<null>")
@@ -403,19 +411,20 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
if (key.allIntents != null && key.allIntents.length > 1) {
res = controller.mAtmInternal.startActivitiesInPackage(
- uid, callingPid, callingUid, key.packageName, allIntents,
- allResolvedTypes, resultTo, mergedOptions, userId,
+ uid, callingPid, callingUid, key.packageName, key.featureId,
+ allIntents, allResolvedTypes, resultTo, mergedOptions, userId,
false /* validateIncomingUser */,
this /* originatingPendingIntent */,
mAllowBgActivityStartsForActivitySender.contains(whitelistToken));
} else {
- res = controller.mAtmInternal.startActivityInPackage(
- uid, callingPid, callingUid, key.packageName, finalIntent,
+ res = controller.mAtmInternal.startActivityInPackage(uid, callingPid,
+ callingUid, key.packageName, key.featureId, finalIntent,
resolvedType, resultTo, resultWho, requestCode, 0,
mergedOptions, userId, null, "PendingIntentRecord",
false /* validateIncomingUser */,
this /* originatingPendingIntent */,
- mAllowBgActivityStartsForActivitySender.contains(whitelistToken));
+ mAllowBgActivityStartsForActivitySender.contains(
+ whitelistToken));
}
} catch (RuntimeException e) {
Slog.w(TAG, "Unable to send startActivity intent", e);
@@ -430,11 +439,12 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
// If a completion callback has been requested, require
// that the broadcast be delivered synchronously
int sent = controller.mAmInternal.broadcastIntentInPackage(key.packageName,
- uid, callingUid, callingPid, finalIntent, resolvedType,
- finishedReceiver, code, null, null, requiredPermission, options,
- (finishedReceiver != null), false, userId,
+ key.featureId, uid, callingUid, callingPid, finalIntent,
+ resolvedType, finishedReceiver, code, null, null,
+ requiredPermission, options, (finishedReceiver != null), false,
+ userId,
mAllowBgActivityStartsForBroadcastSender.contains(whitelistToken)
- || allowTrampoline);
+ || allowTrampoline);
if (sent == ActivityManager.BROADCAST_SUCCESS) {
sendFinish = false;
}
@@ -447,7 +457,7 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
try {
controller.mAmInternal.startServiceInPackage(uid, finalIntent, resolvedType,
key.type == ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE,
- key.packageName, userId,
+ key.packageName, key.featureId, userId,
mAllowBgActivityStartsForServiceSender.contains(whitelistToken)
|| allowTrampoline);
} catch (RuntimeException e) {
@@ -496,6 +506,7 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
public void dump(PrintWriter pw, String prefix) {
pw.print(prefix); pw.print("uid="); pw.print(uid);
pw.print(" packageName="); pw.print(key.packageName);
+ pw.print(" featureId="); pw.print(key.featureId);
pw.print(" type="); pw.print(key.typeName());
pw.print(" flags=0x"); pw.println(Integer.toHexString(key.flags));
if (key.activity != null || key.who != null) {
@@ -545,6 +556,10 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
sb.append(Integer.toHexString(System.identityHashCode(this)));
sb.append(' ');
sb.append(key.packageName);
+ if (key.featureId != null) {
+ sb.append('/');
+ sb.append(key.featureId);
+ }
sb.append(' ');
sb.append(key.typeName());
if (whitelistDuration != null) {
diff --git a/services/core/java/com/android/server/am/PreBootBroadcaster.java b/services/core/java/com/android/server/am/PreBootBroadcaster.java
index beb0e4741c36..747e8a89f8e7 100644
--- a/services/core/java/com/android/server/am/PreBootBroadcaster.java
+++ b/services/core/java/com/android/server/am/PreBootBroadcaster.java
@@ -108,8 +108,8 @@ public abstract class PreBootBroadcaster extends IIntentReceiver.Stub {
mIntent.setComponent(componentName);
synchronized (mService) {
- mService.broadcastIntentLocked(null, null, mIntent, null, this, 0, null, null, null,
- AppOpsManager.OP_NONE, null, true, false, ActivityManagerService.MY_PID,
+ mService.broadcastIntentLocked(null, null, null, mIntent, null, this, 0, null, null,
+ null, AppOpsManager.OP_NONE, null, true, false, ActivityManagerService.MY_PID,
Process.SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), mUserId);
}
}
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index c75ee04543e3..e575e10807bc 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -2447,10 +2447,10 @@ class UserController implements Handler.Callback {
int realCallingPid, @UserIdInt int userId) {
// TODO b/64165549 Verify that mLock is not held before calling AMS methods
synchronized (mService) {
- return mService.broadcastIntentLocked(null, null, intent, resolvedType, resultTo,
- resultCode, resultData, resultExtras, requiredPermissions, appOp, bOptions,
- ordered, sticky, callingPid, callingUid, realCallingUid, realCallingPid,
- userId);
+ return mService.broadcastIntentLocked(null, null, null, intent, resolvedType,
+ resultTo, resultCode, resultData, resultExtras, requiredPermissions, appOp,
+ bOptions, ordered, sticky, callingPid, callingUid, realCallingUid,
+ realCallingPid, userId);
}
}
diff --git a/services/core/java/com/android/server/om/OverlayManagerService.java b/services/core/java/com/android/server/om/OverlayManagerService.java
index 3c31f6a7f0d7..d75eb6d65b03 100644
--- a/services/core/java/com/android/server/om/OverlayManagerService.java
+++ b/services/core/java/com/android/server/om/OverlayManagerService.java
@@ -913,9 +913,9 @@ public final class OverlayManagerService extends SystemService {
}
try {
- ActivityManager.getService().broadcastIntent(null, intent, null, null, 0,
- null, null, null, android.app.AppOpsManager.OP_NONE, null, false, false,
- userId);
+ ActivityManager.getService().broadcastIntentWithFeature(null, null, intent,
+ null, null, 0, null, null, null, android.app.AppOpsManager.OP_NONE,
+ null, false, false, userId);
} catch (RemoteException e) {
// Intentionally left empty.
}
diff --git a/services/core/java/com/android/server/pm/CrossProfileAppsServiceImpl.java b/services/core/java/com/android/server/pm/CrossProfileAppsServiceImpl.java
index 74d2efeceb63..cd4485e67064 100644
--- a/services/core/java/com/android/server/pm/CrossProfileAppsServiceImpl.java
+++ b/services/core/java/com/android/server/pm/CrossProfileAppsServiceImpl.java
@@ -44,9 +44,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ResolveInfo;
import android.os.Binder;
-import android.os.IBinder;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.stats.devicepolicy.DevicePolicyEnums;
@@ -54,10 +52,8 @@ import android.text.TextUtils;
import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.app.IAppOpsService;
import com.android.internal.util.ArrayUtils;
import com.android.server.LocalServices;
-import com.android.server.appop.AppOpsService;
import com.android.server.wm.ActivityTaskManagerInternal;
import java.util.ArrayList;
@@ -69,7 +65,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
private Context mContext;
private Injector mInjector;
- private AppOpsService mAppOpsService;
+ private AppOpsManager mAppOpsManager;
public CrossProfileAppsServiceImpl(Context context) {
this(context, new InjectorImpl(context));
@@ -100,6 +96,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
public void startActivityAsUser(
IApplicationThread caller,
String callingPackage,
+ String callingFeatureId,
ComponentName component,
@UserIdInt int userId,
boolean launchMainActivity) throws RemoteException {
@@ -165,7 +162,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
launchIntent.setPackage(null);
launchIntent.setComponent(component);
mInjector.getActivityTaskManagerInternal().startActivityAsUser(
- caller, callingPackage, launchIntent,
+ caller, callingPackage, callingFeatureId, launchIntent,
launchMainActivity
? ActivityOptions.makeOpenCrossProfileAppsAnimation().toBundle()
: null,
@@ -176,6 +173,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
public void startActivityAsUserByIntent(
IApplicationThread caller,
String callingPackage,
+ String callingFeatureId,
Intent intent,
@UserIdInt int userId) throws RemoteException {
Objects.requireNonNull(callingPackage);
@@ -212,8 +210,8 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
verifyActivityCanHandleIntent(launchIntent, callingUid, userId);
- mInjector.getActivityTaskManagerInternal().startActivityAsUser(
- caller, callingPackage, launchIntent, /* options= */ null, userId);
+ mInjector.getActivityTaskManagerInternal().startActivityAsUser(caller, callingPackage,
+ callingFeatureId, launchIntent, /* options= */ null, userId);
}
@Override
@@ -545,12 +543,11 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
permission, uid, /* owningUid= */-1, /* exported= */ true);
}
- private AppOpsService getAppOpsService() {
- if (mAppOpsService == null) {
- IBinder b = ServiceManager.getService(Context.APP_OPS_SERVICE);
- mAppOpsService = (AppOpsService) IAppOpsService.Stub.asInterface(b);
+ private AppOpsManager getAppOpsManager() {
+ if (mAppOpsManager == null) {
+ mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
}
- return mAppOpsService;
+ return mAppOpsManager;
}
private static class InjectorImpl implements Injector {
diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java
index 8333ae5cbbad..0b0f13929b2a 100644
--- a/services/core/java/com/android/server/pm/InstantAppResolver.java
+++ b/services/core/java/com/android/server/pm/InstantAppResolver.java
@@ -222,6 +222,7 @@ public abstract class InstantAppResolver {
sanitizedIntent,
failureIntent,
requestObj.callingPackage,
+ requestObj.callingFeatureId,
requestObj.verificationBundle,
requestObj.resolvedType,
requestObj.userId,
@@ -266,6 +267,7 @@ public abstract class InstantAppResolver {
@NonNull Intent sanitizedIntent,
@Nullable Intent failureIntent,
@NonNull String callingPackage,
+ @Nullable String callingFeatureId,
@Nullable Bundle verificationBundle,
@NonNull String resolvedType,
int userId,
@@ -308,9 +310,10 @@ public abstract class InstantAppResolver {
onFailureIntent = failureIntent;
}
final IIntentSender failureIntentTarget = ActivityManager.getService()
- .getIntentSender(
+ .getIntentSenderWithFeature(
ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage,
- null /*token*/, null /*resultWho*/, 1 /*requestCode*/,
+ callingFeatureId, null /*token*/, null /*resultWho*/,
+ 1 /*requestCode*/,
new Intent[] { onFailureIntent },
new String[] { resolvedType },
PendingIntent.FLAG_CANCEL_CURRENT
@@ -328,9 +331,10 @@ public abstract class InstantAppResolver {
successIntent.setLaunchToken(token);
try {
final IIntentSender successIntentTarget = ActivityManager.getService()
- .getIntentSender(
+ .getIntentSenderWithFeature(
ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage,
- null /*token*/, null /*resultWho*/, 0 /*requestCode*/,
+ callingFeatureId, null /*token*/, null /*resultWho*/,
+ 0 /*requestCode*/,
new Intent[] { successIntent },
new String[] { resolvedType },
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index 0cd1c259dd9e..da07365a5f35 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -17,6 +17,7 @@
package com.android.server.pm;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
@@ -782,8 +783,9 @@ public class LauncherAppsService extends SystemService {
}
@Override
- public boolean startShortcut(String callingPackage, String packageName, String shortcutId,
- Rect sourceBounds, Bundle startActivityOptions, int targetUserId) {
+ public boolean startShortcut(String callingPackage, String packageName, String featureId,
+ String shortcutId, Rect sourceBounds, Bundle startActivityOptions,
+ int targetUserId) {
verifyCallingPackage(callingPackage);
if (!canAccessProfile(targetUserId, "Cannot start activity")) {
return false;
@@ -807,15 +809,16 @@ public class LauncherAppsService extends SystemService {
intents[0].setSourceBounds(sourceBounds);
return startShortcutIntentsAsPublisher(
- intents, packageName, startActivityOptions, targetUserId);
+ intents, packageName, featureId, startActivityOptions, targetUserId);
}
private boolean startShortcutIntentsAsPublisher(@NonNull Intent[] intents,
- @NonNull String publisherPackage, Bundle startActivityOptions, int userId) {
+ @NonNull String publisherPackage, @Nullable String publishedFeatureId,
+ Bundle startActivityOptions, int userId) {
final int code;
try {
code = mActivityTaskManagerInternal.startActivitiesAsPackage(publisherPackage,
- userId, intents, startActivityOptions);
+ publishedFeatureId, userId, intents, startActivityOptions);
if (ActivityManager.isStartResultSuccessful(code)) {
return true; // Success
} else {
@@ -870,8 +873,8 @@ public class LauncherAppsService extends SystemService {
@Override
public void startSessionDetailsActivityAsUser(IApplicationThread caller,
- String callingPackage, SessionInfo sessionInfo, Rect sourceBounds,
- Bundle opts, UserHandle userHandle) throws RemoteException {
+ String callingPackage, String callingFeatureId, SessionInfo sessionInfo,
+ Rect sourceBounds, Bundle opts, UserHandle userHandle) throws RemoteException {
int userId = userHandle.getIdentifier();
if (!canAccessProfile(userId, "Cannot start details activity")) {
return;
@@ -887,13 +890,13 @@ public class LauncherAppsService extends SystemService {
.authority(callingPackage).build());
i.setSourceBounds(sourceBounds);
- mActivityTaskManagerInternal.startActivityAsUser(caller, callingPackage, i, opts,
- userId);
+ mActivityTaskManagerInternal.startActivityAsUser(caller, callingPackage,
+ callingFeatureId, i, opts, userId);
}
@Override
public void startActivityAsUser(IApplicationThread caller, String callingPackage,
- ComponentName component, Rect sourceBounds,
+ String callingFeatureId, ComponentName component, Rect sourceBounds,
Bundle opts, UserHandle user) throws RemoteException {
if (!canAccessProfile(user.getIdentifier(), "Cannot start activity")) {
return;
@@ -947,12 +950,12 @@ public class LauncherAppsService extends SystemService {
Binder.restoreCallingIdentity(ident);
}
mActivityTaskManagerInternal.startActivityAsUser(caller, callingPackage,
- launchIntent, opts, user.getIdentifier());
+ callingFeatureId, launchIntent, opts, user.getIdentifier());
}
@Override
public void showAppDetailsAsUser(IApplicationThread caller,
- String callingPackage, ComponentName component,
+ String callingPackage, String callingFeatureId, ComponentName component,
Rect sourceBounds, Bundle opts, UserHandle user) throws RemoteException {
if (!canAccessProfile(user.getIdentifier(), "Cannot show app details")) {
return;
@@ -970,7 +973,7 @@ public class LauncherAppsService extends SystemService {
Binder.restoreCallingIdentity(ident);
}
mActivityTaskManagerInternal.startActivityAsUser(caller, callingPackage,
- intent, opts, user.getIdentifier());
+ callingFeatureId, intent, opts, user.getIdentifier());
}
/** Checks if user is a profile of or same as listeningUser.
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 88c048cea267..2c85d067a3ca 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -6298,10 +6298,11 @@ public class PackageManagerService extends IPackageManager.Stub
private void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
Intent origIntent, String resolvedType, String callingPackage,
- boolean isRequesterInstantApp, Bundle verificationBundle, int userId) {
+ @Nullable String callingFeatureId, boolean isRequesterInstantApp,
+ Bundle verificationBundle, int userId) {
final Message msg = mHandler.obtainMessage(INSTANT_APP_RESOLUTION_PHASE_TWO,
new InstantAppRequest(responseObj, origIntent, resolvedType,
- callingPackage, isRequesterInstantApp, userId, verificationBundle,
+ callingPackage, callingFeatureId, isRequesterInstantApp, userId, verificationBundle,
false /*resolveForStart*/, responseObj.hostDigestPrefixSecure,
responseObj.token));
mHandler.sendMessage(msg);
@@ -6987,10 +6988,10 @@ public class PackageManagerService extends IPackageManager.Stub
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral");
String token = UUID.randomUUID().toString();
InstantAppDigest digest = InstantAppResolver.parseDigest(intent);
- final InstantAppRequest requestObject = new InstantAppRequest(
- null /*responseObj*/, intent /*origIntent*/, resolvedType,
- null /*callingPackage*/, isRequesterInstantApp,
- userId, null /*verificationBundle*/, resolveForStart,
+ final InstantAppRequest requestObject = new InstantAppRequest(null /*responseObj*/,
+ intent /*origIntent*/, resolvedType, null /*callingPackage*/,
+ null /*callingFeatureId*/, isRequesterInstantApp, userId,
+ null /*verificationBundle*/, resolveForStart,
digest.getDigestPrefixSecure(), token);
auxiliaryResponse = InstantAppResolver.doInstantAppResolutionPhaseOne(
mInstantAppResolverConnection, requestObject);
@@ -12206,7 +12207,7 @@ public class PackageManagerService extends IPackageManager.Stub
+ intent.toShortString(false, true, false, false)
+ " " + intent.getExtras(), here);
}
- am.broadcastIntent(null, intent, null, finishedReceiver,
+ am.broadcastIntentWithFeature(null, null, intent, null, finishedReceiver,
0, null, null, requiredPermissions, android.app.AppOpsManager.OP_NONE,
null, finishedReceiver != null, false, id);
}
@@ -12368,8 +12369,9 @@ public class PackageManagerService extends IPackageManager.Stub
lockedBcIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
}
final String[] requiredPermissions = {Manifest.permission.RECEIVE_BOOT_COMPLETED};
- am.broadcastIntent(null, lockedBcIntent, null, null, 0, null, null, requiredPermissions,
- android.app.AppOpsManager.OP_NONE, null, false, false, userId);
+ am.broadcastIntentWithFeature(null, null, lockedBcIntent, null, null, 0, null, null,
+ requiredPermissions, android.app.AppOpsManager.OP_NONE, null, false, false,
+ userId);
// Deliver BOOT_COMPLETED only if user is unlocked
if (mUserManager.isUserUnlockingOrUnlocked(userId)) {
@@ -12377,8 +12379,9 @@ public class PackageManagerService extends IPackageManager.Stub
if (includeStopped) {
bcIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
}
- am.broadcastIntent(null, bcIntent, null, null, 0, null, null, requiredPermissions,
- android.app.AppOpsManager.OP_NONE, null, false, false, userId);
+ am.broadcastIntentWithFeature(null, null, bcIntent, null, null, 0, null, null,
+ requiredPermissions, android.app.AppOpsManager.OP_NONE, null, false, false,
+ userId);
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -18781,7 +18784,7 @@ public class PackageManagerService extends IPackageManager.Stub
intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
try {
- am.broadcastIntent(null, intent, null, null,
+ am.broadcastIntentWithFeature(null, null, intent, null, null,
0, null, null, null, android.app.AppOpsManager.OP_NONE,
null, false, false, userId);
} catch (RemoteException e) {
@@ -23425,9 +23428,10 @@ public class PackageManagerService extends IPackageManager.Stub
@Override
public void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
Intent origIntent, String resolvedType, String callingPackage,
- boolean isRequesterInstantApp, Bundle verificationBundle, int userId) {
- PackageManagerService.this.requestInstantAppResolutionPhaseTwo(
- responseObj, origIntent, resolvedType, callingPackage, isRequesterInstantApp,
+ @Nullable String callingFeatureId, boolean isRequesterInstantApp,
+ Bundle verificationBundle, int userId) {
+ PackageManagerService.this.requestInstantAppResolutionPhaseTwo(responseObj, origIntent,
+ resolvedType, callingPackage, callingFeatureId, isRequesterInstantApp,
verificationBundle, userId);
}
@@ -24337,8 +24341,9 @@ public class PackageManagerService extends IPackageManager.Stub
Manifest.permission.RECEIVE_DEVICE_CUSTOMIZATION_READY,
};
try {
- am.broadcastIntent(null, intent, null, null, 0, null, null, requiredPermissions,
- android.app.AppOpsManager.OP_NONE, null, false, false, UserHandle.USER_ALL);
+ am.broadcastIntentWithFeature(null, null, intent, null, null, 0, null, null,
+ requiredPermissions, android.app.AppOpsManager.OP_NONE, null, false, false,
+ UserHandle.USER_ALL);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index ede04f3bbb14..4b2dc85c6667 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -5195,7 +5195,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final Intent dock = createHomeDockIntent();
if (dock != null) {
int result = ActivityTaskManager.getService()
- .startActivityAsUser(null, mContext.getBasePackageName(), dock,
+ .startActivityAsUser(null, mContext.getBasePackageName(),
+ mContext.getFeatureId(), dock,
dock.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0,
ActivityManager.START_FLAG_ONLY_IF_NEEDED,
@@ -5206,7 +5207,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
int result = ActivityTaskManager.getService()
- .startActivityAsUser(null, mContext.getBasePackageName(), mHomeIntent,
+ .startActivityAsUser(null, mContext.getBasePackageName(),
+ mContext.getFeatureId(), mHomeIntent,
mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0,
ActivityManager.START_FLAG_ONLY_IF_NEEDED,
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index a54f5d43751c..ad57e1f675d5 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -362,6 +362,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
private static final String TAG_PERSISTABLEBUNDLE = "persistable_bundle";
private static final String ATTR_LAUNCHEDFROMUID = "launched_from_uid";
private static final String ATTR_LAUNCHEDFROMPACKAGE = "launched_from_package";
+ private static final String ATTR_LAUNCHEDFROMFEATURE = "launched_from_feature";
private static final String ATTR_RESOLVEDTYPE = "resolved_type";
private static final String ATTR_COMPONENTSPECIFIED = "component_specified";
static final String ACTIVITY_ICON_SUFFIX = "_activity_icon_";
@@ -422,6 +423,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
final int launchedFromPid; // always the pid who started the activity.
final int launchedFromUid; // always the uid who started the activity.
final String launchedFromPackage; // always the package who started the activity.
+ final @Nullable String launchedFromFeatureId; // always the feature in launchedFromPackage
final Intent intent; // the original intent that generated us
final String shortComponentName; // the short component name of the intent
final String resolvedType; // as per original caller;
@@ -773,6 +775,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
pw.print(" processName="); pw.println(processName);
pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid);
pw.print(" launchedFromPackage="); pw.print(launchedFromPackage);
+ pw.print(" launchedFromFeature="); pw.print(launchedFromFeatureId);
pw.print(" userId="); pw.println(mUserId);
pw.print(prefix); pw.print("app="); pw.println(app);
pw.print(prefix); pw.println(intent.toInsecureString());
@@ -1483,9 +1486,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
ActivityRecord(ActivityTaskManagerService _service, WindowProcessController _caller,
- int _launchedFromPid, int _launchedFromUid, String _launchedFromPackage, Intent _intent,
- String _resolvedType, ActivityInfo aInfo, Configuration _configuration,
- ActivityRecord _resultTo, String _resultWho, int _reqCode, boolean _componentSpecified,
+ int _launchedFromPid, int _launchedFromUid, String _launchedFromPackage,
+ @Nullable String _launchedFromFeature, Intent _intent, String _resolvedType,
+ ActivityInfo aInfo, Configuration _configuration, ActivityRecord _resultTo,
+ String _resultWho, int _reqCode, boolean _componentSpecified,
boolean _rootVoiceInteraction, ActivityStackSupervisor supervisor,
ActivityOptions options, ActivityRecord sourceRecord) {
super(_service.mWindowManager, new Token(_intent).asBinder(), TYPE_APPLICATION, true,
@@ -1564,6 +1568,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
launchedFromPid = _launchedFromPid;
launchedFromUid = _launchedFromUid;
launchedFromPackage = _launchedFromPackage;
+ launchedFromFeatureId = _launchedFromFeature;
shortComponentName = _intent.getComponent().flattenToShortString();
resolvedType = _resolvedType;
componentSpecified = _componentSpecified;
@@ -2284,7 +2289,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
* @return Whether AppOps allows this package to enter picture-in-picture.
*/
private boolean checkEnterPictureInPictureAppOpsState() {
- return mAtmService.getAppOpsService().checkOperation(
+ return mAtmService.getAppOpsManager().checkOpNoThrow(
OP_PICTURE_IN_PICTURE, info.applicationInfo.uid, packageName) == MODE_ALLOWED;
}
@@ -7282,6 +7287,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (launchedFromPackage != null) {
out.attribute(null, ATTR_LAUNCHEDFROMPACKAGE, launchedFromPackage);
}
+ if (launchedFromFeatureId != null) {
+ out.attribute(null, ATTR_LAUNCHEDFROMFEATURE, launchedFromFeatureId);
+ }
if (resolvedType != null) {
out.attribute(null, ATTR_RESOLVEDTYPE, resolvedType);
}
@@ -7309,6 +7317,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
PersistableBundle persistentState = null;
int launchedFromUid = 0;
String launchedFromPackage = null;
+ String launchedFromFeature = null;
String resolvedType = null;
boolean componentSpecified = false;
int userId = 0;
@@ -7327,6 +7336,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
launchedFromUid = Integer.parseInt(attrValue);
} else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) {
launchedFromPackage = attrValue;
+ } else if (ATTR_LAUNCHEDFROMFEATURE.equals(attrName)) {
+ launchedFromFeature = attrValue;
} else if (ATTR_RESOLVEDTYPE.equals(attrName)) {
resolvedType = attrValue;
} else if (ATTR_COMPONENTSPECIFIED.equals(attrName)) {
@@ -7374,10 +7385,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
" resolvedType=" + resolvedType);
}
final ActivityRecord r = new ActivityRecord(service, null /* caller */,
- 0 /* launchedFromPid */, launchedFromUid, launchedFromPackage, intent, resolvedType,
- aInfo, service.getConfiguration(), null /* resultTo */, null /* resultWho */,
- 0 /* reqCode */, componentSpecified, false /* rootVoiceInteraction */,
- stackSupervisor, null /* options */, null /* sourceRecord */);
+ 0 /* launchedFromPid */, launchedFromUid, launchedFromPackage, launchedFromFeature,
+ intent, resolvedType, aInfo, service.getConfiguration(), null /* resultTo */,
+ null /* resultWho */, 0 /* reqCode */, componentSpecified,
+ false /* rootVoiceInteraction */, stackSupervisor, null /* options */,
+ null /* sourceRecord */);
r.mPersistentState = persistentState;
r.taskDescription = taskDescription;
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index d380f8cd7337..9030fce7cfcc 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -135,6 +135,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static java.lang.Integer.MAX_VALUE;
import android.annotation.IntDef;
+import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
@@ -622,7 +623,7 @@ class ActivityStack extends Task implements BoundsAnimationTarget {
true /*neverRelinquishIdentity*/,
_taskDescription != null ? _taskDescription : new ActivityManager.TaskDescription(),
id, INVALID_TASK_ID, INVALID_TASK_ID, 0 /*taskAffiliationColor*/,
- info.applicationInfo.uid, info.packageName, info.resizeMode,
+ info.applicationInfo.uid, info.packageName, null, info.resizeMode,
info.supportsPictureInPicture(), false /*_realActivitySuspended*/,
false /*userSetupComplete*/, INVALID_MIN_SIZE, INVALID_MIN_SIZE, info,
_voiceSession, _voiceInteractor, stack);
@@ -635,15 +636,16 @@ class ActivityStack extends Task implements BoundsAnimationTarget {
String _lastDescription, long lastTimeMoved, boolean neverRelinquishIdentity,
ActivityManager.TaskDescription _lastTaskDescription, int taskAffiliation,
int prevTaskId, int nextTaskId, int taskAffiliationColor, int callingUid,
- String callingPackage, int resizeMode, boolean supportsPictureInPicture,
- boolean _realActivitySuspended, boolean userSetupComplete, int minWidth, int minHeight,
+ String callingPackage, @Nullable String callingFeatureId, int resizeMode,
+ boolean supportsPictureInPicture, boolean _realActivitySuspended,
+ boolean userSetupComplete, int minWidth, int minHeight,
ActivityInfo info, IVoiceInteractionSession _voiceSession,
IVoiceInteractor _voiceInteractor, ActivityStack stack) {
super(atmService, id, _intent, _affinityIntent, _affinity, _rootAffinity,
_realActivity, _origActivity, _rootWasReset, _autoRemoveRecents, _askedCompatMode,
_userId, _effectiveUid, _lastDescription, lastTimeMoved, neverRelinquishIdentity,
_lastTaskDescription, taskAffiliation, prevTaskId, nextTaskId, taskAffiliationColor,
- callingUid, callingPackage, resizeMode, supportsPictureInPicture,
+ callingUid, callingPackage, callingFeatureId, resizeMode, supportsPictureInPicture,
_realActivitySuspended, userSetupComplete, minWidth, minHeight, info, _voiceSession,
_voiceInteractor, stack);
@@ -2924,6 +2926,7 @@ class ActivityStack extends Task implements BoundsAnimationTarget {
.setCallingPid(-1)
.setCallingUid(parent.launchedFromUid)
.setCallingPackage(parent.launchedFromPackage)
+ .setCallingFeatureId(parent.launchedFromFeatureId)
.setRealCallingPid(-1)
.setRealCallingUid(parent.launchedFromUid)
.setComponentSpecified(true)
diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
index a513ef8f3190..a582f2159dfc 100644
--- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
@@ -88,6 +88,7 @@ import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
import android.Manifest;
+import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
@@ -260,7 +261,9 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
/** Short cut */
private WindowManagerService mWindowManager;
- /** Common synchronization logic used to save things to disks. */
+ private AppOpsManager mAppOpsManager;
+
+ /** Common synchronization logic used to save things to disks. */
PersisterQueue mPersisterQueue;
LaunchParamsPersister mLaunchParamsPersister;
private LaunchParamsController mLaunchParamsController;
@@ -1047,8 +1050,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
boolean checkStartAnyActivityPermission(Intent intent, ActivityInfo aInfo, String resultWho,
int requestCode, int callingPid, int callingUid, String callingPackage,
- boolean ignoreTargetSecurity, boolean launchingInTask,
- WindowProcessController callerApp, ActivityRecord resultRecord,
+ @Nullable String callingFeatureId, boolean ignoreTargetSecurity,
+ boolean launchingInTask, WindowProcessController callerApp, ActivityRecord resultRecord,
ActivityStack resultStack) {
final boolean isCallerRecents = mService.getRecentTasks() != null
&& mService.getRecentTasks().isCallerRecents(callingUid);
@@ -1060,10 +1063,10 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
// existing task, then also allow the activity to be fully relaunched.
return true;
}
- final int componentRestriction = getComponentRestrictionForCallingPackage(
- aInfo, callingPackage, callingPid, callingUid, ignoreTargetSecurity);
+ final int componentRestriction = getComponentRestrictionForCallingPackage(aInfo,
+ callingPackage, callingFeatureId, callingPid, callingUid, ignoreTargetSecurity);
final int actionRestriction = getActionRestrictionForCallingPackage(
- intent.getAction(), callingPackage, callingPid, callingUid);
+ intent.getAction(), callingPackage, callingFeatureId, callingPid, callingUid);
if (componentRestriction == ACTIVITY_RESTRICTION_PERMISSION
|| actionRestriction == ACTIVITY_RESTRICTION_PERMISSION) {
if (resultRecord != null) {
@@ -1194,8 +1197,16 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
}
}
+ private AppOpsManager getAppOpsManager() {
+ if (mAppOpsManager == null) {
+ mAppOpsManager = mService.mContext.getSystemService(AppOpsManager.class);
+ }
+ return mAppOpsManager;
+ }
+
private int getComponentRestrictionForCallingPackage(ActivityInfo activityInfo,
- String callingPackage, int callingPid, int callingUid, boolean ignoreTargetSecurity) {
+ String callingPackage, @Nullable String callingFeatureId, int callingPid,
+ int callingUid, boolean ignoreTargetSecurity) {
if (!ignoreTargetSecurity && mService.checkComponentPermission(activityInfo.permission,
callingPid, callingUid, activityInfo.applicationInfo.uid, activityInfo.exported)
== PERMISSION_DENIED) {
@@ -1211,9 +1222,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
return ACTIVITY_RESTRICTION_NONE;
}
- // TODO moltmann b/136595429: Set featureId from caller
- if (mService.getAppOpsService().noteOperation(opCode, callingUid,
- callingPackage, /* featureId */ null, false, "") != AppOpsManager.MODE_ALLOWED) {
+ if (getAppOpsManager().noteOpNoThrow(opCode, callingUid,
+ callingPackage, callingFeatureId, "") != AppOpsManager.MODE_ALLOWED) {
if (!ignoreTargetSecurity) {
return ACTIVITY_RESTRICTION_APPOP;
}
@@ -1222,8 +1232,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
return ACTIVITY_RESTRICTION_NONE;
}
- private int getActionRestrictionForCallingPackage(String action,
- String callingPackage, int callingPid, int callingUid) {
+ private int getActionRestrictionForCallingPackage(String action, String callingPackage,
+ @Nullable String callingFeatureId, int callingPid, int callingUid) {
if (action == null) {
return ACTIVITY_RESTRICTION_NONE;
}
@@ -1256,9 +1266,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
return ACTIVITY_RESTRICTION_NONE;
}
- // TODO moltmann b/136595429: Set featureId from caller
- if (mService.getAppOpsService().noteOperation(opCode, callingUid,
- callingPackage, /* featureId */ null, false, "") != AppOpsManager.MODE_ALLOWED) {
+ if (getAppOpsManager().noteOpNoThrow(opCode, callingUid,
+ callingPackage, callingFeatureId, "") != AppOpsManager.MODE_ALLOWED) {
return ACTIVITY_RESTRICTION_APPOP;
}
@@ -2701,6 +2710,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
SafeActivityOptions options) {
Task task = null;
final String callingPackage;
+ final String callingFeatureId;
final Intent intent;
final int userId;
int activityType = ACTIVITY_TYPE_UNDEFINED;
@@ -2780,11 +2790,12 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
return ActivityManager.START_TASK_TO_FRONT;
}
callingPackage = task.mCallingPackage;
+ callingFeatureId = task.mCallingFeatureId;
intent = task.intent;
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
userId = task.mUserId;
- return mService.getActivityStartController().startActivityInPackage(
- task.mCallingUid, callingPid, callingUid, callingPackage, intent, null, null,
+ return mService.getActivityStartController().startActivityInPackage(task.mCallingUid,
+ callingPid, callingUid, callingPackage, callingFeatureId, intent, null, null,
null, 0, 0, options, userId, task, "startActivityFromRecents",
false /* validateIncomingUser */, null /* originatingPendingIntent */,
false /* allowBackgroundActivityStart */);
diff --git a/services/core/java/com/android/server/wm/ActivityStartController.java b/services/core/java/com/android/server/wm/ActivityStartController.java
index f35ba9e69ed7..881dc81807f5 100644
--- a/services/core/java/com/android/server/wm/ActivityStartController.java
+++ b/services/core/java/com/android/server/wm/ActivityStartController.java
@@ -26,6 +26,7 @@ import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.IApplicationThread;
import android.content.ComponentName;
@@ -278,10 +279,11 @@ public class ActivityStartController {
}
final int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
- String callingPackage, Intent intent, String resolvedType, IBinder resultTo,
- String resultWho, int requestCode, int startFlags, SafeActivityOptions options,
- int userId, Task inTask, String reason, boolean validateIncomingUser,
- PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart) {
+ String callingPackage, @Nullable String callingFeatureId, Intent intent,
+ String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, SafeActivityOptions options, int userId, Task inTask, String reason,
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
+ boolean allowBackgroundActivityStart) {
userId = checkTargetUser(userId, validateIncomingUser, realCallingPid, realCallingUid,
reason);
@@ -292,6 +294,7 @@ public class ActivityStartController {
.setRealCallingPid(realCallingPid)
.setRealCallingUid(realCallingUid)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setResultTo(resultTo)
.setResultWho(resultWho)
@@ -310,19 +313,20 @@ public class ActivityStartController {
*
* @param uid Make a call as if this UID did.
* @param callingPackage Make a call as if this package did.
+ * @param callingFeatureId Make a call as if this feature in the package did.
* @param intents Intents to start.
* @param userId Start the intents on this user.
* @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID.
* @param originatingPendingIntent PendingIntentRecord that originated this activity start or
* null if not originated by PendingIntent
*/
- final int startActivitiesInPackage(int uid, String callingPackage, Intent[] intents,
- String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
- boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
- boolean allowBackgroundActivityStart) {
+ final int startActivitiesInPackage(int uid, String callingPackage,
+ @Nullable String callingFeatureId, Intent[] intents, String[] resolvedTypes,
+ IBinder resultTo, SafeActivityOptions options, int userId, boolean validateIncomingUser,
+ PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart) {
return startActivitiesInPackage(uid, 0 /* realCallingPid */, -1 /* realCallingUid */,
- callingPackage, intents, resolvedTypes, resultTo, options, userId, validateIncomingUser,
- originatingPendingIntent, allowBackgroundActivityStart);
+ callingPackage, callingFeatureId, intents, resolvedTypes, resultTo, options, userId,
+ validateIncomingUser, originatingPendingIntent, allowBackgroundActivityStart);
}
/**
@@ -339,9 +343,9 @@ public class ActivityStartController {
* null if not originated by PendingIntent
*/
final int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid,
- String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo,
- SafeActivityOptions options, int userId, boolean validateIncomingUser,
- PendingIntentRecord originatingPendingIntent,
+ String callingPackage, @Nullable String callingFeatureId, Intent[] intents,
+ String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
boolean allowBackgroundActivityStart) {
final String reason = "startActivityInPackage";
@@ -350,14 +354,14 @@ public class ActivityStartController {
Binder.getCallingUid(), reason);
// TODO: Switch to user app stacks here.
- return startActivities(null, uid, realCallingPid, realCallingUid, callingPackage, intents,
- resolvedTypes, resultTo, options, userId, reason, originatingPendingIntent,
- allowBackgroundActivityStart);
+ return startActivities(null, uid, realCallingPid, realCallingUid, callingPackage,
+ callingFeatureId, intents, resolvedTypes, resultTo, options, userId, reason,
+ originatingPendingIntent, allowBackgroundActivityStart);
}
int startActivities(IApplicationThread caller, int callingUid, int incomingRealCallingPid,
- int incomingRealCallingUid, String callingPackage, Intent[] intents,
- String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options,
+ int incomingRealCallingUid, String callingPackage, @Nullable String callingFeatureId,
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options,
int userId, String reason, PendingIntentRecord originatingPendingIntent,
boolean allowBackgroundActivityStart) {
if (intents == null) {
@@ -435,6 +439,7 @@ public class ActivityStartController {
.setCallingPid(callingPid)
.setCallingUid(callingUid)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setRealCallingPid(realCallingPid)
.setRealCallingUid(realCallingUid)
.setActivityOptions(checkedOptions)
diff --git a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
index 76aa1d115ef6..100977187239 100644
--- a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
+++ b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
@@ -34,6 +34,7 @@ import static android.content.pm.ApplicationInfo.FLAG_SUSPENDED;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
+import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.KeyguardManager;
import android.app.admin.DevicePolicyManagerInternal;
@@ -85,6 +86,7 @@ class ActivityStartInterceptor {
private int mUserId;
private int mStartFlags;
private String mCallingPackage;
+ private @Nullable String mCallingFeatureId;
/*
* Per-intent states that were load from ActivityStarter and are subject to modifications
@@ -120,19 +122,20 @@ class ActivityStartInterceptor {
* method should not be changed during intercept.
*/
void setStates(int userId, int realCallingPid, int realCallingUid, int startFlags,
- String callingPackage) {
+ String callingPackage, @Nullable String callingFeatureId) {
mRealCallingPid = realCallingPid;
mRealCallingUid = realCallingUid;
mUserId = userId;
mStartFlags = startFlags;
mCallingPackage = callingPackage;
+ mCallingFeatureId = callingFeatureId;
}
private IntentSender createIntentSenderForOriginalIntent(int callingUid, int flags) {
Bundle activityOptions = deferCrossProfileAppsAnimationIfNecessary();
final IIntentSender target = mService.getIntentSenderLocked(
- INTENT_SENDER_ACTIVITY, mCallingPackage, callingUid, mUserId, null /*token*/,
- null /*resultCode*/, 0 /*requestCode*/,
+ INTENT_SENDER_ACTIVITY, mCallingPackage, mCallingFeatureId, callingUid, mUserId,
+ null /*token*/, null /*resultCode*/, 0 /*requestCode*/,
new Intent[] { mIntent }, new String[] { mResolvedType },
flags, activityOptions);
return new IntentSender(target);
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index c7270f257923..8ed798c766d2 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -318,6 +318,7 @@ class ActivityStarter {
int callingPid = DEFAULT_CALLING_PID;
int callingUid = DEFAULT_CALLING_UID;
String callingPackage;
+ @Nullable String callingFeatureId;
int realCallingPid = DEFAULT_REAL_CALLING_PID;
int realCallingUid = DEFAULT_REAL_CALLING_UID;
int startFlags;
@@ -367,6 +368,7 @@ class ActivityStarter {
callingPid = DEFAULT_CALLING_PID;
callingUid = DEFAULT_CALLING_UID;
callingPackage = null;
+ callingFeatureId = null;
realCallingPid = DEFAULT_REAL_CALLING_PID;
realCallingUid = DEFAULT_REAL_CALLING_UID;
startFlags = 0;
@@ -405,6 +407,7 @@ class ActivityStarter {
callingPid = request.callingPid;
callingUid = request.callingUid;
callingPackage = request.callingPackage;
+ callingFeatureId = request.callingFeatureId;
realCallingPid = request.realCallingPid;
realCallingUid = request.realCallingUid;
startFlags = request.startFlags;
@@ -693,9 +696,10 @@ class ActivityStarter {
}
final IIntentSender target = mService.getIntentSenderLocked(
- ActivityManager.INTENT_SENDER_ACTIVITY, "android" /* packageName */, appCallingUid,
- mRequest.userId, null /* token */, null /* resultWho*/, 0 /* requestCode*/,
- new Intent[] { mRequest.intent }, new String[] { mRequest.resolvedType },
+ ActivityManager.INTENT_SENDER_ACTIVITY, "android" /* packageName */,
+ null /* featureId */, appCallingUid, mRequest.userId, null /* token */,
+ null /* resultWho*/, 0 /* requestCode*/, new Intent[]{mRequest.intent},
+ new String[]{mRequest.resolvedType},
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT,
null /* bOptions */);
@@ -807,6 +811,7 @@ class ActivityStarter {
int callingPid = request.callingPid;
int callingUid = request.callingUid;
String callingPackage = request.callingPackage;
+ String callingFeatureId = request.callingFeatureId;
final int realCallingPid = request.realCallingPid;
final int realCallingUid = request.realCallingUid;
final int startFlags = request.startFlags;
@@ -882,6 +887,7 @@ class ActivityStarter {
// we want the final activity to consider it to have been launched by the
// previous app activity.
callingPackage = sourceRecord.launchedFromPackage;
+ callingFeatureId = sourceRecord.launchedFromFeatureId;
}
}
@@ -949,8 +955,8 @@ class ActivityStarter {
}
boolean abort = !mSupervisor.checkStartAnyActivityPermission(intent, aInfo, resultWho,
- requestCode, callingPid, callingUid, callingPackage, request.ignoreTargetSecurity,
- inTask != null, callerApp, resultRecord, resultStack);
+ requestCode, callingPid, callingUid, callingPackage, callingFeatureId,
+ request.ignoreTargetSecurity, inTask != null, callerApp, resultRecord, resultStack);
abort |= !mService.mIntentFirewall.checkStartActivity(intent, callingUid,
callingPid, resolvedType, aInfo.applicationInfo);
abort |= !mService.getPermissionPolicyInternal().checkStartActivity(intent, callingUid,
@@ -990,7 +996,8 @@ class ActivityStarter {
}
}
- mInterceptor.setStates(userId, realCallingPid, realCallingUid, startFlags, callingPackage);
+ mInterceptor.setStates(userId, realCallingPid, realCallingUid, startFlags, callingPackage,
+ callingFeatureId);
if (mInterceptor.intercept(intent, rInfo, aInfo, resolvedType, inTask, callingPid,
callingUid, checkedOptions)) {
// activity start was intercepted, e.g. because the target user is currently in quiet
@@ -1023,7 +1030,7 @@ class ActivityStarter {
if (mService.getPackageManagerInternalLocked().isPermissionsReviewRequired(
aInfo.packageName, userId)) {
final IIntentSender target = mService.getIntentSenderLocked(
- ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage,
+ ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, callingFeatureId,
callingUid, userId, null, null, 0, new Intent[]{intent},
new String[]{resolvedType}, PendingIntent.FLAG_CANCEL_CURRENT
| PendingIntent.FLAG_ONE_SHOT, null);
@@ -1081,7 +1088,7 @@ class ActivityStarter {
// app [on install success].
if (rInfo != null && rInfo.auxiliaryInfo != null) {
intent = createLaunchIntent(rInfo.auxiliaryInfo, request.ephemeralIntent,
- callingPackage, verificationBundle, resolvedType, userId);
+ callingPackage, callingFeatureId, verificationBundle, resolvedType, userId);
resolvedType = null;
callingUid = realCallingUid;
callingPid = realCallingPid;
@@ -1090,9 +1097,10 @@ class ActivityStarter {
}
final ActivityRecord r = new ActivityRecord(mService, callerApp, callingPid, callingUid,
- callingPackage, intent, resolvedType, aInfo, mService.getGlobalConfiguration(),
- resultRecord, resultWho, requestCode, request.componentSpecified,
- voiceSession != null, mSupervisor, checkedOptions, sourceRecord);
+ callingPackage, callingFeatureId, intent, resolvedType, aInfo,
+ mService.getGlobalConfiguration(), resultRecord, resultWho, requestCode,
+ request.componentSpecified, voiceSession != null, mSupervisor, checkedOptions,
+ sourceRecord);
mLastStartActivityRecord = r;
if (r.appTimeTracker == null && sourceRecord != null) {
@@ -1302,21 +1310,22 @@ class ActivityStarter {
* Creates a launch intent for the given auxiliary resolution data.
*/
private @NonNull Intent createLaunchIntent(@Nullable AuxiliaryResolveInfo auxiliaryResponse,
- Intent originalIntent, String callingPackage, Bundle verificationBundle,
- String resolvedType, int userId) {
+ Intent originalIntent, String callingPackage, @Nullable String callingFeatureId,
+ Bundle verificationBundle, String resolvedType, int userId) {
if (auxiliaryResponse != null && auxiliaryResponse.needsPhaseTwo) {
// request phase two resolution
PackageManagerInternal packageManager = mService.getPackageManagerInternalLocked();
boolean isRequesterInstantApp = packageManager.isInstantApp(callingPackage, userId);
packageManager.requestInstantAppResolutionPhaseTwo(
auxiliaryResponse, originalIntent, resolvedType, callingPackage,
- isRequesterInstantApp, verificationBundle, userId);
+ callingFeatureId, isRequesterInstantApp, verificationBundle, userId);
}
return InstantAppResolver.buildEphemeralInstallerIntent(
originalIntent,
InstantAppResolver.sanitizeIntent(originalIntent),
auxiliaryResponse == null ? null : auxiliaryResponse.failureIntent,
callingPackage,
+ callingFeatureId,
verificationBundle,
resolvedType,
userId,
@@ -2575,6 +2584,11 @@ class ActivityStarter {
return this;
}
+ ActivityStarter setCallingFeatureId(String callingFeatureId) {
+ mRequest.callingFeatureId = callingFeatureId;
+ return this;
+ }
+
/**
* Sets the pid of the caller who requested to launch the activity.
*
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
index 25f6d6fd5ca6..7302e529c1eb 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
@@ -182,14 +182,15 @@ public abstract class ActivityTaskManagerInternal {
public abstract void notifySingleTaskDisplayDrawn(int displayId);
/**
- * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
+ * Start activity {@code intents} as if {@code packageName/featureId} on user {@code userId} did
+ * it.
*
* - DO NOT call it with the calling UID cleared.
* - All the necessary caller permission checks must be done at callsites.
*
* @return error codes used by {@link IActivityManager#startActivity} and its siblings.
*/
- public abstract int startActivitiesAsPackage(String packageName,
+ public abstract int startActivitiesAsPackage(String packageName, String featureId,
int userId, Intent[] intents, Bundle bOptions);
/**
@@ -199,6 +200,7 @@ public abstract class ActivityTaskManagerInternal {
* @param realCallingPid PID of the real caller.
* @param realCallingUid UID of the real caller.
* @param callingPackage Make a call as if this package did.
+ * @param callingFeatureId Make a call as if this feature in the package did.
* @param intents Intents to start.
* @param userId Start the intents on this user.
* @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID.
@@ -208,16 +210,17 @@ public abstract class ActivityTaskManagerInternal {
* from originatingPendingIntent
*/
public abstract int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid,
- String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo,
- SafeActivityOptions options, int userId, boolean validateIncomingUser,
- PendingIntentRecord originatingPendingIntent,
+ String callingPackage, @Nullable String callingFeatureId, Intent[] intents,
+ String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
boolean allowBackgroundActivityStart);
public abstract int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
- String callingPackage, Intent intent, String resolvedType, IBinder resultTo,
- String resultWho, int requestCode, int startFlags, SafeActivityOptions options,
- int userId, Task inTask, String reason, boolean validateIncomingUser,
- PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart);
+ String callingPackage, @Nullable String callingFeaturId, Intent intent,
+ String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, SafeActivityOptions options, int userId, Task inTask, String reason,
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
+ boolean allowBackgroundActivityStart);
/**
* Start activity {@code intent} without calling user-id check.
@@ -228,7 +231,7 @@ public abstract class ActivityTaskManagerInternal {
* @return error codes used by {@link IActivityManager#startActivity} and its siblings.
*/
public abstract int startActivityAsUser(IApplicationThread caller, String callingPackage,
- Intent intent, @Nullable Bundle options, int userId);
+ @Nullable String callingFeatureId, Intent intent, @Nullable Bundle options, int userId);
/**
* Called when Keyguard flags might have changed.
@@ -388,7 +391,7 @@ public abstract class ActivityTaskManagerInternal {
public abstract ActivityTokens getTopActivityForTask(int taskId);
public abstract IIntentSender getIntentSender(int type, String packageName,
- int callingUid, int userId, IBinder token, String resultWho,
+ @Nullable String featureId, int callingUid, int userId, IBinder token, String resultWho,
int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
Bundle bOptions);
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 5f3e3a39490c..ea5a71a7200e 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -234,7 +234,6 @@ import android.view.WindowManager;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.AssistUtils;
-import com.android.internal.app.IAppOpsService;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.ProcessMap;
import com.android.internal.logging.MetricsLogger;
@@ -264,7 +263,6 @@ import com.android.server.am.BaseErrorDialog;
import com.android.server.am.PendingIntentController;
import com.android.server.am.PendingIntentRecord;
import com.android.server.am.UserState;
-import com.android.server.appop.AppOpsService;
import com.android.server.firewall.IntentFirewall;
import com.android.server.inputmethod.InputMethodSystemProperty;
import com.android.server.pm.UserManagerService;
@@ -378,7 +376,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
RootWindowContainer mRootWindowContainer;
WindowManagerService mWindowManager;
private UserManagerService mUserManager;
- private AppOpsService mAppOpsService;
+ private AppOpsManager mAppOpsManager;
/** All active uids in the system. */
private final MirrorActiveUids mActiveUids = new MirrorActiveUids();
private final SparseArray<String> mPendingTempWhitelist = new SparseArray<>();
@@ -891,12 +889,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return mUserManager;
}
- AppOpsService getAppOpsService() {
- if (mAppOpsService == null) {
- IBinder b = ServiceManager.getService(Context.APP_OPS_SERVICE);
- mAppOpsService = (AppOpsService) IAppOpsService.Stub.asInterface(b);
+ AppOpsManager getAppOpsManager() {
+ if (mAppOpsManager == null) {
+ mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
}
- return mAppOpsService;
+ return mAppOpsManager;
}
boolean hasUserRestriction(String restriction, int userId) {
@@ -904,8 +901,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
boolean hasSystemAlertWindowPermission(int callingUid, int callingPid, String callingPackage) {
- final int mode = getAppOpsService().noteOperation(AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
- callingUid, callingPackage, /* featureId */ null, false, "");
+ final int mode = getAppOpsManager().noteOpNoThrow(AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
+ callingUid, callingPackage, /* featureId */ null, "");
if (mode == AppOpsManager.MODE_DEFAULT) {
return checkPermission(Manifest.permission.SYSTEM_ALERT_WINDOW, callingPid, callingUid)
== PERMISSION_GRANTED;
@@ -1025,41 +1022,43 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
@Override
public final int startActivity(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) {
- return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
- resultWho, requestCode, startFlags, profilerInfo, bOptions,
+ String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo,
+ Bundle bOptions) {
+ return startActivityAsUser(caller, callingPackage, callingFeatureId, intent, resolvedType,
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions,
UserHandle.getCallingUserId());
}
@Override
public final int startActivities(IApplicationThread caller, String callingPackage,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle bOptions,
- int userId) {
+ String callingFeatureId, Intent[] intents, String[] resolvedTypes, IBinder resultTo,
+ Bundle bOptions, int userId) {
assertPackageMatchesCallingUid(callingPackage);
final String reason = "startActivities";
enforceNotIsolatedCaller(reason);
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, reason);
// TODO: Switch to user app stacks here.
return getActivityStartController().startActivities(caller, -1, 0, -1, callingPackage,
- intents, resolvedTypes, resultTo, SafeActivityOptions.fromBundle(bOptions), userId,
- reason, null /* originatingPendingIntent */,
- false /* allowBackgroundActivityStart */);
+ callingFeatureId, intents, resolvedTypes, resultTo,
+ SafeActivityOptions.fromBundle(bOptions), userId, reason,
+ null /* originatingPendingIntent */, false /* allowBackgroundActivityStart */);
}
@Override
public int startActivityAsUser(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
- return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
- resultWho, requestCode, startFlags, profilerInfo, bOptions, userId,
+ String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo,
+ Bundle bOptions, int userId) {
+ return startActivityAsUser(caller, callingPackage, callingFeatureId, intent, resolvedType,
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions, userId,
true /*validateIncomingUser*/);
}
private int startActivityAsUser(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId,
- boolean validateIncomingUser) {
+ @Nullable String callingFeatureId, Intent intent, String resolvedType,
+ IBinder resultTo, String resultWho, int requestCode, int startFlags,
+ ProfilerInfo profilerInfo, Bundle bOptions, int userId, boolean validateIncomingUser) {
assertPackageMatchesCallingUid(callingPackage);
enforceNotIsolatedCaller("startActivityAsUser");
@@ -1070,6 +1069,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return getActivityStartController().obtainStarter(intent, "startActivityAsUser")
.setCaller(caller)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setResultTo(resultTo)
.setResultWho(resultWho)
@@ -1215,6 +1215,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
.setCallingPid(-1)
.setCallingUid(r.launchedFromUid)
.setCallingPackage(r.launchedFromPackage)
+ .setCallingFeatureId(r.launchedFromFeatureId)
.setRealCallingPid(-1)
.setRealCallingUid(r.launchedFromUid)
.setActivityOptions(options)
@@ -1231,8 +1232,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
@Override
public final WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
+ String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo,
+ Bundle bOptions, int userId) {
assertPackageMatchesCallingUid(callingPackage);
final WaitResult res = new WaitResult();
enforceNotIsolatedCaller("startActivityAndWait");
@@ -1242,6 +1244,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
getActivityStartController().obtainStarter(intent, "startActivityAndWait")
.setCaller(caller)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setResultTo(resultTo)
.setResultWho(resultWho)
@@ -1257,8 +1260,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
@Override
public final int startActivityWithConfig(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, Configuration config, Bundle bOptions, int userId) {
+ String callingFeatureId, Intent intent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int startFlags, Configuration config,
+ Bundle bOptions, int userId) {
assertPackageMatchesCallingUid(callingPackage);
enforceNotIsolatedCaller("startActivityWithConfig");
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
@@ -1267,6 +1271,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return getActivityStartController().obtainStarter(intent, "startActivityWithConfig")
.setCaller(caller)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setResultTo(resultTo)
.setResultWho(resultWho)
@@ -1317,6 +1322,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
final ActivityRecord sourceRecord;
final int targetUid;
final String targetPackage;
+ final String targetFeatureId;
final boolean isResolver;
synchronized (mGlobalLock) {
if (resultTo == null) {
@@ -1384,6 +1390,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
targetUid = sourceRecord.launchedFromUid;
targetPackage = sourceRecord.launchedFromPackage;
+ targetFeatureId = sourceRecord.launchedFromFeatureId;
isResolver = sourceRecord.isResolverOrChildActivity();
}
@@ -1396,6 +1403,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return getActivityStartController().obtainStarter(intent, "startActivityAsCaller")
.setCallingUid(targetUid)
.setCallingPackage(targetPackage)
+ .setCallingFeatureId(targetFeatureId)
.setResolvedType(resolvedType)
.setResultTo(resultTo)
.setResultWho(resultWho)
@@ -1431,8 +1439,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
@Override
- public int startVoiceActivity(String callingPackage, int callingPid, int callingUid,
- Intent intent, String resolvedType, IVoiceInteractionSession session,
+ public int startVoiceActivity(String callingPackage, String callingFeatureId, int callingPid,
+ int callingUid, Intent intent, String resolvedType, IVoiceInteractionSession session,
IVoiceInteractor interactor, int startFlags, ProfilerInfo profilerInfo,
Bundle bOptions, int userId) {
assertPackageMatchesCallingUid(callingPackage);
@@ -1445,6 +1453,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return getActivityStartController().obtainStarter(intent, "startVoiceActivity")
.setCallingUid(callingUid)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setVoiceSession(session)
.setVoiceInteractor(interactor)
@@ -1457,8 +1466,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
@Override
- public int startAssistantActivity(String callingPackage, int callingPid, int callingUid,
- Intent intent, String resolvedType, Bundle bOptions, int userId) {
+ public int startAssistantActivity(String callingPackage, @NonNull String callingFeatureId,
+ int callingPid, int callingUid, Intent intent, String resolvedType, Bundle bOptions,
+ int userId) {
assertPackageMatchesCallingUid(callingPackage);
mAmInternal.enforceCallingPermission(BIND_VOICE_INTERACTION, "startAssistantActivity()");
userId = handleIncomingUser(callingPid, callingUid, userId, "startAssistantActivity");
@@ -1466,6 +1476,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return getActivityStartController().obtainStarter(intent, "startAssistantActivity")
.setCallingUid(callingUid)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setActivityOptions(bOptions)
.setUserId(userId)
@@ -1489,13 +1500,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
try {
synchronized (mGlobalLock) {
final ComponentName recentsComponent = mRecentTasks.getRecentsComponent();
+ final String recentsFeatureId = mRecentTasks.getRecentsComponentFeatureId();
final int recentsUid = mRecentTasks.getRecentsComponentUid();
final WindowProcessController caller = getProcessController(callingPid, callingUid);
// Start a new recents animation
final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
getActivityStartController(), mWindowManager, intent, recentsComponent,
- recentsUid, caller);
+ recentsFeatureId, recentsUid, caller);
if (recentsAnimationRunner == null) {
anim.preloadRecentsActivity();
} else {
@@ -5773,9 +5785,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
- IIntentSender getIntentSenderLocked(int type, String packageName, int callingUid, int userId,
- IBinder token, String resultWho, int requestCode, Intent[] intents,
- String[] resolvedTypes, int flags, Bundle bOptions) {
+ IIntentSender getIntentSenderLocked(int type, String packageName, String featureId,
+ int callingUid, int userId, IBinder token, String resultWho, int requestCode,
+ Intent[] intents, String[] resolvedTypes, int flags, Bundle bOptions) {
ActivityRecord activity = null;
if (type == ActivityManager.INTENT_SENDER_ACTIVITY_RESULT) {
@@ -5791,8 +5803,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
final PendingIntentRecord rec = mPendingIntentController.getIntentSender(type, packageName,
- callingUid, userId, token, resultWho, requestCode, intents, resolvedTypes, flags,
- bOptions);
+ featureId, callingUid, userId, token, resultWho, requestCode, intents,
+ resolvedTypes, flags, bOptions);
final boolean noCreate = (flags & PendingIntent.FLAG_NO_CREATE) != 0;
if (noCreate) {
return rec;
@@ -6180,8 +6192,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
@Override
- public int startActivitiesAsPackage(String packageName, int userId, Intent[] intents,
- Bundle bOptions) {
+ public int startActivitiesAsPackage(String packageName, @Nullable String featureId,
+ int userId, Intent[] intents, Bundle bOptions) {
Objects.requireNonNull(intents, "intents");
final String[] resolvedTypes = new String[intents.length];
@@ -6206,7 +6218,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
return getActivityStartController().startActivitiesInPackage(
- packageUid, packageName,
+ packageUid, packageName, featureId,
intents, resolvedTypes, null /* resultTo */,
SafeActivityOptions.fromBundle(bOptions), userId,
false /* validateIncomingUser */, null /* originatingPendingIntent */,
@@ -6215,41 +6227,41 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
@Override
public int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid,
- String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo,
- SafeActivityOptions options, int userId, boolean validateIncomingUser,
- PendingIntentRecord originatingPendingIntent,
+ String callingPackage, @Nullable String callingFeatureId, Intent[] intents,
+ String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
boolean allowBackgroundActivityStart) {
assertPackageMatchesCallingUid(callingPackage);
synchronized (mGlobalLock) {
return getActivityStartController().startActivitiesInPackage(uid, realCallingPid,
- realCallingUid, callingPackage, intents, resolvedTypes, resultTo, options,
- userId, validateIncomingUser, originatingPendingIntent,
+ realCallingUid, callingPackage, callingFeatureId, intents, resolvedTypes,
+ resultTo, options, userId, validateIncomingUser, originatingPendingIntent,
allowBackgroundActivityStart);
}
}
@Override
public int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
- String callingPackage, Intent intent, String resolvedType, IBinder resultTo,
- String resultWho, int requestCode, int startFlags, SafeActivityOptions options,
- int userId, Task inTask, String reason, boolean validateIncomingUser,
- PendingIntentRecord originatingPendingIntent,
+ String callingPackage, @Nullable String callingFeatureId, Intent intent,
+ String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, SafeActivityOptions options, int userId, Task inTask, String reason,
+ boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
boolean allowBackgroundActivityStart) {
assertPackageMatchesCallingUid(callingPackage);
synchronized (mGlobalLock) {
return getActivityStartController().startActivityInPackage(uid, realCallingPid,
- realCallingUid, callingPackage, intent, resolvedType, resultTo, resultWho,
- requestCode, startFlags, options, userId, inTask, reason,
- validateIncomingUser, originatingPendingIntent,
+ realCallingUid, callingPackage, callingFeatureId, intent, resolvedType,
+ resultTo, resultWho, requestCode, startFlags, options, userId, inTask,
+ reason, validateIncomingUser, originatingPendingIntent,
allowBackgroundActivityStart);
}
}
@Override
- public int startActivityAsUser(IApplicationThread caller, String callerPacakge,
- Intent intent, Bundle options, int userId) {
+ public int startActivityAsUser(IApplicationThread caller, String callerPackage,
+ @Nullable String callerFeatureId, Intent intent, Bundle options, int userId) {
return ActivityTaskManagerService.this.startActivityAsUser(
- caller, callerPacakge, intent,
+ caller, callerPackage, callerFeatureId, intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options, userId,
false /*validateIncomingUser*/);
@@ -6685,12 +6697,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
@Override
public IIntentSender getIntentSender(int type, String packageName,
- int callingUid, int userId, IBinder token, String resultWho,
- int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
- Bundle bOptions) {
+ @Nullable String featureId, int callingUid, int userId, IBinder token,
+ String resultWho, int requestCode, Intent[] intents, String[] resolvedTypes,
+ int flags, Bundle bOptions) {
synchronized (mGlobalLock) {
- return getIntentSenderLocked(type, packageName, callingUid, userId, token,
- resultWho, requestCode, intents, resolvedTypes, flags, bOptions);
+ return getIntentSenderLocked(type, packageName, featureId, callingUid, userId,
+ token, resultWho, requestCode, intents, resolvedTypes, flags, bOptions);
}
}
diff --git a/services/core/java/com/android/server/wm/AppTaskImpl.java b/services/core/java/com/android/server/wm/AppTaskImpl.java
index 16a75645f9ae..8fa811915fc2 100644
--- a/services/core/java/com/android/server/wm/AppTaskImpl.java
+++ b/services/core/java/com/android/server/wm/AppTaskImpl.java
@@ -125,7 +125,7 @@ class AppTaskImpl extends IAppTask.Stub {
}
@Override
- public int startActivity(IBinder whoThread, String callingPackage,
+ public int startActivity(IBinder whoThread, String callingPackage, String callingFeatureId,
Intent intent, String resolvedType, Bundle bOptions) {
checkCaller();
mService.assertPackageMatchesCallingUid(callingPackage);
@@ -148,6 +148,7 @@ class AppTaskImpl extends IAppTask.Stub {
return mService.getActivityStartController().obtainStarter(intent, "AppTaskImpl")
.setCaller(appThread)
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setResolvedType(resolvedType)
.setActivityOptions(bOptions)
.setUserId(callingUser)
diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java
index a9dc36d91a3f..3771b3ee9dc9 100644
--- a/services/core/java/com/android/server/wm/RecentTasks.java
+++ b/services/core/java/com/android/server/wm/RecentTasks.java
@@ -42,6 +42,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_TASKS
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
@@ -155,6 +156,7 @@ class RecentTasks {
*/
private int mRecentsUid = -1;
private ComponentName mRecentsComponent = null;
+ private @Nullable String mFeatureId;
/**
* Mapping of user id -> whether recent tasks have been loaded for that user.
@@ -418,6 +420,13 @@ class RecentTasks {
}
/**
+ * @return the featureId for the recents component.
+ */
+ @Nullable String getRecentsComponentFeatureId() {
+ return mFeatureId;
+ }
+
+ /**
* @return the uid for the recents component.
*/
int getRecentsComponentUid() {
diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java
index 9770947ff2c3..b0492be5f542 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimation.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimation.java
@@ -63,6 +63,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
private final DisplayContent mDefaultDisplay;
private final Intent mTargetIntent;
private final ComponentName mRecentsComponent;
+ private final @Nullable String mRecentsFeatureId;
private final int mRecentsUid;
private final @Nullable WindowProcessController mCaller;
private final int mUserId;
@@ -80,8 +81,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
RecentsAnimation(ActivityTaskManagerService atm, ActivityStackSupervisor stackSupervisor,
ActivityStartController activityStartController, WindowManagerService wm,
- Intent targetIntent, ComponentName recentsComponent, int recentsUid,
- @Nullable WindowProcessController caller) {
+ Intent targetIntent, ComponentName recentsComponent, @Nullable String recentsFeatureId,
+ int recentsUid, @Nullable WindowProcessController caller) {
mService = atm;
mStackSupervisor = stackSupervisor;
mDefaultDisplay = mService.mRootWindowContainer.getDefaultDisplay();
@@ -89,6 +90,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
mWindowManager = wm;
mTargetIntent = targetIntent;
mRecentsComponent = recentsComponent;
+ mRecentsFeatureId = recentsFeatureId;
mRecentsUid = recentsUid;
mCaller = caller;
mUserId = atm.getCurrentUserId();
@@ -456,6 +458,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
.obtainStarter(mTargetIntent, reason)
.setCallingUid(mRecentsUid)
.setCallingPackage(mRecentsComponent.getPackageName())
+ .setCallingFeatureId(mRecentsFeatureId)
.setActivityOptions(new SafeActivityOptions(options))
.setUserId(mUserId)
.execute();
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 302e7596dec4..9fb8e2f4e3da 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -183,6 +183,7 @@ class Task extends WindowContainer<WindowContainer> {
private static final String ATTR_TASK_AFFILIATION_COLOR = "task_affiliation_color";
private static final String ATTR_CALLING_UID = "calling_uid";
private static final String ATTR_CALLING_PACKAGE = "calling_package";
+ private static final String ATTR_CALLING_FEATURE_ID = "calling_feature_id";
private static final String ATTR_SUPPORTS_PICTURE_IN_PICTURE = "supports_picture_in_picture";
private static final String ATTR_RESIZE_MODE = "resize_mode";
private static final String ATTR_NON_FULLSCREEN_BOUNDS = "non_fullscreen_bounds";
@@ -296,6 +297,7 @@ class Task extends WindowContainer<WindowContainer> {
// For relaunching the task from recents as though it was launched by the original launcher.
int mCallingUid;
String mCallingPackage;
+ String mCallingFeatureId;
private final Rect mTmpStableBounds = new Rect();
private final Rect mTmpNonDecorBounds = new Rect();
@@ -477,8 +479,8 @@ class Task extends WindowContainer<WindowContainer> {
true /*neverRelinquishIdentity*/,
_taskDescription != null ? _taskDescription : new TaskDescription(),
_taskId, INVALID_TASK_ID, INVALID_TASK_ID, 0 /*taskAffiliationColor*/,
- info.applicationInfo.uid, info.packageName, info.resizeMode,
- info.supportsPictureInPicture(), false /*_realActivitySuspended*/,
+ info.applicationInfo.uid, info.packageName, null /* default featureId */,
+ info.resizeMode, info.supportsPictureInPicture(), false /*_realActivitySuspended*/,
false /*userSetupComplete*/, INVALID_MIN_SIZE, INVALID_MIN_SIZE, info,
_voiceSession, _voiceInteractor, stack);
}
@@ -500,18 +502,17 @@ class Task extends WindowContainer<WindowContainer> {
}
/** Don't use constructor directly. This is only used by XML parser. */
- Task(ActivityTaskManagerService atmService, int _taskId, Intent _intent,
- Intent _affinityIntent, String _affinity, String _rootAffinity,
- ComponentName _realActivity, ComponentName _origActivity, boolean _rootWasReset,
- boolean _autoRemoveRecents, boolean _askedCompatMode, int _userId,
- int _effectiveUid, String _lastDescription,
+ Task(ActivityTaskManagerService atmService, int _taskId, Intent _intent, Intent _affinityIntent,
+ String _affinity, String _rootAffinity, ComponentName _realActivity,
+ ComponentName _origActivity, boolean _rootWasReset, boolean _autoRemoveRecents,
+ boolean _askedCompatMode, int _userId, int _effectiveUid, String _lastDescription,
long lastTimeMoved, boolean neverRelinquishIdentity,
TaskDescription _lastTaskDescription, int taskAffiliation, int prevTaskId,
int nextTaskId, int taskAffiliationColor, int callingUid, String callingPackage,
- int resizeMode, boolean supportsPictureInPicture, boolean _realActivitySuspended,
- boolean userSetupComplete, int minWidth, int minHeight, ActivityInfo info,
- IVoiceInteractionSession _voiceSession, IVoiceInteractor _voiceInteractor,
- ActivityStack stack) {
+ @Nullable String callingFeatureId, int resizeMode, boolean supportsPictureInPicture,
+ boolean _realActivitySuspended, boolean userSetupComplete, int minWidth, int minHeight,
+ ActivityInfo info, IVoiceInteractionSession _voiceSession,
+ IVoiceInteractor _voiceInteractor, ActivityStack stack) {
super(atmService.mWindowManager);
EventLogTags.writeWmTaskCreated(_taskId, stack != null ? getRootTaskId() : INVALID_TASK_ID);
@@ -550,6 +551,7 @@ class Task extends WindowContainer<WindowContainer> {
mNextAffiliateTaskId = nextTaskId;
mCallingUid = callingUid;
mCallingPackage = callingPackage;
+ mCallingFeatureId = callingFeatureId;
mResizeMode = resizeMode;
if (info != null) {
setIntent(_intent, info);
@@ -896,6 +898,7 @@ class Task extends WindowContainer<WindowContainer> {
void setIntent(ActivityRecord r) {
mCallingUid = r.launchedFromUid;
mCallingPackage = r.launchedFromPackage;
+ mCallingFeatureId = r.launchedFromFeatureId;
setIntent(r.intent, r.info);
setLockTaskAuth(r);
@@ -1351,6 +1354,7 @@ class Task extends WindowContainer<WindowContainer> {
isPersistable = r.isPersistable();
mCallingUid = r.launchedFromUid;
mCallingPackage = r.launchedFromPackage;
+ mCallingFeatureId = r.launchedFromFeatureId;
// Clamp to [1, max].
maxRecents = Math.min(Math.max(r.info.maxRecents, 1),
ActivityTaskManager.getMaxAppRecentsLimitStatic());
@@ -3249,6 +3253,7 @@ class Task extends WindowContainer<WindowContainer> {
pw.print(" mCallingUid="); UserHandle.formatUid(pw, mCallingUid);
pw.print(" mUserSetupComplete="); pw.print(mUserSetupComplete);
pw.print(" mCallingPackage="); pw.println(mCallingPackage);
+ pw.print(" mCallingFeatureId="); pw.println(mCallingFeatureId);
if (affinity != null || rootAffinity != null) {
pw.print(prefix); pw.print("affinity="); pw.print(affinity);
if (affinity == null || !affinity.equals(rootAffinity)) {
@@ -3458,6 +3463,8 @@ class Task extends WindowContainer<WindowContainer> {
out.attribute(null, ATTR_NEXT_AFFILIATION, String.valueOf(mNextAffiliateTaskId));
out.attribute(null, ATTR_CALLING_UID, String.valueOf(mCallingUid));
out.attribute(null, ATTR_CALLING_PACKAGE, mCallingPackage == null ? "" : mCallingPackage);
+ out.attribute(null, ATTR_CALLING_FEATURE_ID,
+ mCallingFeatureId == null ? "" : mCallingFeatureId);
out.attribute(null, ATTR_RESIZE_MODE, String.valueOf(mResizeMode));
out.attribute(null, ATTR_SUPPORTS_PICTURE_IN_PICTURE,
String.valueOf(mSupportsPictureInPicture));
@@ -3571,16 +3578,17 @@ class Task extends WindowContainer<WindowContainer> {
long lastTimeMoved, boolean neverRelinquishIdentity,
TaskDescription lastTaskDescription, int taskAffiliation, int prevTaskId,
int nextTaskId, int taskAffiliationColor, int callingUid, String callingPackage,
- int resizeMode, boolean supportsPictureInPicture, boolean realActivitySuspended,
+ @Nullable String callingFeatureId, int resizeMode,
+ boolean supportsPictureInPicture, boolean realActivitySuspended,
boolean userSetupComplete, int minWidth, int minHeight, ActivityStack stack) {
return new ActivityStack(service, taskId, intent, affinityIntent, affinity,
rootAffinity, realActivity, origActivity, rootWasReset, autoRemoveRecents,
askedCompatMode, userId, effectiveUid, lastDescription,
lastTimeMoved, neverRelinquishIdentity, lastTaskDescription, taskAffiliation,
prevTaskId, nextTaskId, taskAffiliationColor, callingUid, callingPackage,
- resizeMode, supportsPictureInPicture, realActivitySuspended, userSetupComplete,
- minWidth, minHeight, null /*ActivityInfo*/, null /*_voiceSession*/,
- null /*_voiceInteractor*/, stack);
+ callingFeatureId, resizeMode, supportsPictureInPicture, realActivitySuspended,
+ userSetupComplete, minWidth, minHeight, null /*ActivityInfo*/,
+ null /*_voiceSession*/, null /*_voiceInteractor*/, stack);
}
Task restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor)
@@ -3613,6 +3621,7 @@ class Task extends WindowContainer<WindowContainer> {
int nextTaskId = INVALID_TASK_ID;
int callingUid = -1;
String callingPackage = "";
+ String callingFeatureId = null;
int resizeMode = RESIZE_MODE_FORCE_RESIZEABLE;
boolean supportsPictureInPicture = false;
Rect lastNonFullscreenBounds = null;
@@ -3693,6 +3702,9 @@ class Task extends WindowContainer<WindowContainer> {
case ATTR_CALLING_PACKAGE:
callingPackage = attrValue;
break;
+ case ATTR_CALLING_FEATURE_ID:
+ callingFeatureId = attrValue;
+ break;
case ATTR_RESIZE_MODE:
resizeMode = Integer.parseInt(attrValue);
break;
@@ -3794,8 +3806,8 @@ class Task extends WindowContainer<WindowContainer> {
autoRemoveRecents, askedCompatMode, userId, effectiveUid, lastDescription,
lastTimeOnTop, neverRelinquishIdentity, taskDescription,
taskAffiliation, prevTaskId, nextTaskId, taskAffiliationColor, callingUid,
- callingPackage, resizeMode, supportsPictureInPicture, realActivitySuspended,
- userSetupComplete, minWidth, minHeight, null /*stack*/);
+ callingPackage, callingFeatureId, resizeMode, supportsPictureInPicture,
+ realActivitySuspended, userSetupComplete, minWidth, minHeight, null /*stack*/);
task.mLastNonFullscreenBounds = lastNonFullscreenBounds;
task.setBounds(lastNonFullscreenBounds);
diff --git a/services/core/java/com/android/server/wm/TaskTile.java b/services/core/java/com/android/server/wm/TaskTile.java
index add11d69cbaa..369db05452f7 100644
--- a/services/core/java/com/android/server/wm/TaskTile.java
+++ b/services/core/java/com/android/server/wm/TaskTile.java
@@ -60,10 +60,11 @@ public class TaskTile extends ActivityStack {
System.currentTimeMillis(), true /*neverRelinquishIdentity*/,
new ActivityManager.TaskDescription(), id, INVALID_TASK_ID, INVALID_TASK_ID,
0 /*taskAffiliationColor*/, 0 /*callingUid*/, "" /*callingPackage*/,
- RESIZE_MODE_RESIZEABLE, false /*supportsPictureInPicture*/,
- false /*_realActivitySuspended*/, false /*userSetupComplete*/, INVALID_MIN_SIZE,
- INVALID_MIN_SIZE, createEmptyActivityInfo(), null /*voiceSession*/,
- null /*voiceInteractor*/, null /*stack*/);
+ null /*callingFeatureId*/, RESIZE_MODE_RESIZEABLE,
+ false /*supportsPictureInPicture*/, false /*_realActivitySuspended*/,
+ false /*userSetupComplete*/, INVALID_MIN_SIZE, INVALID_MIN_SIZE,
+ createEmptyActivityInfo(), null /*voiceSession*/, null /*voiceInteractor*/,
+ null /*stack*/);
getRequestedOverrideConfiguration().windowConfiguration.setWindowingMode(windowingMode);
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java
index 3975f0baa22a..e3453a06990f 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java
@@ -50,6 +50,7 @@ import org.mockito.quality.Strictness;
@RunWith(AndroidJUnit4.class)
public class PendingIntentControllerTest {
private static final String TEST_PACKAGE_NAME = "test-package-1";
+ private static final String TEST_FEATURE_ID = "test-feature-1";
private static final int TEST_CALLING_UID = android.os.Process.myUid();
private static final Intent[] TEST_INTENTS = new Intent[]{new Intent("com.test.intent")};
@@ -87,8 +88,8 @@ public class PendingIntentControllerTest {
private PendingIntentRecord createPendingIntentRecord(int flags) {
return mPendingIntentController.getIntentSender(ActivityManager.INTENT_SENDER_BROADCAST,
- TEST_PACKAGE_NAME, TEST_CALLING_UID, 0, null, null, 0, TEST_INTENTS, null, flags,
- null);
+ TEST_PACKAGE_NAME, TEST_FEATURE_ID, TEST_CALLING_UID, 0, null, null, 0,
+ TEST_INTENTS, null, flags, null);
}
@Test
diff --git a/services/tests/servicestests/src/com/android/server/am/BroadcastRecordTest.java b/services/tests/servicestests/src/com/android/server/am/BroadcastRecordTest.java
index 089a79b018a8..a871ec64af3b 100644
--- a/services/tests/servicestests/src/com/android/server/am/BroadcastRecordTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/BroadcastRecordTest.java
@@ -178,6 +178,7 @@ public class BroadcastRecordTest {
new Intent(),
null /* callerApp */,
null /* callerPackage */,
+ null /* callerFeatureId */,
0 /* callingPid */,
0 /* callingUid */,
false /* callerInstantApp */,
diff --git a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
index 77f842aa503f..df2b3efeb94c 100644
--- a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
@@ -24,6 +24,7 @@ import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.set;
import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
@@ -1728,6 +1729,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
final ArgumentCaptor<Intent[]> intentsCaptor = ArgumentCaptor.forClass(Intent[].class);
verify(mMockActivityTaskManagerInternal).startActivitiesAsPackage(
eq(packageName),
+ isNull(),
eq(userId),
intentsCaptor.capture(),
anyOrNull(Bundle.class));
@@ -1786,6 +1788,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
// This shouldn't have been called.
verify(mMockActivityTaskManagerInternal, times(0)).startActivitiesAsPackage(
anyString(),
+ isNull(),
anyInt(),
any(Intent[].class),
anyOrNull(Bundle.class));
diff --git a/services/tests/servicestests/src/com/android/server/pm/CrossProfileAppsServiceImplTest.java b/services/tests/servicestests/src/com/android/server/pm/CrossProfileAppsServiceImplTest.java
index 91cc9f35da1e..fea1b825228c 100644
--- a/services/tests/servicestests/src/com/android/server/pm/CrossProfileAppsServiceImplTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/CrossProfileAppsServiceImplTest.java
@@ -55,6 +55,7 @@ import java.util.List;
@RunWith(MockitoJUnitRunner.class)
public class CrossProfileAppsServiceImplTest {
private static final String PACKAGE_ONE = "com.one";
+ private static final String FEATURE_ID = "feature.one";
private static final int PACKAGE_ONE_UID = 1111;
private static final ComponentName ACTIVITY_COMPONENT =
new ComponentName("com.one", "test");
@@ -220,6 +221,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PRIMARY_USER).getIdentifier(),
true));
@@ -228,6 +230,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -241,6 +244,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PRIMARY_USER).getIdentifier(),
false));
@@ -249,6 +253,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -264,6 +269,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
true));
@@ -272,6 +278,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -287,6 +294,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
false));
@@ -295,6 +303,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -308,6 +317,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_TWO,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
true));
@@ -316,6 +326,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -329,6 +340,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_TWO,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
false));
@@ -337,6 +349,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -352,6 +365,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
true));
@@ -360,6 +374,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -380,6 +395,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
false));
@@ -388,6 +404,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -401,6 +418,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
new ComponentName(PACKAGE_TWO, "test"),
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
true));
@@ -409,6 +427,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -422,6 +441,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
new ComponentName(PACKAGE_TWO, "test"),
UserHandle.of(PROFILE_OF_PRIMARY_USER).getIdentifier(),
false));
@@ -430,6 +450,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -443,6 +464,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(SECONDARY_USER).getIdentifier(),
true));
@@ -451,6 +473,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -464,6 +487,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(SECONDARY_USER).getIdentifier(),
false));
@@ -472,6 +496,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
anyString(),
+ nullable(String.class),
any(Intent.class),
nullable(Bundle.class),
anyInt());
@@ -484,6 +509,7 @@ public class CrossProfileAppsServiceImplTest {
mCrossProfileAppsServiceImpl.startActivityAsUser(
mIApplicationThread,
PACKAGE_ONE,
+ FEATURE_ID,
ACTIVITY_COMPONENT,
UserHandle.of(PRIMARY_USER).getIdentifier(),
true);
@@ -492,6 +518,7 @@ public class CrossProfileAppsServiceImplTest {
.startActivityAsUser(
nullable(IApplicationThread.class),
eq(PACKAGE_ONE),
+ eq(FEATURE_ID),
any(Intent.class),
nullable(Bundle.class),
eq(PRIMARY_USER));
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
index f03670843f3a..2936bdd8501b 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
@@ -3144,7 +3144,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
// Not launchable.
doReturn(ActivityManager.START_CLASS_NOT_FOUND)
.when(mMockActivityTaskManagerInternal).startActivitiesAsPackage(
- anyStringOrNull(), anyInt(),
+ anyStringOrNull(), anyStringOrNull(), anyInt(),
anyOrNull(Intent[].class), anyOrNull(Bundle.class));
assertStartShortcutThrowsException(CALLING_PACKAGE_1, "s1", USER_0,
ActivityNotFoundException.class);
@@ -3153,7 +3153,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
doReturn(ActivityManager.START_CLASS_NOT_FOUND)
.when(mMockActivityTaskManagerInternal)
.startActivitiesAsPackage(
- anyStringOrNull(), anyInt(),
+ anyStringOrNull(), anyStringOrNull(), anyInt(),
anyOrNull(Intent[].class), anyOrNull(Bundle.class));
assertStartShortcutThrowsException(CALLING_PACKAGE_1, "s1", USER_0,
ActivityNotFoundException.class);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java
index 135d00586329..af04f7641250 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java
@@ -120,7 +120,7 @@ public class ActivityStartInterceptorTest {
mInterceptor = new ActivityStartInterceptor(
mService, mSupervisor, mRootWindowContainer, mContext);
mInterceptor.setStates(TEST_USER_ID, TEST_REAL_CALLING_PID, TEST_REAL_CALLING_UID,
- TEST_START_FLAGS, TEST_CALLING_PACKAGE);
+ TEST_START_FLAGS, TEST_CALLING_PACKAGE, null);
// Mock ActivityManagerInternal
LocalServices.removeServiceForTest(ActivityManagerInternal.class);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index bab877e6c26f..fa182d68d917 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -275,7 +275,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
if (containsConditions(preconditions, PRECONDITION_CANNOT_START_ANY_ACTIVITY)) {
doReturn(false).when(service.mStackSupervisor).checkStartAnyActivityPermission(
- any(), any(), any(), anyInt(), anyInt(), anyInt(), any(),
+ any(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any(),
anyBoolean(), anyBoolean(), any(), any(), any());
}
@@ -349,7 +349,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
boolean mockGetLaunchStack) {
// always allow test to start activity.
doReturn(true).when(mSupervisor).checkStartAnyActivityPermission(
- any(), any(), any(), anyInt(), anyInt(), anyInt(), any(),
+ any(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any(),
anyBoolean(), anyBoolean(), any(), any(), any());
if (mockGetLaunchStack) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
index eb84d0af35c7..c93dc9757853 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
@@ -255,10 +255,10 @@ class ActivityTestsBase extends SystemServiceTestsBase {
final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
mLaunchedFromPid /* launchedFromPid */, mLaunchedFromUid /* launchedFromUid */,
- null, intent, null, aInfo /*aInfo*/, new Configuration(), null /* resultTo */,
- null /* resultWho */, 0 /* reqCode */, false /*componentSpecified*/,
- false /* rootVoiceInteraction */, mService.mStackSupervisor, options,
- null /* sourceRecord */);
+ null, null, intent, null, aInfo /*aInfo*/, new Configuration(),
+ null /* resultTo */, null /* resultWho */, 0 /* reqCode */,
+ false /*componentSpecified*/, false /* rootVoiceInteraction */,
+ mService.mStackSupervisor, options, null /* sourceRecord */);
spyOn(activity);
if (mTask != null) {
// fullscreen value is normally read from resources in ctor, so for testing we need
diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
index e50750841e20..f517881d835b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
@@ -439,11 +439,11 @@ public class SystemServicesTestRule implements TestRule {
doNothing().when(this).updateCpuStats();
// AppOpsService
- final AppOpsService aos = mock(AppOpsService.class);
- doReturn(aos).when(this).getAppOpsService();
+ final AppOpsManager aos = mock(AppOpsManager.class);
+ doReturn(aos).when(this).getAppOpsManager();
// Make sure permission checks aren't overridden.
- doReturn(AppOpsManager.MODE_DEFAULT).when(aos).noteOperation(anyInt(), anyInt(),
- anyString(), nullable(String.class), anyBoolean(), nullable(String.class));
+ doReturn(AppOpsManager.MODE_DEFAULT).when(aos).noteOpNoThrow(anyInt(), anyInt(),
+ anyString(), nullable(String.class), nullable(String.class));
// UserManagerService
final UserManagerService ums = mock(UserManagerService.class);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
index ebf14d2c6a19..feadd0a496bb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
@@ -988,7 +988,7 @@ public class TaskRecordTests extends ActivityTestsBase {
private Task createTask(int taskId) {
return new ActivityStack(mService, taskId, new Intent(), null, null, null,
ActivityBuilder.getDefaultComponent(), null, false, false, false, 0, 10050, null,
- 0, false, null, 0, 0, 0, 0, 0, null, 0, false, false, false, 0,
+ 0, false, null, 0, 0, 0, 0, 0, null, null, 0, false, false, false, 0,
0, null /*ActivityInfo*/, null /*_voiceSession*/, null /*_voiceInteractor*/,
null /*stack*/);
}
@@ -1022,7 +1022,7 @@ public class TaskRecordTests extends ActivityTestsBase {
boolean neverRelinquishIdentity,
ActivityManager.TaskDescription lastTaskDescription,
int taskAffiliation, int prevTaskId, int nextTaskId, int taskAffiliationColor,
- int callingUid, String callingPackage, int resizeMode,
+ int callingUid, String callingPackage, String callingFeatureId, int resizeMode,
boolean supportsPictureInPicture,
boolean realActivitySuspended, boolean userSetupComplete, int minWidth,
int minHeight, ActivityStack stack) {
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index d5eec332cda0..8378d8ed9f68 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -747,7 +747,8 @@ public class VoiceInteractionManagerService extends SystemService {
}
@Override
- public int startVoiceActivity(IBinder token, Intent intent, String resolvedType) {
+ public int startVoiceActivity(IBinder token, Intent intent, String resolvedType,
+ String callingFeatureId) {
synchronized (this) {
if (mImpl == null) {
Slog.w(TAG, "startVoiceActivity without running voice interaction service");
@@ -757,8 +758,8 @@ public class VoiceInteractionManagerService extends SystemService {
final int callingUid = Binder.getCallingUid();
final long caller = Binder.clearCallingIdentity();
try {
- return mImpl.startVoiceActivityLocked(callingPid, callingUid, token,
- intent, resolvedType);
+ return mImpl.startVoiceActivityLocked(callingFeatureId, callingPid, callingUid,
+ token, intent, resolvedType);
} finally {
Binder.restoreCallingIdentity(caller);
}
@@ -766,7 +767,8 @@ public class VoiceInteractionManagerService extends SystemService {
}
@Override
- public int startAssistantActivity(IBinder token, Intent intent, String resolvedType) {
+ public int startAssistantActivity(IBinder token, Intent intent, String resolvedType,
+ String callingFeatureId) {
synchronized (this) {
if (mImpl == null) {
Slog.w(TAG, "startAssistantActivity without running voice interaction service");
@@ -776,8 +778,8 @@ public class VoiceInteractionManagerService extends SystemService {
final int callingUid = Binder.getCallingUid();
final long caller = Binder.clearCallingIdentity();
try {
- return mImpl.startAssistantActivityLocked(callingPid, callingUid, token,
- intent, resolvedType);
+ return mImpl.startAssistantActivityLocked(callingFeatureId, callingPid,
+ callingUid, token, intent, resolvedType);
} finally {
Binder.restoreCallingIdentity(caller);
}
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
index a1210cfce26d..a62b03ca82e4 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
@@ -216,8 +216,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
return true;
}
- public int startVoiceActivityLocked(int callingPid, int callingUid, IBinder token,
- Intent intent, String resolvedType) {
+ public int startVoiceActivityLocked(@Nullable String callingFeatureId, int callingPid,
+ int callingUid, IBinder token, Intent intent, String resolvedType) {
try {
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "startVoiceActivity does not match active session");
@@ -230,16 +230,16 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
intent = new Intent(intent);
intent.addCategory(Intent.CATEGORY_VOICE);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- return mAtm.startVoiceActivity(mComponent.getPackageName(), callingPid, callingUid,
- intent, resolvedType, mActiveSession.mSession, mActiveSession.mInteractor,
- 0, null, null, mUser);
+ return mAtm.startVoiceActivity(mComponent.getPackageName(), callingFeatureId,
+ callingPid, callingUid, intent, resolvedType, mActiveSession.mSession,
+ mActiveSession.mInteractor, 0, null, null, mUser);
} catch (RemoteException e) {
throw new IllegalStateException("Unexpected remote error", e);
}
}
- public int startAssistantActivityLocked(int callingPid, int callingUid, IBinder token,
- Intent intent, String resolvedType) {
+ public int startAssistantActivityLocked(@Nullable String callingFeatureId, int callingPid,
+ int callingUid, IBinder token, Intent intent, String resolvedType) {
try {
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "startAssistantActivity does not match active session");
@@ -253,8 +253,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchActivityType(ACTIVITY_TYPE_ASSISTANT);
- return mAtm.startAssistantActivity(mComponent.getPackageName(), callingPid, callingUid,
- intent, resolvedType, options.toBundle(), mUser);
+ return mAtm.startAssistantActivity(mComponent.getPackageName(), callingFeatureId,
+ callingPid, callingUid, intent, resolvedType, options.toBundle(), mUser);
} catch (RemoteException e) {
throw new IllegalStateException("Unexpected remote error", e);
}
diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
index 1361df30e9d7..59049160e885 100644
--- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
+++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
@@ -321,7 +321,8 @@ public class MemoryUsageTest extends InstrumentationTestCase {
}
mAtm.startActivityAndWait(null,
- getInstrumentation().getContext().getBasePackageName(), mLaunchIntent,
+ getInstrumentation().getContext().getBasePackageName(),
+ getInstrumentation().getContext().getFeatureId(), mLaunchIntent,
mimeType, null, null, 0, mLaunchIntent.getFlags(), null, null,
UserHandle.USER_CURRENT_OR_SELF);
} catch (RemoteException e) {