1 /*
2  * Copyright (C) 2024 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 package com.android.settings.datetime;
17 
18 import static android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI;
19 
20 import android.provider.DeviceConfig;
21 
22 import com.android.settings.flags.Flags;
23 
24 /** A class to avoid duplication of launch-control logic for "time feedback" support. */
25 final class TimeFeedbackLaunchUtils {
26     /**
27      * A {@link DeviceConfig} flag that influences whether the settings entries related to help and
28      * feedback are supported on this device / for this user.
29      */
30     public static final String KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED =
31             "time_help_and_feedback_feature_supported";
32 
TimeFeedbackLaunchUtils()33     private TimeFeedbackLaunchUtils() {}
34 
isFeedbackFeatureSupported()35     static boolean isFeedbackFeatureSupported() {
36         // Support is determined according to:
37         // 1) A build-time flag to determine release feature availability.
38         // 2) A runtime / server-side flag to determine which devices / who gets to see the feature.
39         //    This is launch control for limiting the feedback to droidfooding.
40         return isFeatureSupportedThisRelease() && isFeatureSupportedOnThisDevice();
41     }
42 
isFeatureSupportedThisRelease()43     private static boolean isFeatureSupportedThisRelease() {
44         return Flags.datetimeFeedback();
45     }
46 
isFeatureSupportedOnThisDevice()47     private static boolean isFeatureSupportedOnThisDevice() {
48         boolean defaultIsSupported = false;
49         return DeviceConfig.getBoolean(
50                 NAMESPACE_SETTINGS_UI, KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED, defaultIsSupported);
51     }
52 }
53