• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.server.integrity.serializer;
18 
19 import android.annotation.IntDef;
20 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /** Holds the indexing type and indexing key of a given formula. */
25 class 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     static final String DEFAULT_RULE_KEY = "N/A";
32 
33     /** Represents which indexed file the rule should be located. */
34     @IntDef(
35             value = {
36                     NOT_INDEXED,
37                     PACKAGE_NAME_INDEXED,
38                     APP_CERTIFICATE_INDEXED
39             })
40     @Retention(RetentionPolicy.SOURCE)
41     public @interface IndexType {
42     }
43 
44     private @IndexType int mIndexType;
45     private String mRuleKey;
46 
47     /** Constructor without a ruleKey for {@code NOT_INDEXED}. */
RuleIndexingDetails(@ndexType int indexType)48     RuleIndexingDetails(@IndexType int indexType) {
49         this.mIndexType = indexType;
50         this.mRuleKey = DEFAULT_RULE_KEY;
51     }
52 
53     /** Constructor with a ruleKey for indexed rules. */
RuleIndexingDetails(@ndexType int indexType, String ruleKey)54     RuleIndexingDetails(@IndexType int indexType, String ruleKey) {
55         this.mIndexType = indexType;
56         this.mRuleKey = ruleKey;
57     }
58 
59     /** Returns the indexing type for the rule. */
60     @IndexType
getIndexType()61     public int getIndexType() {
62         return mIndexType;
63     }
64 
65     /** Returns the identified rule key. */
getRuleKey()66     public String getRuleKey() {
67         return mRuleKey;
68     }
69 }
70