Initialize rule evaluation engine

Creates a singleton instance of the rule evaluation engine. It will be
used by the integrity component to evaluate rules against app installs,
and then sending an allow or block response.

Bug: 141907044
Test: N/A
Change-Id: I3200de0f53e60bf67c904f153ab15dd665888cfa
This commit is contained in:
Khaled Abdelmohsen
2019-10-02 11:38:22 +01:00
parent f4cc8979e0
commit 3a7a43f7a1

View File

@@ -16,14 +16,38 @@
package com.android.server.integrity.engine;
import java.util.ArrayList;
import java.util.List;
/**
* The engine used to evaluate rules against app installs.
*
* <p>Every app install is evaluated against rules (pushed by the verifier) by the evaluation engine
* to allow/block that install.
*/
public final class RuleEvaluation {
public final class RuleEvaluationEngine {
private static final String TAG = "RuleEvaluation";
// TODO: Add singleton injection.
// The engine for loading rules, retrieving metadata for app installs, and evaluating app
// installs against rules.
private static RuleEvaluationEngine sRuleEvaluationEngine;
// The subset of rules loaded to be used to evaluate an app install request.
// TODO: Load rules relevant to app installs.
private List<String> mRules;
private RuleEvaluationEngine() {
// Initialize rules with the empty rule set.
mRules = new ArrayList<>();
}
/**
* Provide a singleton instance of the rule evaluation engine.
*/
public static synchronized RuleEvaluationEngine getRuleEvaluationEngine() {
if (sRuleEvaluationEngine == null) {
return new RuleEvaluationEngine();
}
return sRuleEvaluationEngine;
}
}