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