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 com.android.systemui.dagger.SysUISingleton 21 22 import javax.inject.Inject 23 24 /** 25 * Proxy to make {@link SystemProperties} easily testable. 26 */ 27 @SysUISingleton 28 open class SystemPropertiesHelper @Inject constructor() { 29 fun get(name: String): String { 30 return SystemProperties.get(name) 31 } 32 33 fun getBoolean(name: String, default: Boolean): Boolean { 34 return SystemProperties.getBoolean(name, default) 35 } 36 37 fun setBoolean(name: String, value: Boolean) { 38 SystemProperties.set(name, if (value) "1" else "0") 39 } 40 41 fun set(name: String, value: String) { 42 SystemProperties.set(name, value) 43 } 44 45 fun set(name: String, value: Int) { 46 set(name, value.toString()) 47 } 48 49 fun erase(name: String) { 50 set(name, "") 51 } 52 }