summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michal Karpinski <mkarpinski@google.com> 2019-01-15 16:05:25 +0000
committer Michal Karpinski <mkarpinski@google.com> 2019-01-15 16:17:10 +0000
commitd016285dd1a368f7eec532fb82c01dcee0c4bcf1 (patch)
tree9da338068737fe866d52fe2d704f5846e344c579
parenta9002d56be7743b78ee76058bc9330e141bd2719 (diff)
Add a logcat message for aborted background activity starts
Previously we just showed a toast and didn't log anything. This needs to change as we start getting more and more bug reports from early dogfooders, and more and more people will want to figure out what's going on. Bug: 110956953 Test: atest WmTests:ActivityStarterTests Test: adb logcat | grep "Blocking background activity start" Change-Id: I48483d33b28cbb18c633666b990c58144e54bde1
-rw-r--r--services/core/java/com/android/server/wm/ActivityStarter.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index ef3c8d5257fb..916baa08fcbc 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -749,7 +749,7 @@ class ActivityStarter {
if (!abort) {
abort |= shouldAbortBackgroundActivityStart(callingUid, callingPid, callingPackage,
realCallingUid, callerApp, originatingPendingIntent,
- allowBackgroundActivityStart);
+ allowBackgroundActivityStart, intent);
}
// Merge the two options bundles, while realCallerOptions takes precedence.
@@ -898,7 +898,8 @@ class ActivityStarter {
private boolean shouldAbortBackgroundActivityStart(int callingUid, int callingPid,
final String callingPackage, int realCallingUid, WindowProcessController callerApp,
- PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart) {
+ PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart,
+ Intent intent) {
if (mService.isBackgroundActivityStartsEnabled()) {
return false;
}
@@ -911,19 +912,24 @@ class ActivityStarter {
return false;
}
// don't abort if the callingUid is in the foreground or is a persistent system process
- if (isUidForeground(callingUid) || isUidPersistentSystemProcess(callingUid)) {
+ final boolean isCallingUidForeground = isUidForeground(callingUid);
+ final boolean isCallingUidPersistentSystemProcess = isUidPersistentSystemProcess(
+ callingUid);
+ if (isCallingUidForeground || isCallingUidPersistentSystemProcess) {
return false;
}
// take realCallingUid into consideration
+ final boolean isRealCallingUidForeground = isUidForeground(realCallingUid);
+ final boolean isRealCallingUidPersistentSystemProcess = isUidPersistentSystemProcess(
+ realCallingUid);
if (realCallingUid != callingUid) {
// don't abort if the realCallingUid is in the foreground and callingUid isn't
- if (isUidForeground(realCallingUid)) {
+ if (isRealCallingUidForeground) {
return false;
}
// if the realCallingUid is a persistent system process, abort if the IntentSender
// wasn't whitelisted to start an activity
- if (isUidPersistentSystemProcess(realCallingUid) && (originatingPendingIntent != null)
- && allowBackgroundActivityStart) {
+ if (isRealCallingUidPersistentSystemProcess && allowBackgroundActivityStart) {
return false;
}
}
@@ -941,6 +947,18 @@ class ActivityStarter {
return false;
}
// anything that has fallen through will currently be aborted
+ Slog.w(TAG, "Blocking background activity start [callingPackage: " + callingPackage
+ + "; callingUid: " + callingUid
+ + "; isCallingUidForeground: " + isCallingUidForeground
+ + "; isCallingUidPersistentSystemProcess: " + isCallingUidPersistentSystemProcess
+ + "; realCallingUid: " + realCallingUid
+ + "; isRealCallingUidForeground: " + isRealCallingUidForeground
+ + "; isRealCallingUidPersistentSystemProcess: "
+ + isRealCallingUidPersistentSystemProcess
+ + "; originatingPendingIntent: " + originatingPendingIntent
+ + "; isBgStartWhitelisted: " + allowBackgroundActivityStart
+ + "; intent: " + intent
+ + "]");
// TODO: remove this toast after feature development is done
mService.mUiHandler.post(() -> {
Toast.makeText(mService.mContext,