1 /*
2  * Copyright (C) 2023 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.settings.accessibility;
18 
19 import static com.android.settings.accessibility.FlashNotificationsUtil.State;
20 
21 import android.content.Context;
22 
23 import androidx.annotation.ColorInt;
24 import androidx.annotation.NonNull;
25 
26 import org.robolectric.annotation.Implementation;
27 import org.robolectric.annotation.Implements;
28 import org.robolectric.annotation.Resetter;
29 
30 @Implements(FlashNotificationsUtil.class)
31 public class ShadowFlashNotificationsUtils {
32 
33     private static boolean sIsTorchAvailable;
34     private static int sState;
35     private static String sColorDescriptionText = "";
36 
setIsTorchAvailable(boolean isTorchAvailable)37     public static void setIsTorchAvailable(boolean isTorchAvailable) {
38         sIsTorchAvailable = isTorchAvailable;
39     }
40 
41     @Implementation
isTorchAvailable(Context context)42     protected static boolean isTorchAvailable(Context context) {
43         return sIsTorchAvailable;
44     }
45 
setFlashNotificationsState(@tate int state)46     public static void setFlashNotificationsState(@State int state) {
47         sState = state;
48     }
49 
50     @State
51     @Implementation
getFlashNotificationsState(Context context)52     protected static int getFlashNotificationsState(Context context) {
53         return sState;
54     }
55 
setColorDescriptionText(@onNull String text)56     public static void setColorDescriptionText(@NonNull String text) {
57         sColorDescriptionText = text;
58     }
59 
60     @Implementation
61     @NonNull
getColorDescriptionText(@onNull Context context, @ColorInt int color)62     protected static String getColorDescriptionText(@NonNull Context context, @ColorInt int color) {
63         return sColorDescriptionText;
64     }
65 
66     @Resetter
reset()67     public static void reset() {
68         sIsTorchAvailable = false;
69         sState = 0;
70         sColorDescriptionText = "";
71     }
72 }
73