• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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.doze;
18 
19 import android.annotation.NonNull;
20 
21 /**
22  * Interface the doze service uses to communicate with the rest of system UI.
23  */
24 public interface DozeHost {
addCallback(@onNull Callback callback)25     void addCallback(@NonNull Callback callback);
removeCallback(@onNull Callback callback)26     void removeCallback(@NonNull Callback callback);
startDozing()27     void startDozing();
pulseWhileDozing(@onNull PulseCallback callback, int reason)28     void pulseWhileDozing(@NonNull PulseCallback callback, int reason);
stopDozing()29     void stopDozing();
dozeTimeTick()30     void dozeTimeTick();
isPowerSaveActive()31     boolean isPowerSaveActive();
isPulsingBlocked()32     boolean isPulsingBlocked();
isProvisioned()33     boolean isProvisioned();
isBlockingDoze()34     boolean isBlockingDoze();
35 
36     /**
37      * Makes a current pulse last for twice as long.
38      * @param reason why we're extending it.
39      */
extendPulse(int reason)40     void extendPulse(int reason);
41 
setAnimateWakeup(boolean animateWakeup)42     void setAnimateWakeup(boolean animateWakeup);
setAnimateScreenOff(boolean animateScreenOff)43     void setAnimateScreenOff(boolean animateScreenOff);
44 
45     /**
46      * Reports that a tap event happend on the Sensors Low Power Island.
47      *
48      * @param x Touch X, or -1 if sensor doesn't support touch location.
49      * @param y Touch Y, or -1 if sensor doesn't support touch location.
50      */
onSlpiTap(float x, float y)51     void onSlpiTap(float x, float y);
52 
53     /**
54      * Artificially dim down the the display by changing scrim opacities.
55      * @param scrimOpacity opacity from 0 to 1.
56      */
setAodDimmingScrim(float scrimOpacity)57     default void setAodDimmingScrim(float scrimOpacity) {}
58 
59     /**
60      * Sets the actual display brightness.
61      * @param value from 0 to 255.
62      */
setDozeScreenBrightness(int value)63     void setDozeScreenBrightness(int value);
64 
65     /**
66      * Fade out screen before switching off the display power mode.
67      * @param onDisplayOffCallback Executed when the display is black.
68      */
prepareForGentleSleep(Runnable onDisplayOffCallback)69     void prepareForGentleSleep(Runnable onDisplayOffCallback);
70 
71     /**
72      * Cancel pending {@code onDisplayOffCallback} callback.
73      * @see #prepareForGentleSleep(Runnable)
74      */
cancelGentleSleep()75     void cancelGentleSleep();
76 
onIgnoreTouchWhilePulsing(boolean ignore)77     void onIgnoreTouchWhilePulsing(boolean ignore);
78 
79     /**
80      * Leaves pulsing state, going back to ambient UI.
81      */
stopPulsing()82     void stopPulsing();
83 
84     /** Returns whether doze is suppressed. */
isDozeSuppressed()85     boolean isDozeSuppressed();
86 
87     interface Callback {
88         /**
89          * Called when a high priority notification is added.
90          * @param onPulseSuppressedListener A listener that is invoked if the pulse is being
91          *                                  supressed.
92          */
onNotificationAlerted(Runnable onPulseSuppressedListener)93         default void onNotificationAlerted(Runnable onPulseSuppressedListener) {}
94 
95         /**
96          * Called when battery state or power save mode changes.
97          * @param active whether power save is active or not
98          */
onPowerSaveChanged(boolean active)99         default void onPowerSaveChanged(boolean active) {}
100 
101         /** Called when the doze suppression state changes. */
onDozeSuppressedChanged(boolean suppressed)102         default void onDozeSuppressedChanged(boolean suppressed) {}
103     }
104 
105     interface PulseCallback {
onPulseStarted()106         void onPulseStarted();
onPulseFinished()107         void onPulseFinished();
108     }
109 }
110