• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

修訂f697cd3b97b10a283c54b37d8448a011c570e2c6 (tree)
時間2020-04-07 12:03:16
作者Christopher Tate <ctate@goog...>
CommiterVasyl Gello

Log Message

Revoke 'always' web handler status when not autoverifying

If an app has previously used autoVerify to make claims about its status
re handling web navigation intents, but is updated such that it no
longer makes those claims, step down its "official handler" status as
though it had never invoked autoVerify in the first place.

Bug: 146204120
Test: manual: as described in bug; observe policy before/after via

'adb shell dumpsys package d'

Test: atest CtsOsHostTestCases
Change-Id: I58502d1b32d793aba9aa772fa2ad5ac38acca48a
Merged-In: I58502d1b32d793aba9aa772fa2ad5ac38acca48a
(cherry picked from commit 6cf5f92825df545bd011b7163418f2ea0b337af3)

Change Summary

差異

--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -15565,35 +15565,47 @@ public class PackageManagerService extends IPackageManager.Stub {
1556515565 int count = 0;
1556615566 final String packageName = pkg.packageName;
1556715567
15568+ boolean handlesWebUris = false;
15569+ final boolean alreadyVerified;
1556815570 synchronized (mPackages) {
1556915571 // If this is a new install and we see that we've already run verification for this
1557015572 // package, we have nothing to do: it means the state was restored from backup.
15571- if (!replacing) {
15572- IntentFilterVerificationInfo ivi =
15573- mSettings.getIntentFilterVerificationLPr(packageName);
15574- if (ivi != null) {
15575- if (DEBUG_DOMAIN_VERIFICATION) {
15576- Slog.i(TAG, "Package " + packageName+ " already verified: status="
15577- + ivi.getStatusString());
15578- }
15579- return;
15573+ final IntentFilterVerificationInfo ivi =
15574+ mSettings.getIntentFilterVerificationLPr(packageName);
15575+ alreadyVerified = (ivi != null);
15576+ if (!replacing && alreadyVerified) {
15577+ if (DEBUG_DOMAIN_VERIFICATION) {
15578+ Slog.i(TAG, "Package " + packageName + " already verified: status="
15579+ + ivi.getStatusString());
1558015580 }
15581+ return;
1558115582 }
1558215583
15583- // If any filters need to be verified, then all need to be.
15584+ // If any filters need to be verified, then all need to be. In addition, we need to
15585+ // know whether an updating app has any web navigation intent filters, to re-
15586+ // examine handling policy even if not re-verifying.
1558415587 boolean needToVerify = false;
1558515588 for (PackageParser.Activity a : pkg.activities) {
1558615589 for (ActivityIntentInfo filter : a.intents) {
15590+ if (filter.handlesWebUris(true)) {
15591+ handlesWebUris = true;
15592+ }
1558715593 if (filter.needsVerification() && needsNetworkVerificationLPr(filter)) {
1558815594 if (DEBUG_DOMAIN_VERIFICATION) {
1558915595 Slog.d(TAG, "Intent filter needs verification, so processing all filters");
1559015596 }
1559115597 needToVerify = true;
15598+ // It's safe to break out here because filter.needsVerification()
15599+ // can only be true if filter.handlesWebUris(true) returns true, so
15600+ // we've already noted that.
1559215601 break;
1559315602 }
1559415603 }
1559515604 }
1559615605
15606+ // Note whether this app publishes any web navigation handling support at all,
15607+ // and whether there are any web-nav filters that fit the profile for running
15608+ // a verification pass now.
1559715609 if (needToVerify) {
1559815610 final int verificationId = mIntentFilterVerificationToken++;
1559915611 for (PackageParser.Activity a : pkg.activities) {
@@ -15611,13 +15623,23 @@ public class PackageManagerService extends IPackageManager.Stub {
1561115623 }
1561215624
1561315625 if (count > 0) {
15626+ // count > 0 means that we're running a full verification pass
1561415627 if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, "Starting " + count
1561515628 + " IntentFilter verification" + (count > 1 ? "s" : "")
1561615629 + " for userId:" + userId);
1561715630 mIntentFilterVerifier.startVerifications(userId);
15631+ } else if (alreadyVerified && handlesWebUris) {
15632+ // App used autoVerify in the past, no longer does, but still handles web
15633+ // navigation starts.
15634+ if (DEBUG_DOMAIN_VERIFICATION) {
15635+ Slog.d(TAG, "App changed web filters but no longer verifying - resetting policy");
15636+ }
15637+ synchronized (mPackages) {
15638+ clearIntentFilterVerificationsLPw(packageName, userId);
15639+ }
1561815640 } else {
1561915641 if (DEBUG_DOMAIN_VERIFICATION) {
15620- Slog.d(TAG, "No filters or not all autoVerify for " + packageName);
15642+ Slog.d(TAG, "No web filters or no prior verify policy for " + packageName);
1562115643 }
1562215644 }
1562315645 }
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -1331,6 +1331,7 @@ final class Settings {
13311331 return false;
13321332 }
13331333 ps.clearDomainVerificationStatusForUser(userId);
1334+ ps.setIntentFilterVerificationInfo(null);
13341335 return true;
13351336 }
13361337