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.qs.dagger;
18 
19 import android.content.Context;
20 import android.hardware.display.ColorDisplayManager;
21 
22 import com.android.systemui.dagger.SysUISingleton;
23 import com.android.systemui.flags.FeatureFlags;
24 import com.android.systemui.flags.Flags;
25 import com.android.systemui.util.settings.GlobalSettings;
26 
27 import dagger.Module;
28 import dagger.Provides;
29 
30 import javax.inject.Named;
31 
32 @Module
33 public interface QSFlagsModule {
34 
35     String RBC_AVAILABLE = "rbc_available";
36     String PM_LITE_ENABLED = "pm_lite";
37     String PM_LITE_SETTING = "sysui_pm_lite";
38     int PM_LITE_SETTING_DEFAULT = 1;
39 
40     /** */
41     @Provides
42     @SysUISingleton
43     @Named(RBC_AVAILABLE)
isReduceBrightColorsAvailable(Context context)44     static boolean isReduceBrightColorsAvailable(Context context) {
45         return ColorDisplayManager.isReduceBrightColorsAvailable(context);
46     }
47 
48     @Provides
49     @SysUISingleton
50     @Named(PM_LITE_ENABLED)
isPMLiteEnabled(FeatureFlags featureFlags, GlobalSettings globalSettings)51     static boolean isPMLiteEnabled(FeatureFlags featureFlags, GlobalSettings globalSettings) {
52         return featureFlags.isEnabled(Flags.POWER_MENU_LITE)
53                 && globalSettings.getInt(PM_LITE_SETTING, PM_LITE_SETTING_DEFAULT) != 0;
54     }
55 }
56