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
This commit is contained in:
Riddle Hsu
2021-06-30 06:01:06 +08:00
parent 6f383b1b8e
commit 0b2d6e1aa3

View File

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