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