Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 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.systemui.assist; |
| 18 | |
| 19 | import android.provider.DeviceConfig; |
| 20 | |
| 21 | import androidx.annotation.Nullable; |
| 22 | |
| 23 | import java.util.concurrent.Executor; |
| 24 | |
Govinda Wasserman | 3fcd717 | 2019-09-05 16:32:23 -0400 | [diff] [blame] | 25 | import javax.inject.Inject; |
| 26 | import javax.inject.Singleton; |
| 27 | |
| 28 | /** |
| 29 | * Wrapper class for retrieving phenotype flag values. |
| 30 | * |
| 31 | * Can be mocked in tests for ease of testing the effects of particular values. |
| 32 | */ |
| 33 | @Singleton |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 34 | public class PhenotypeHelper { |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 35 | |
Govinda Wasserman | 3fcd717 | 2019-09-05 16:32:23 -0400 | [diff] [blame] | 36 | @Inject |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 37 | public PhenotypeHelper() {} |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 38 | |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 39 | public long getLong(String name, long defaultValue) { |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 40 | return DeviceConfig.getLong(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue); |
| 41 | } |
| 42 | |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 43 | public int getInt(String name, int defaultValue) { |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 44 | return DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue); |
| 45 | } |
| 46 | |
| 47 | @Nullable |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 48 | public String getString(String name, @Nullable String defaultValue) { |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 49 | return DeviceConfig.getString(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue); |
| 50 | } |
| 51 | |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 52 | public boolean getBoolean(String name, boolean defaultValue) { |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 53 | return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue); |
| 54 | } |
| 55 | |
Matt Casey | e1ff28d | 2019-06-18 17:58:44 -0400 | [diff] [blame] | 56 | public void addOnPropertiesChangedListener( |
Govinda Wasserman | 48cdd68 | 2019-06-04 12:15:23 -0400 | [diff] [blame] | 57 | Executor executor, DeviceConfig.OnPropertiesChangedListener listener) { |
| 58 | DeviceConfig.addOnPropertiesChangedListener( |
| 59 | DeviceConfig.NAMESPACE_SYSTEMUI, executor, listener); |
| 60 | } |
| 61 | } |