1 /* 2 * Copyright (C) 2010 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.app; 18 19 import android.app.IOnProjectionStateChangedListener; 20 21 /** 22 * Interface used to control special UI modes. 23 * @hide 24 */ 25 interface IUiModeManager { 26 /** 27 * Enables the car mode. Only the system can do this. 28 * @hide 29 */ enableCarMode(int flags, int priority, String callingPackage)30 void enableCarMode(int flags, int priority, String callingPackage); 31 32 /** 33 * Disables the car mode. 34 */ 35 @UnsupportedAppUsage(maxTargetSdk = 28) disableCarMode(int flags)36 void disableCarMode(int flags); 37 38 /** 39 * Disables car mode (the original version is marked unsupported app usage so cannot be changed 40 * for the time being). 41 */ disableCarModeByCallingPackage(int flags, String callingPackage)42 void disableCarModeByCallingPackage(int flags, String callingPackage); 43 44 /** 45 * Return the current running mode. 46 */ getCurrentModeType()47 int getCurrentModeType(); 48 49 /** 50 * Sets the night mode. 51 * <p> 52 * The mode can be one of: 53 * <ol>notnight mode</ol> 54 * <ol>night mode</ol> 55 * <ol>custom schedule mode switching</ol> 56 */ setNightMode(int mode)57 void setNightMode(int mode); 58 59 /** 60 * Gets the currently configured night mode. 61 * <p> 62 * Returns 63 * <ol>notnight mode</ol> 64 * <ol>night mode</ol> 65 * <ol>custom schedule mode switching</ol> 66 */ getNightMode()67 int getNightMode(); 68 69 /** 70 * Sets the current night mode to {@link #MODE_NIGHT_CUSTOM} with the custom night mode type 71 * {@code nightModeCustomType}. 72 * 73 * @param nightModeCustomType 74 * @hide 75 */ 76 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)") setNightModeCustomType(int nightModeCustomType)77 void setNightModeCustomType(int nightModeCustomType); 78 79 /** 80 * Returns the custom night mode type. 81 * <p> 82 * If the current night mode is not {@link #MODE_NIGHT_CUSTOM}, returns 83 * {@link #MODE_NIGHT_CUSTOM_TYPE_UNKNOWN}. 84 * @hide 85 */ 86 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)") getNightModeCustomType()87 int getNightModeCustomType(); 88 89 /** 90 * Sets the dark mode for the given application. This setting is persisted and will override the 91 * system configuration for this application. 92 * 1 - notnight mode 93 * 2 - night mode 94 * 3 - automatic mode switching 95 */ setApplicationNightMode(in int mode)96 void setApplicationNightMode(in int mode); 97 98 /** 99 * Tells if UI mode is locked or not. 100 */ isUiModeLocked()101 boolean isUiModeLocked(); 102 103 /** 104 * Tells if Night mode is locked or not. 105 */ isNightModeLocked()106 boolean isNightModeLocked(); 107 108 /** 109 * [De]activating night mode for the current user if the current night mode is custom and the 110 * custom type matches {@code nightModeCustomType}. 111 * 112 * @param nightModeCustomType the specify type of custom mode 113 * @param active {@code true} to activate night mode. Otherwise, deactivate night mode 114 * @return {@code true} if night mode has successfully activated for the requested 115 * {@code nightModeCustomType}. 116 * @hide 117 */ 118 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)") setNightModeActivatedForCustomMode(int nightModeCustom, boolean active)119 boolean setNightModeActivatedForCustomMode(int nightModeCustom, boolean active); 120 121 /** 122 * [De]Activates night mode. 123 * @hide 124 */ setNightModeActivated(boolean active)125 boolean setNightModeActivated(boolean active); 126 127 /** 128 * Returns custom start clock time 129 */ getCustomNightModeStart()130 long getCustomNightModeStart(); 131 132 /** 133 * Sets custom start clock time 134 */ setCustomNightModeStart(long time)135 void setCustomNightModeStart(long time); 136 137 /** 138 * Returns custom end clock time 139 */ getCustomNightModeEnd()140 long getCustomNightModeEnd(); 141 142 /** 143 * Sets custom end clock time 144 */ setCustomNightModeEnd(long time)145 void setCustomNightModeEnd(long time); 146 147 /** 148 * Sets projection state for the caller for the given projection type. 149 */ requestProjection(in IBinder binder, int projectionType, String callingPackage)150 boolean requestProjection(in IBinder binder, int projectionType, String callingPackage); 151 152 /** 153 * Releases projection state for the caller for the given projection type. 154 */ releaseProjection(int projectionType, String callingPackage)155 boolean releaseProjection(int projectionType, String callingPackage); 156 157 /** 158 * Registers a listener for changes to projection state. 159 */ addOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener, int projectionType)160 void addOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener, int projectionType); 161 162 /** 163 * Unregisters a listener for changes to projection state. 164 */ removeOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener)165 void removeOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener); 166 167 /** 168 * Returns packages that have currently set the given projection type. 169 */ getProjectingPackages(int projectionType)170 List<String> getProjectingPackages(int projectionType); 171 172 /** 173 * Returns currently set projection types. 174 */ getActiveProjectionTypes()175 int getActiveProjectionTypes(); 176 } 177