blob: dd871e2bbe6c8811dc1c61fbd1cbe5aacee44d4c [file] [log] [blame]
Omer Nebil Yaveroglu30749c82019-12-17 18:23:16 +00001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.integrity.serializer;
18
19import android.annotation.IntDef;
20
21import java.lang.annotation.Retention;
22import java.lang.annotation.RetentionPolicy;
23
24/** Holds the indexing type and indexing key of a given formula. */
25class RuleIndexingDetails {
26
27 static final int NOT_INDEXED = 0;
28 static final int PACKAGE_NAME_INDEXED = 1;
29 static final int APP_CERTIFICATE_INDEXED = 2;
30
31 /** Represents which indexed file the rule should be located. */
32 @IntDef(
33 value = {
34 NOT_INDEXED,
35 PACKAGE_NAME_INDEXED,
36 APP_CERTIFICATE_INDEXED
37 })
38 @Retention(RetentionPolicy.SOURCE)
39 public @interface IndexType {
40 }
41
42 private @IndexType int mIndexType;
43 private String mRuleKey;
44
45 /** Constructor without a ruleKey for {@code NOT_INDEXED}. */
46 RuleIndexingDetails(@IndexType int indexType) {
47 this.mIndexType = indexType;
48 this.mRuleKey = null;
49 }
50
51 /** Constructor with a ruleKey for indexed rules. */
52 RuleIndexingDetails(@IndexType int indexType, String ruleKey) {
53 this.mIndexType = indexType;
54 this.mRuleKey = ruleKey;
55 }
56
57 /** Returns the indexing type for the rule. */
58 @IndexType
59 public int getIndexType() {
60 return mIndexType;
61 }
62
63 /** Returns the identified rule key. */
64 public String getRuleKey() {
65 return mRuleKey;
66 }
67}