blob: c21a717dc8cf409cebd8e4eb66d6b9068b4c74f1 [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
Lucas Dupin8968f6a2019-08-09 17:41:15 -070019import static com.android.systemui.DejankUtils.whitelistIpcs;
20
Govinda Wasserman48cdd682019-06-04 12:15:23 -040021import android.provider.DeviceConfig;
22
23import androidx.annotation.Nullable;
24
25import java.util.concurrent.Executor;
26
Matt Caseye1ff28d2019-06-18 17:58:44 -040027public class PhenotypeHelper {
Govinda Wasserman48cdd682019-06-04 12:15:23 -040028
Matt Caseye1ff28d2019-06-18 17:58:44 -040029 public PhenotypeHelper() {}
Govinda Wasserman48cdd682019-06-04 12:15:23 -040030
Matt Caseye1ff28d2019-06-18 17:58:44 -040031 public long getLong(String name, long defaultValue) {
Lucas Dupin8968f6a2019-08-09 17:41:15 -070032 return whitelistIpcs(() ->
33 DeviceConfig.getLong(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue));
Govinda Wasserman48cdd682019-06-04 12:15:23 -040034 }
35
Matt Caseye1ff28d2019-06-18 17:58:44 -040036 public int getInt(String name, int defaultValue) {
Lucas Dupin8968f6a2019-08-09 17:41:15 -070037 return whitelistIpcs(() ->
38 DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue));
Govinda Wasserman48cdd682019-06-04 12:15:23 -040039 }
40
41 @Nullable
Matt Caseye1ff28d2019-06-18 17:58:44 -040042 public String getString(String name, @Nullable String defaultValue) {
Lucas Dupin8968f6a2019-08-09 17:41:15 -070043 return whitelistIpcs(() ->
44 DeviceConfig.getString(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue));
Govinda Wasserman48cdd682019-06-04 12:15:23 -040045 }
46
Matt Caseye1ff28d2019-06-18 17:58:44 -040047 public boolean getBoolean(String name, boolean defaultValue) {
Lucas Dupin8968f6a2019-08-09 17:41:15 -070048 return whitelistIpcs(() ->
49 DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, name, defaultValue));
Govinda Wasserman48cdd682019-06-04 12:15:23 -040050 }
51
Matt Caseye1ff28d2019-06-18 17:58:44 -040052 public void addOnPropertiesChangedListener(
Govinda Wasserman48cdd682019-06-04 12:15:23 -040053 Executor executor, DeviceConfig.OnPropertiesChangedListener listener) {
54 DeviceConfig.addOnPropertiesChangedListener(
55 DeviceConfig.NAMESPACE_SYSTEMUI, executor, listener);
56 }
57}