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); 43 44 /** 45 * Reports that a tap event happend on the Sensors Low Power Island. 46 * 47 * @param x Touch X, or -1 if sensor doesn't support touch location. 48 * @param y Touch Y, or -1 if sensor doesn't support touch location. 49 */ onSlpiTap(float x, float y)50 void onSlpiTap(float x, float y); 51 52 /** 53 * Artificially dim down the the display by changing scrim opacities. 54 * @param scrimOpacity opacity from 0 to 1. 55 */ setAodDimmingScrim(float scrimOpacity)56 default void setAodDimmingScrim(float scrimOpacity) {} 57 58 /** 59 * Sets the actual display brightness. 60 * @param value from 0 to 255. 61 */ setDozeScreenBrightness(int value)62 void setDozeScreenBrightness(int value); 63 64 /** 65 * Fade out screen before switching off the display power mode. 66 * @param onDisplayOffCallback Executed when the display is black. 67 */ prepareForGentleSleep(Runnable onDisplayOffCallback)68 void prepareForGentleSleep(Runnable onDisplayOffCallback); 69 70 /** 71 * Cancel pending {@code onDisplayOffCallback} callback. 72 * @see #prepareForGentleSleep(Runnable) 73 */ cancelGentleSleep()74 void cancelGentleSleep(); 75 onIgnoreTouchWhilePulsing(boolean ignore)76 void onIgnoreTouchWhilePulsing(boolean ignore); 77 78 /** 79 * Leaves pulsing state, going back to ambient UI. 80 */ stopPulsing()81 void stopPulsing(); 82 83 /** Returns whether doze is suppressed. */ isDozeSuppressed()84 boolean isDozeSuppressed(); 85 86 interface Callback { 87 /** 88 * Called when a high priority notification is added. 89 * @param onPulseSuppressedListener A listener that is invoked if the pulse is being 90 * supressed. 91 */ onNotificationAlerted(Runnable onPulseSuppressedListener)92 default void onNotificationAlerted(Runnable onPulseSuppressedListener) {} 93 94 /** 95 * Called when battery state or power save mode changes. 96 * @param active whether power save is active or not 97 */ onPowerSaveChanged(boolean active)98 default void onPowerSaveChanged(boolean active) {} 99 100 /** Called when the doze suppression state changes. */ onDozeSuppressedChanged(boolean suppressed)101 default void onDozeSuppressedChanged(boolean suppressed) {} 102 } 103 104 interface PulseCallback { onPulseStarted()105 void onPulseStarted(); onPulseFinished()106 void onPulseFinished(); 107 } 108 } 109