1 /*
2  * Copyright (C) 2024 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 android.platform.test.ravenwood;
18 
19 import java.util.HashMap;
20 import java.util.HashSet;
21 import java.util.Map;
22 import java.util.Set;
23 
24 /**
25  * A class to store system properties defined by tests.
26  */
27 public class RavenwoodTestProperties {
28     final Map<String, String> mValues = new HashMap<>();
29 
30     /** Set of additional keys that should be considered readable */
31     final Set<String> mKeyReadable = new HashSet<>();
32 
33     /** Set of additional keys that should be considered writable */
34     final Set<String> mKeyWritable = new HashSet<>();
35 
setValue(String key, Object value)36     public void setValue(String key, Object value) {
37         final String valueString = (value == null) ? null : String.valueOf(value);
38         if ((valueString == null) || valueString.isEmpty()) {
39             mValues.remove(key);
40         } else {
41             mValues.put(key, valueString);
42         }
43     }
44 
setAccessNone(String key)45     public void setAccessNone(String key) {
46         mKeyReadable.remove(key);
47         mKeyWritable.remove(key);
48     }
49 
setAccessReadOnly(String key)50     public void setAccessReadOnly(String key) {
51         mKeyReadable.add(key);
52         mKeyWritable.remove(key);
53     }
54 
setAccessReadWrite(String key)55     public void setAccessReadWrite(String key) {
56         mKeyReadable.add(key);
57         mKeyWritable.add(key);
58     }
59 }
60