From 0b2d6e1aa330ad4054fd78fd35c2afde9ba64270 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 30 Jun 2021 06:01:06 +0800 Subject: [PATCH] Return invalid task id if no acceptable target app No matter the app is not found or has different uid, return the invalid id to indicate that the add operation is failed. So the caller won't know whether the specified package exists or not. Bug: 189122913 Test: Pass intent with specified component name to ActivityManager#addAppTask. Change-Id: I013264414c60f2d9864a5fcc369180425f20529e --- .../android/server/wm/ActivityTaskManagerService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 569c11be01e7c..680937b37eac0 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -2633,10 +2633,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } final ActivityInfo ainfo = AppGlobals.getPackageManager().getActivityInfo(comp, STOCK_PM_FLAGS, UserHandle.getUserId(callingUid)); - if (ainfo.applicationInfo.uid != callingUid) { - throw new SecurityException( - "Can't add task for another application: target uid=" - + ainfo.applicationInfo.uid + ", calling uid=" + callingUid); + if (ainfo == null || ainfo.applicationInfo.uid != callingUid) { + Slog.e(TAG, "Can't add task for another application: target uid=" + + (ainfo == null ? Process.INVALID_UID : ainfo.applicationInfo.uid) + + ", calling uid=" + callingUid); + return INVALID_TASK_ID; } final Task rootTask = r.getRootTask();