summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Khaled Abdelmohsen <khelmy@google.com> 2019-10-09 16:14:15 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-10-09 16:14:15 +0000
commit4cba33d4384a02fc5a429b3ac33d0f1d3a9daed3 (patch)
tree725835814c8455b94d5c930e2bf5d2e08ccc5077
parent2a1873bed26803763f7078feccfe5fa73687c5c8 (diff)
parent08f25b787b462e40ee7f39965e27c32bce04dcb1 (diff)
Merge "Create evaluation engine outcome"
-rw-r--r--services/core/java/com/android/server/integrity/model/EvaluationOutcome.java67
-rw-r--r--services/core/java/com/android/server/integrity/model/Rule.java2
2 files changed, 68 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/integrity/model/EvaluationOutcome.java b/services/core/java/com/android/server/integrity/model/EvaluationOutcome.java
new file mode 100644
index 000000000000..dc30dc39f44a
--- /dev/null
+++ b/services/core/java/com/android/server/integrity/model/EvaluationOutcome.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.integrity.model;
+
+/**
+ * A class encapsulating the result from the evaluation engine after evaluating rules against app
+ * install metadata.
+ *
+ * <p>It contains the outcome effect (whether to allow or block the install), and the rule causing
+ * that effect.
+ */
+public final class EvaluationOutcome {
+
+ public enum Effect {
+ ALLOW,
+ DENY
+ }
+
+ private final Effect mEffect;
+ private final Rule mRule;
+
+ private EvaluationOutcome(Effect effect, Rule rule) {
+ this.mEffect = effect;
+ this.mRule = rule;
+ }
+
+ public Effect getEffect() {
+ return mEffect;
+ }
+
+ public Rule getRule() {
+ return mRule;
+ }
+
+ /**
+ * Create an ALLOW evaluation outcome.
+ *
+ * @return An evaluation outcome with ALLOW effect and empty rule.
+ */
+ public static EvaluationOutcome allow() {
+ return new EvaluationOutcome(Effect.ALLOW, Rule.EMPTY);
+ }
+
+ /**
+ * Create a DENY evaluation outcome.
+ *
+ * @param rule Rule causing the DENY effect.
+ * @return An evaluation outcome with DENY effect and rule causing that effect.
+ */
+ public static EvaluationOutcome deny(Rule rule) {
+ return new EvaluationOutcome(Effect.DENY, rule);
+ }
+}
diff --git a/services/core/java/com/android/server/integrity/model/Rule.java b/services/core/java/com/android/server/integrity/model/Rule.java
index 4fd40c1e0365..3d233abda5ed 100644
--- a/services/core/java/com/android/server/integrity/model/Rule.java
+++ b/services/core/java/com/android/server/integrity/model/Rule.java
@@ -25,7 +25,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
*/
public final class Rule {
- enum Effect {
+ public enum Effect {
DENY
}