Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55447e37 authored by Song Pan's avatar Song Pan Committed by Android (Google) Code Review
Browse files

Merge "Fail early if we don't have any rules file on disk."

parents 87a7b2f6 541a7710
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -196,6 +196,15 @@ public class AppIntegrityManagerServiceImpl extends IAppIntegrityManager.Stub {

    private void handleIntegrityVerification(Intent intent) {
        int verificationId = intent.getIntExtra(EXTRA_VERIFICATION_ID, -1);

        // Fail early if we don't have any rules at all.
        if (!mIntegrityFileManager.initialized()) {
            Slog.i(TAG, "Rules not initialized. Skipping integrity check.");
            mPackageManagerInternal.setIntegrityVerificationResult(
                    verificationId, PackageManagerInternal.INTEGRITY_VERIFICATION_ALLOW);
            return;
        }

        try {
            Slog.i(TAG, "Received integrity verification intent " + intent.toString());
            Slog.i(TAG, "Extras " + intent.getExtras());
+11 −4
Original line number Diff line number Diff line
@@ -74,10 +74,7 @@ public class IntegrityFileManager {
    }

    private IntegrityFileManager() {
        this(
                new RuleXmlParser(),
                new RuleXmlSerializer(),
                Environment.getDataSystemDirectory());
        this(new RuleXmlParser(), new RuleXmlSerializer(), Environment.getDataSystemDirectory());
    }

    @VisibleForTesting
@@ -103,6 +100,16 @@ public class IntegrityFileManager {
        }
    }

    /**
     * Returns if the rules have been initialized.
     *
     * <p>Used to fail early if there are no rules (so we don't need to parse the apk at all).
     */
    public boolean initialized() {
        return new File(mRulesDir, RULES_FILE).exists()
                && new File(mRulesDir, METADATA_FILE).exists();
    }

    /** Write rules to persistent storage. */
    public void writeRules(String version, String ruleProvider, List<Rule> rules)
            throws IOException, RuleSerializeException {