blob: ff76adfd5b6a70c062cca48ce51551f2e6f54973 [file] [log] [blame]
Govinda Wasserman48cdd682019-06-04 12:15:23 -04001/*
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
17package com.android.systemui.assist;
18
19import android.provider.DeviceConfig;
20
21import androidx.annotation.Nullable;
22
23import java.util.concurrent.Executor;
24
Govinda Wasserman3fcd7172019-09-05 16:32:23 -040025import javax.inject.Inject;
26import 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 Caseye1ff28d2019-06-18 17:58:44 -040034public class PhenotypeHelper {
Govinda Wasserman48cdd682019-06-04 12:15:23 -040035
Govinda Wasserman3fcd7172019-09-05 16:32:23 -040036 @Inject
Matt Caseye1ff28d2019-06-18 17:58:44 -040037 public PhenotypeHelper() {}
Govinda Wasserman48cdd682019-06-04 12:15:23 -040038
Matt Caseye1ff28d2019-06-18 17:58:44 -040039 public long getLong(String name, long defaultValue) {
Govinda Wasserman48cdd682019-06-04 12:15:23 -040040 return DeviceConfig.getLong(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue);
41 }
42
Matt Caseye1ff28d2019-06-18 17:58:44 -040043 public int getInt(String name, int defaultValue) {
Govinda Wasserman48cdd682019-06-04 12:15:23 -040044 return DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue);
45 }
46
47 @Nullable
Matt Caseye1ff28d2019-06-18 17:58:44 -040048 public String getString(String name, @Nullable String defaultValue) {
Govinda Wasserman48cdd682019-06-04 12:15:23 -040049 return DeviceConfig.getString(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue);
50 }
51
Matt Caseye1ff28d2019-06-18 17:58:44 -040052 public boolean getBoolean(String name, boolean defaultValue) {
Govinda Wasserman48cdd682019-06-04 12:15:23 -040053 return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue);
54 }
55
Matt Caseye1ff28d2019-06-18 17:58:44 -040056 public void addOnPropertiesChangedListener(
Govinda Wasserman48cdd682019-06-04 12:15:23 -040057 Executor executor, DeviceConfig.OnPropertiesChangedListener listener) {
58 DeviceConfig.addOnPropertiesChangedListener(
59 DeviceConfig.NAMESPACE_SYSTEMUI, executor, listener);
60 }
61}