1 /*
2  * Copyright (C) 2021 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.systemui.flags
18 
19 import android.os.SystemProperties
20 import javax.inject.Inject
21 import javax.inject.Singleton
22 
23 /** Proxy to make {@link SystemProperties} easily testable. */
24 @Singleton
25 open class SystemPropertiesHelper @Inject constructor() {
getnull26     open fun get(name: String): String {
27         return SystemProperties.get(name)
28     }
29 
getnull30     open fun get(name: String, def: String?): String {
31         return SystemProperties.get(name, def)
32     }
33 
getBooleannull34     open fun getBoolean(name: String, default: Boolean): Boolean {
35         return SystemProperties.getBoolean(name, default)
36     }
37 
setBooleannull38     open fun setBoolean(name: String, value: Boolean) {
39         SystemProperties.set(name, if (value) "1" else "0")
40     }
41 
setnull42     open fun set(name: String, value: String) {
43         SystemProperties.set(name, value)
44     }
45 
setnull46     open fun set(name: String, value: Int) {
47         set(name, value.toString())
48     }
49 
erasenull50     open fun erase(name: String) {
51         set(name, "")
52     }
53 }
54