summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chiu <chiuwinson@google.com> 2023-05-23 18:00:31 +0000
committer Winson Chiu <chiuwinson@google.com> 2023-05-23 18:13:37 +0000
commit3acb6fa6c8b42976b4a976e80a29ab1cc952ddbb (patch)
tree5ab4a0a0ca285f77ba3c5b8ebf9375e4352bffb7
parentb4bec96db33a695b9ff7690facff9ffa96c3a90b (diff)
Add domain approval level debug logs
Another attempt to debug a CI-only issue related to Intent domain verification resolution. Bug: 283023419 Test: atest CtsDomainVerificationDeviceStandaloneTestCases Change-Id: I2ec4d0953622399b0c8a9cdcb06368cc2dc8e8b3
-rw-r--r--services/core/java/com/android/server/pm/ComputerEngine.java7
-rw-r--r--services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java53
2 files changed, 37 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java
index a3866caacf39..abfc1d7ff2d2 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -2342,6 +2342,11 @@ public class ComputerEngine implements Computer {
Intent intent, List<ResolveInfo> resolvedActivities, int userId,
boolean skipPackageCheck, @PackageManager.ResolveInfoFlagsBits long flags) {
final int count = (resolvedActivities == null ? 0 : resolvedActivities.size());
+ var debug = (intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0;
+ if (debug) {
+ Slog.d(TAG, "Checking if instant app resolution allowed, resolvedActivities = "
+ + resolvedActivities);
+ }
for (int n = 0; n < count; n++) {
final ResolveInfo info = resolvedActivities.get(n);
final String packageName = info.activityInfo.packageName;
@@ -2365,6 +2370,8 @@ public class ComputerEngine implements Computer {
}
return false;
}
+ } else if (debug) {
+ Slog.d(TAG, "Could not find package " + packageName);
}
}
// We've exhausted all ways to deny ephemeral application; let the system look for them.
diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java
index 811d6e272292..11f62e953525 100644
--- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java
+++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java
@@ -788,7 +788,7 @@ public class DomainVerificationService extends SystemService
/**
* @param includeNegative See
- * {@link #approvalLevelForDomain(PackageStateInternal, String, boolean, int, Object)}.
+ * {@link #approvalLevelForDomain(PackageStateInternal, String, boolean, int, boolean, Object)}.
* @return Mapping of approval level to packages; packages are sorted by firstInstallTime. Null
* if no owners were found.
*/
@@ -808,7 +808,7 @@ public class DomainVerificationService extends SystemService
}
int level = approvalLevelForDomain(pkgSetting, domain, includeNegative, userId,
- domain);
+ DEBUG_APPROVAL, domain);
if (!includeNegative && level <= APPROVAL_LEVEL_NONE) {
continue;
}
@@ -1616,7 +1616,8 @@ public class DomainVerificationService extends SystemService
fillInfoMapForSamePackage(inputMap, packageName, APPROVAL_LEVEL_NONE);
continue;
}
- int approval = approvalLevelForDomain(pkgSetting, domain, false, userId, domain);
+ int approval = approvalLevelForDomain(pkgSetting, domain, false, userId, DEBUG_APPROVAL,
+ domain);
highestApproval = Math.max(highestApproval, approval);
fillInfoMapForSamePackage(inputMap, packageName, approval);
}
@@ -1726,15 +1727,21 @@ public class DomainVerificationService extends SystemService
@NonNull Intent intent, @PackageManager.ResolveInfoFlagsBits long resolveInfoFlags,
@UserIdInt int userId) {
String packageName = pkgSetting.getPackageName();
+ var debug = DEBUG_APPROVAL || (intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0;
if (!DomainVerificationUtils.isDomainVerificationIntent(intent, resolveInfoFlags)) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, intent, userId, false, "not valid intent");
}
return APPROVAL_LEVEL_NONE;
}
- return approvalLevelForDomain(pkgSetting, intent.getData().getHost(), false, userId,
- intent);
+ var approvalLevel = approvalLevelForDomain(pkgSetting, intent.getData().getHost(), false,
+ userId, debug, intent);
+ if (debug) {
+ Slog.d(TAG + "Approval", "Final approval level for " + pkgSetting.getPackageName()
+ + " for host " + intent.getData().getHost() + " is " + approvalLevel);
+ }
+ return approvalLevel;
}
/**
@@ -1744,10 +1751,10 @@ public class DomainVerificationService extends SystemService
* {@link String} otherwise.
*/
private int approvalLevelForDomain(@NonNull PackageStateInternal pkgSetting,
- @NonNull String host, boolean includeNegative, @UserIdInt int userId,
+ @NonNull String host, boolean includeNegative, @UserIdInt int userId, boolean debug,
@NonNull Object debugObject) {
int approvalLevel = approvalLevelForDomainInternal(pkgSetting, host, includeNegative,
- userId, debugObject);
+ userId, debug, debugObject);
if (includeNegative && approvalLevel == APPROVAL_LEVEL_NONE) {
PackageUserStateInternal pkgUserState = pkgSetting.getUserStateOrDefault(userId);
if (!pkgUserState.isInstalled()) {
@@ -1768,13 +1775,13 @@ public class DomainVerificationService extends SystemService
}
private int approvalLevelForDomainInternal(@NonNull PackageStateInternal pkgSetting,
- @NonNull String host, boolean includeNegative, @UserIdInt int userId,
+ @NonNull String host, boolean includeNegative, @UserIdInt int userId, boolean debug,
@NonNull Object debugObject) {
String packageName = pkgSetting.getPackageName();
final AndroidPackage pkg = pkgSetting.getPkg();
if (pkg != null && includeNegative && !mCollector.containsWebDomain(pkg, host)) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false,
"domain not declared");
}
@@ -1783,7 +1790,7 @@ public class DomainVerificationService extends SystemService
final PackageUserStateInternal pkgUserState = pkgSetting.getUserStates().get(userId);
if (pkgUserState == null) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false,
"PackageUserState unavailable");
}
@@ -1791,7 +1798,7 @@ public class DomainVerificationService extends SystemService
}
if (!pkgUserState.isInstalled()) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false,
"package not installed for user");
}
@@ -1799,7 +1806,7 @@ public class DomainVerificationService extends SystemService
}
if (!PackageUserStateUtils.isPackageEnabled(pkgUserState, pkg)) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false,
"package not enabled for user");
}
@@ -1807,7 +1814,7 @@ public class DomainVerificationService extends SystemService
}
if (pkgUserState.isSuspended()) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false,
"package suspended for user");
}
@@ -1834,7 +1841,7 @@ public class DomainVerificationService extends SystemService
synchronized (mLock) {
DomainVerificationPkgState pkgState = mAttachedPkgStates.get(packageName);
if (pkgState == null) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false, "pkgState unavailable");
}
return APPROVAL_LEVEL_NONE;
@@ -1843,7 +1850,7 @@ public class DomainVerificationService extends SystemService
DomainVerificationInternalUserState userState = pkgState.getUserState(userId);
if (userState != null && !userState.isLinkHandlingAllowed()) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false,
"link handling not allowed");
}
@@ -1865,7 +1872,7 @@ public class DomainVerificationService extends SystemService
// Check if the exact host matches
Integer state = stateMap.get(host);
if (state != null && DomainVerificationState.isVerified(state)) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, true,
"host verified exactly");
}
@@ -1881,7 +1888,7 @@ public class DomainVerificationService extends SystemService
String domain = stateMap.keyAt(index);
if (domain.startsWith("*.") && host.endsWith(domain.substring(2))) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, true,
"host verified by wildcard");
}
@@ -1891,7 +1898,7 @@ public class DomainVerificationService extends SystemService
// Check user state if available
if (userState == null) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false, "userState unavailable");
}
return APPROVAL_LEVEL_NONE;
@@ -1900,7 +1907,7 @@ public class DomainVerificationService extends SystemService
// See if the user has approved the exact host
ArraySet<String> enabledHosts = userState.getEnabledHosts();
if (enabledHosts.contains(host)) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, true,
"host enabled by user exactly");
}
@@ -1912,7 +1919,7 @@ public class DomainVerificationService extends SystemService
for (int index = 0; index < enabledHostsSize; index++) {
String domain = enabledHosts.valueAt(index);
if (domain.startsWith("*.") && host.endsWith(domain.substring(2))) {
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, true,
"host enabled by user through wildcard");
}
@@ -1920,7 +1927,7 @@ public class DomainVerificationService extends SystemService
}
}
- if (DEBUG_APPROVAL) {
+ if (debug) {
debugApproval(packageName, debugObject, userId, false, "not approved");
}
return APPROVAL_LEVEL_NONE;
@@ -1948,7 +1955,7 @@ public class DomainVerificationService extends SystemService
}
int level = approvalLevelForDomain(pkgSetting, domain, includeNegative, userId,
- domain);
+ DEBUG_APPROVAL, domain);
if (level < minimumApproval) {
continue;
}