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 android.service.dreams; 18 19 20 /** 21 * Dream manager local system service interface. 22 * 23 * @hide Only for use within the system server. 24 */ 25 public abstract class DreamManagerInternal { 26 /** 27 * Called by the power manager to start a dream. 28 * 29 * @param doze If true, starts the doze dream component if one has been configured, 30 * otherwise starts the user-specified dream. 31 * @param reason The reason to start dreaming, which is logged to help debugging. 32 */ startDream(boolean doze, String reason)33 public abstract void startDream(boolean doze, String reason); 34 35 /** 36 * Called by the power manager to stop a dream. 37 * 38 * @param immediate If true, ends the dream summarily, otherwise gives it some time 39 * to perform a proper exit transition. 40 * @param reason The reason to stop dreaming, which is logged to help debugging. 41 */ stopDream(boolean immediate, String reason)42 public abstract void stopDream(boolean immediate, String reason); 43 44 /** 45 * Called by the power manager to determine whether a dream is running. 46 */ isDreaming()47 public abstract boolean isDreaming(); 48 49 /** 50 * Ask the power manager to nap. It will eventually call back into startDream() if/when it is 51 * appropriate to start dreaming. 52 */ requestDream()53 public abstract void requestDream(); 54 55 /** 56 * Whether dreaming can start given user settings and the current dock/charge state. 57 * 58 * @param isScreenOn True if the screen is currently on. 59 */ canStartDreaming(boolean isScreenOn)60 public abstract boolean canStartDreaming(boolean isScreenOn); 61 62 /** 63 * Return whether dreams can continue when undocking by default. Even if the default is true, 64 * it can be overridden temporarily, in which case {@link DreamManagerStateListener} will be 65 * informed of any changes. 66 */ keepDreamingWhenUndockedDefault()67 public abstract boolean keepDreamingWhenUndockedDefault(); 68 69 /** 70 * Register a {@link DreamManagerStateListener}, which will be called when there are changes to 71 * dream state. 72 * 73 * @param listener The listener to register. 74 */ registerDreamManagerStateListener(DreamManagerStateListener listener)75 public abstract void registerDreamManagerStateListener(DreamManagerStateListener listener); 76 77 /** 78 * Unregister a {@link DreamManagerStateListener}, which will be called when there are changes 79 * to dream state. 80 * 81 * @param listener The listener to unregister. 82 */ unregisterDreamManagerStateListener(DreamManagerStateListener listener)83 public abstract void unregisterDreamManagerStateListener(DreamManagerStateListener listener); 84 85 /** 86 * Called when there are changes to dream state. 87 */ 88 public interface DreamManagerStateListener { 89 /** 90 * Called when keep dreaming when undocked has changed. 91 * 92 * @param keepDreaming True if the current dream should continue when undocking. 93 */ onKeepDreamingWhenUndockedChanged(boolean keepDreaming)94 void onKeepDreamingWhenUndockedChanged(boolean keepDreaming); 95 } 96 } 97