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     @EnforcePermission("MODIFY_DAY_NIGHT_MODE")
83     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)")
setNightModeCustomType(int nightModeCustomType)84     void setNightModeCustomType(int nightModeCustomType);
85 
86     /**
87      * Returns the custom night mode type.
88      * <p>
89      * If the current night mode is not {@link #MODE_NIGHT_CUSTOM}, returns
90      * {@link #MODE_NIGHT_CUSTOM_TYPE_UNKNOWN}.
91      * @hide
92      */
93     @EnforcePermission("MODIFY_DAY_NIGHT_MODE")
94     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)")
getNightModeCustomType()95     int getNightModeCustomType();
96 
97     /**
98      * Overlays current Night Mode value.
99      * {@code attentionModeThemeOverlayType}.
100      *
101      * @param attentionModeThemeOverlayType
102      * @hide
103      */
104     @EnforcePermission("MODIFY_DAY_NIGHT_MODE")
105     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)")
setAttentionModeThemeOverlay(int attentionModeThemeOverlayType)106     void setAttentionModeThemeOverlay(int attentionModeThemeOverlayType);
107 
108 
109     /**
110      * Returns current Attention Mode overlay type.
111      * <p>
112      * returns
113      *  <ul>
114      *    <li>{@link #MODE_ATTENTION_OFF}</li>
115      *    <li>{@link #MODE_ATTENTION_NIGHT}</li>
116      *    <li>{@link #MODE_ATTENTION_DAY}</li>
117      *  </ul>
118      * </p>
119      * @hide
120      */
121     @EnforcePermission("MODIFY_DAY_NIGHT_MODE")
122     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)")
getAttentionModeThemeOverlay()123     int getAttentionModeThemeOverlay();
124 
125     /**
126      * Sets the dark mode for the given application. This setting is persisted and will override the
127      * system configuration for this application.
128      *   1 - notnight mode
129      *   2 - night mode
130      *   3 - automatic mode switching
131      */
setApplicationNightMode(in int mode)132     void setApplicationNightMode(in int mode);
133 
134     /**
135      * Tells if UI mode is locked or not.
136      */
isUiModeLocked()137     boolean isUiModeLocked();
138 
139     /**
140      * Tells if Night mode is locked or not.
141      */
isNightModeLocked()142     boolean isNightModeLocked();
143 
144     /**
145      * [De]activating night mode for the current user if the current night mode is custom and the
146      * custom type matches {@code nightModeCustomType}.
147      *
148      * @param nightModeCustomType the specify type of custom mode
149      * @param active {@code true} to activate night mode. Otherwise, deactivate night mode
150      * @return {@code true} if night mode has successfully activated for the requested
151      *         {@code nightModeCustomType}.
152      * @hide
153      */
154     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)")
setNightModeActivatedForCustomMode(int nightModeCustom, boolean active)155     boolean setNightModeActivatedForCustomMode(int nightModeCustom, boolean active);
156 
157     /**
158      * [De]Activates night mode.
159      * @hide
160      */
setNightModeActivated(boolean active)161     boolean setNightModeActivated(boolean active);
162 
163     /**
164     * Returns custom start clock time
165     */
getCustomNightModeStart()166     long getCustomNightModeStart();
167 
168     /**
169     * Sets custom start clock time
170     */
setCustomNightModeStart(long time)171     void setCustomNightModeStart(long time);
172 
173     /**
174     * Returns custom end clock time
175     */
getCustomNightModeEnd()176     long getCustomNightModeEnd();
177 
178     /**
179     * Sets custom end clock time
180     */
setCustomNightModeEnd(long time)181     void setCustomNightModeEnd(long time);
182 
183     /**
184     * Sets projection state for the caller for the given projection type.
185     */
requestProjection(in IBinder binder, int projectionType, String callingPackage)186     boolean requestProjection(in IBinder binder, int projectionType, String callingPackage);
187 
188     /**
189     * Releases projection state for the caller for the given projection type.
190     */
releaseProjection(int projectionType, String callingPackage)191     boolean releaseProjection(int projectionType, String callingPackage);
192 
193     /**
194     * Registers a listener for changes to projection state.
195     */
196     @EnforcePermission("READ_PROJECTION_STATE")
addOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener, int projectionType)197     void addOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener, int projectionType);
198 
199     /**
200     * Unregisters a listener for changes to projection state.
201     */
202     @EnforcePermission("READ_PROJECTION_STATE")
removeOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener)203     void removeOnProjectionStateChangedListener(in IOnProjectionStateChangedListener listener);
204 
205     /**
206     * Returns packages that have currently set the given projection type.
207     */
208     @EnforcePermission("READ_PROJECTION_STATE")
getProjectingPackages(int projectionType)209     List<String> getProjectingPackages(int projectionType);
210 
211     /**
212     * Returns currently set projection types.
213     */
214     @EnforcePermission("READ_PROJECTION_STATE")
getActiveProjectionTypes()215     int getActiveProjectionTypes();
216 
217     /**
218     * Returns the contrast for the current user
219     */
getContrast()220     float getContrast();
221 }
222