OSDN Git Service

Sysconfig takes precedence over update-time autoVerify
authorChristopher Tate <ctate@google.com>
Wed, 20 Mar 2019 19:40:13 +0000 (12:40 -0700)
committerChristopher Tate <ctate@google.com>
Thu, 21 Mar 2019 22:43:09 +0000 (15:43 -0700)
autoVerify is re-evaluated whenever an apk is updated, and in the normal
case a verification failure here results in the app being demoted out of
'always' status for handling web link Intents.  However, bundled app
policy for this is supposed to be set statically via sysconfig --
so now we make sure that sysconfig policy takes precedence in this case.

Fixes: 127838380
Test: manual (update bundled sysconfig-cited app and force failure)
Test: atest OsHostTests#testIntentFilterHostValidation
Change-Id: If80511ce47847bb21a48634b191acfacda606331

services/core/java/com/android/server/pm/PackageManagerService.java

index e5b6397..fd04a3a 100644 (file)
@@ -160,9 +160,9 @@ import android.content.pm.InstantAppInfo;
 import android.content.pm.InstantAppRequest;
 import android.content.pm.InstrumentationInfo;
 import android.content.pm.IntentFilterVerificationInfo;
-import android.content.pm.PackageBackwardCompatibility;
 import android.content.pm.KeySet;
 import android.content.pm.ModuleInfo;
+import android.content.pm.PackageBackwardCompatibility;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageInfoLite;
 import android.content.pm.PackageInstaller;
@@ -1127,11 +1127,22 @@ public class PackageManagerService extends IPackageManager.Stub
                     switch (userStatus) {
                         case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS:
                             if (!verified) {
-                                // updatedStatus is already UNDEFINED
-                                needUpdate = true;
-
-                                if (DEBUG_DOMAIN_VERIFICATION) {
-                                    Slog.d(TAG, "Formerly validated but now failing; demoting");
+                                // Don't demote if sysconfig says 'always'
+                                SystemConfig systemConfig = SystemConfig.getInstance();
+                                ArraySet<String> packages = systemConfig.getLinkedApps();
+                                if (!packages.contains(packageName)) {
+                                    // updatedStatus is already UNDEFINED
+                                    needUpdate = true;
+
+                                    if (DEBUG_DOMAIN_VERIFICATION) {
+                                        Slog.d(TAG, "Formerly validated but now failing; demoting");
+                                    }
+                                } else {
+                                    if (DEBUG_DOMAIN_VERIFICATION) {
+                                        Slog.d(TAG, "Updating bundled package " + packageName
+                                                + " failed autoVerify, but sysconfig supersedes");
+                                    }
+                                    // leave needUpdate == false here intentionally
                                 }
                             }
                             break;