• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.dreams
18 
19 import com.android.systemui.dagger.SysUISingleton
20 import com.android.systemui.statusbar.policy.CallbackController
21 import javax.inject.Inject
22 
23 /** Dream overlay-related callback information */
24 @SysUISingleton
25 class DreamOverlayCallbackController @Inject constructor() :
26     CallbackController<DreamOverlayCallbackController.Callback> {
27 
28     private val callbacks = mutableSetOf<DreamOverlayCallbackController.Callback>()
29 
30     var isDreaming = false
31         private set
32 
addCallbacknull33     override fun addCallback(callback: DreamOverlayCallbackController.Callback) {
34         callbacks.add(callback)
35     }
36 
removeCallbacknull37     override fun removeCallback(callback: DreamOverlayCallbackController.Callback) {
38         callbacks.remove(callback)
39     }
40 
onWakeUpnull41     fun onWakeUp() {
42         isDreaming = false
43         callbacks.forEach { it.onWakeUp() }
44     }
45 
onStartDreamnull46     fun onStartDream() {
47         isDreaming = true
48         callbacks.forEach { it.onStartDream() }
49     }
50 
51     interface Callback {
52         /** Dream overlay has ended */
onWakeUpnull53         fun onWakeUp()
54 
55         /** Dream overlay has started */
56         fun onStartDream()
57     }
58 }
59