• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.systemui.accessibility.extradim
17 
18 import android.content.BroadcastReceiver
19 import android.content.Context
20 import android.content.Intent
21 import com.android.server.display.feature.flags.Flags
22 import javax.inject.Inject
23 
24 /**
25  * BroadcastReceiver for handling [ExtraDimDialogDelegate] intent.
26  *
27  * This is not exported. Need to call from framework and use SYSTEM user to send the intent.
28  */
29 class ExtraDimDialogReceiver
30 @Inject
31 constructor(
32     private val extraDimDialogManager: ExtraDimDialogManager,
33 ) : BroadcastReceiver() {
34 
onReceivenull35     override fun onReceive(context: Context, intent: Intent) {
36         if (
37             !Flags.evenDimmer() ||
38                 !context
39                     .getResources()
40                     .getBoolean(com.android.internal.R.bool.config_evenDimmerEnabled)
41         ) {
42             return
43         }
44 
45         if (ACTION == intent.action) {
46             extraDimDialogManager.dismissKeyguardIfNeededAndShowDialog()
47         }
48     }
49 
50     companion object {
51         const val ACTION = "com.android.systemui.action.LAUNCH_REMOVE_EXTRA_DIM_DIALOG"
52     }
53 }
54