Fix issue with permission check for shortcuts and pendingIntent

When launching a PendingIntent, we have two sets of activity
options: One supplied from the caller that obtained the
pending intent, and those supplied from the caller that is
sending it. We need to perform the permission check depending
on which caller the options are coming from.

For that, we introduce SafeActivityOptions that records the
callingPid/callingUid when obtaining it and checks for the
permissions with the correct callingPid/callingUid, and
also supports merging both activity options.

In addition to that, fix shortcuts by not clearing caller
identity in LauncherAppsService.

Test: go/wm-smoke
Test: Install custom launcher APK with animation for shortcuts
enabled, make sure launch works properly.
Bug: 64674361

Change-Id: I9a854d43c65c8fa69bf16ccfbed86e8e681a095b
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
index 589a89b..b58c700 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
@@ -228,8 +228,8 @@
 
         if (containsConditions(preconditions,PRECONDITION_CANNOT_START_ANY_ACTIVITY)) {
             doReturn(false).when(service.mStackSupervisor).checkStartAnyActivityPermission(
-                    any(), any(), any(), anyInt(), anyInt(), anyInt(), any(), anyBoolean(),
-                    any(), any(), any(), any());
+                    any(), any(), any(), anyInt(), anyInt(), anyInt(), any(),
+                    anyBoolean(), any(), any(), any());
         }
 
         try {
@@ -278,7 +278,7 @@
                     .setResultTo(resultTo)
                     .setRequestCode(requestCode)
                     .setReason("testLaunchActivityPermissionDenied")
-                    .setActivityOptions(options)
+                    .setActivityOptions(new SafeActivityOptions(options))
                     .execute();
             verify(options, times(1)).abort();
         }