Recalculate real caller if caller results in block
When the caller==realcaller while sending an own PendingIntent (which
should be avoided, but it happens) and the caller does not allow the PI
start, calculate if the real caller is allowed (which is possible,
because for a PI the callerApp is null and the realCallerApp is
calculated).
Test: atest CtsPackageManagerTestCases:android.content.pm.cts.PackageManagerTest#testGetLaunchIntentSenderForPackage ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.NetworkNotificationManagerTest#testNotifyNoInternet_asDialog
Fixes: 307911244
Fixes: 307907820
Fixes: 308163300
Change-Id: I9cd0d5022c6302a2a802749f009f6f2372f8bb01
diff --git a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
index 9b7b8de..0ab07c8 100644
--- a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
+++ b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
@@ -414,8 +414,9 @@
}
BalVerdict resultForCaller = checkBackgroundActivityStartAllowedByCaller(state);
- BalVerdict resultForRealCaller = callingUid == realCallingUid
+ BalVerdict resultForRealCaller = callingUid == realCallingUid && resultForCaller.allows()
? resultForCaller // no need to calculate again
+ // otherwise we might need to recalculate because the logic is not the same
: checkBackgroundActivityStartAllowedBySender(state, checkedOptions);
if (resultForCaller.allows()