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 package com.android.quickstep.util;
17 
18 import androidx.annotation.NonNull;
19 
20 import com.android.systemui.unfold.updates.screen.ScreenStatusProvider;
21 
22 import java.util.ArrayList;
23 import java.util.List;
24 
25 /**
26  * Screen status provider implementation that exposes methods to provide screen
27  * status updates to listeners. It is used to receive screen turned on event from
28  * SystemUI to Launcher.
29  */
30 public class ProxyScreenStatusProvider implements ScreenStatusProvider {
31 
32     public static final ProxyScreenStatusProvider INSTANCE = new ProxyScreenStatusProvider();
33     private final List<ScreenListener> mListeners = new ArrayList<>();
34 
35     /**
36      * Called when the screen is on and ready (windows are drawn and screen blocker is removed)
37      */
onScreenTurnedOn()38     public void onScreenTurnedOn() {
39         mListeners.forEach(ScreenListener::onScreenTurnedOn);
40     }
41 
42     @Override
addCallback(@onNull ScreenListener listener)43     public void addCallback(@NonNull ScreenListener listener) {
44         mListeners.add(listener);
45     }
46 
47     @Override
removeCallback(@onNull ScreenListener listener)48     public void removeCallback(@NonNull ScreenListener listener) {
49         mListeners.remove(listener);
50     }
51 }
52