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 import androidx.annotation.MainThread; 22 23 /** 24 * Interface the doze service uses to communicate with the rest of system UI. 25 */ 26 public interface DozeHost { addCallback(@onNull Callback callback)27 void addCallback(@NonNull Callback callback); removeCallback(@onNull Callback callback)28 void removeCallback(@NonNull Callback callback); startDozing()29 void startDozing(); pulseWhileDozing(@onNull PulseCallback callback, int reason)30 void pulseWhileDozing(@NonNull PulseCallback callback, int reason); stopDozing()31 void stopDozing(); 32 @MainThread dozeTimeTick()33 void dozeTimeTick(); isPowerSaveActive()34 boolean isPowerSaveActive(); isPulsingBlocked()35 boolean isPulsingBlocked(); isProvisioned()36 boolean isProvisioned(); 37 38 /** 39 * Whether there's a pulse that's been requested but hasn't started transitioning to pulsing 40 * states yet. 41 */ isPulsePending()42 boolean isPulsePending(); 43 44 /** 45 * @param isPulsePending whether a pulse has been requested but hasn't started transitioning 46 * to the pulse state yet 47 */ setPulsePending(boolean isPulsePending)48 void setPulsePending(boolean isPulsePending); 49 50 /** 51 * Makes a current pulse last for twice as long. 52 * @param reason why we're extending it. 53 */ extendPulse(int reason)54 void extendPulse(int reason); 55 setAnimateWakeup(boolean animateWakeup)56 void setAnimateWakeup(boolean animateWakeup); 57 58 /** 59 * Reports that a tap event happend on the Sensors Low Power Island. 60 * 61 * @param x Touch X, or -1 if sensor doesn't support touch location. 62 * @param y Touch Y, or -1 if sensor doesn't support touch location. 63 */ onSlpiTap(float x, float y)64 void onSlpiTap(float x, float y); 65 66 /** 67 * Artificially dim down the the display by changing scrim opacities. 68 * @param scrimOpacity opacity from 0 to 1. 69 */ setAodDimmingScrim(float scrimOpacity)70 default void setAodDimmingScrim(float scrimOpacity) {} 71 72 /** 73 * Sets the actual display brightness. 74 * @param value from 1 to 255. 75 */ setDozeScreenBrightness(int value)76 void setDozeScreenBrightness(int value); 77 78 /** 79 * Sets the actual display brightness. 80 * @param value from {@link PowerManager#BRIGHTNESS_MIN} to {@link PowerManager#BRIGHTNESS_MAX}. 81 */ setDozeScreenBrightnessFloat(float value)82 void setDozeScreenBrightnessFloat(float value); 83 84 /** 85 * Fade out screen before switching off the display power mode. 86 * @param onDisplayOffCallback Executed when the display is black. 87 */ prepareForGentleSleep(Runnable onDisplayOffCallback)88 void prepareForGentleSleep(Runnable onDisplayOffCallback); 89 90 /** 91 * Cancel pending {@code onDisplayOffCallback} callback. 92 * @see #prepareForGentleSleep(Runnable) 93 */ cancelGentleSleep()94 void cancelGentleSleep(); 95 onIgnoreTouchWhilePulsing(boolean ignore)96 void onIgnoreTouchWhilePulsing(boolean ignore); 97 98 /** 99 * Leaves pulsing state, going back to ambient UI. 100 */ stopPulsing()101 void stopPulsing(); 102 103 /** Returns whether always-on-display is suppressed. This does not include suppressing 104 * wake-up gestures. */ isAlwaysOnSuppressed()105 boolean isAlwaysOnSuppressed(); 106 107 interface Callback { 108 /** 109 * Called when a high priority notification is added. 110 * @param onPulseSuppressedListener A listener that is invoked if the pulse is being 111 * supressed. 112 */ onNotificationAlerted(Runnable onPulseSuppressedListener)113 default void onNotificationAlerted(Runnable onPulseSuppressedListener) {} 114 115 /** 116 * Called when battery state or power save mode changes. 117 * @param active whether power save is active or not 118 */ onPowerSaveChanged(boolean active)119 default void onPowerSaveChanged(boolean active) {} 120 121 /** 122 * Called when the always on suppression state changes. See {@link #isAlwaysOnSuppressed()}. 123 */ onAlwaysOnSuppressedChanged(boolean suppressed)124 default void onAlwaysOnSuppressedChanged(boolean suppressed) {} 125 126 /** 127 * Called when the dozing state may have been updated. 128 */ onDozingChanged(boolean isDozing)129 default void onDozingChanged(boolean isDozing) {} 130 131 /** 132 * Called when fingerprint acquisition has started and screen state might need updating. 133 */ onSideFingerprintAcquisitionStarted()134 default void onSideFingerprintAcquisitionStarted() {} 135 } 136 137 interface PulseCallback { onPulseStarted()138 void onPulseStarted(); onPulseFinished()139 void onPulseFinished(); 140 } 141 } 142