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 * Makes scrims black and changes animation durations. 67 */ prepareForGentleWakeUp()68 default void prepareForGentleWakeUp() {} 69 onIgnoreTouchWhilePulsing(boolean ignore)70 void onIgnoreTouchWhilePulsing(boolean ignore); 71 72 /** 73 * Leaves pulsing state, going back to ambient UI. 74 */ stopPulsing()75 void stopPulsing(); 76 77 interface Callback { 78 /** 79 * Called when a high priority notification is added. 80 * @param onPulseSuppressedListener A listener that is invoked if the pulse is being 81 * supressed. 82 */ onNotificationAlerted(Runnable onPulseSuppressedListener)83 default void onNotificationAlerted(Runnable onPulseSuppressedListener) {} 84 85 /** 86 * Called when battery state or power save mode changes. 87 * @param active whether power save is active or not 88 */ onPowerSaveChanged(boolean active)89 default void onPowerSaveChanged(boolean active) {} 90 } 91 92 interface PulseCallback { onPulseStarted()93 void onPulseStarted(); onPulseFinished()94 void onPulseFinished(); 95 } 96 } 97