115a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root/*
215a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * Copyright (C) 2010 The Android Open Source Project
315a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *
415a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * Licensed under the Apache License, Version 2.0 (the "License");
515a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * you may not use this file except in compliance with the License.
615a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * You may obtain a copy of the License at
715a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *
815a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *      http://www.apache.org/licenses/LICENSE-2.0
915a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *
1015a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * Unless required by applicable law or agreed to in writing, software
1115a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * distributed under the License is distributed on an "AS IS" BASIS,
1215a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1315a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * See the License for the specific language governing permissions and
1415a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * limitations under the License.
1515a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root */
1615a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root
1753332883543868fb83e111a07306368b7772b340Tobias Haamelpackage android.app;
1853332883543868fb83e111a07306368b7772b340Tobias Haamel
197299c41630935a2b106e73e5603579a7747f7535Dianne Hackbornimport android.content.Context;
207299c41630935a2b106e73e5603579a7747f7535Dianne Hackbornimport android.content.res.Configuration;
2153332883543868fb83e111a07306368b7772b340Tobias Haamelimport android.os.RemoteException;
2253332883543868fb83e111a07306368b7772b340Tobias Haamelimport android.os.ServiceManager;
2353332883543868fb83e111a07306368b7772b340Tobias Haamelimport android.util.Log;
2453332883543868fb83e111a07306368b7772b340Tobias Haamel
2553332883543868fb83e111a07306368b7772b340Tobias Haamel/**
2653332883543868fb83e111a07306368b7772b340Tobias Haamel * This class provides access to the system uimode services.  These services
2753332883543868fb83e111a07306368b7772b340Tobias Haamel * allow applications to control UI modes of the device.
2853332883543868fb83e111a07306368b7772b340Tobias Haamel * It provides functionality to disable the car mode and it gives access to the
2953332883543868fb83e111a07306368b7772b340Tobias Haamel * night mode settings.
307299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn *
317299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * <p>These facilities are built on top of the underlying
327299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * {@link android.content.Intent#ACTION_DOCK_EVENT} broadcasts that are sent when the user
337299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * physical places the device into and out of a dock.  When that happens,
347299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * the UiModeManager switches the system {@link android.content.res.Configuration}
357299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * to the appropriate UI mode, sends broadcasts about the mode switch, and
367299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * starts the corresponding mode activity if appropriate.  See the
377299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * broadcasts {@link #ACTION_ENTER_CAR_MODE} and
387299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * {@link #ACTION_ENTER_DESK_MODE} for more information.
397299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn *
407299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * <p>In addition, the user may manually switch the system to car mode without
417299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * physically being in a dock.  While in car mode -- whether by manual action
427299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * from the user or being physically placed in a dock -- a notification is
437299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * displayed allowing the user to exit dock mode.  Thus the dock mode
447299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * represented here may be different than the current state of the underlying
457299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn * dock event broadcast.
4653332883543868fb83e111a07306368b7772b340Tobias Haamel *
4753332883543868fb83e111a07306368b7772b340Tobias Haamel * <p>You do not instantiate this class directly; instead, retrieve it through
4853332883543868fb83e111a07306368b7772b340Tobias Haamel * {@link android.content.Context#getSystemService
4929274dc363229a3a4f18c7341f90bd04e39c2c07Tobias Haamel * Context.getSystemService(Context.UI_MODE_SERVICE)}.
5053332883543868fb83e111a07306368b7772b340Tobias Haamel */
5153332883543868fb83e111a07306368b7772b340Tobias Haamelpublic class UiModeManager {
5253332883543868fb83e111a07306368b7772b340Tobias Haamel    private static final String TAG = "UiModeManager";
5353332883543868fb83e111a07306368b7772b340Tobias Haamel
547299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /**
557299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * Broadcast sent when the device's UI has switched to car mode, either
567299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * by being placed in a car dock or explicit action of the user.  After
577299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * sending the broadcast, the system will start the intent
587299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * {@link android.content.Intent#ACTION_MAIN} with category
597299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * {@link android.content.Intent#CATEGORY_CAR_DOCK}
607299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * to display the car UI, which typically what an application would
617299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * implement to provide their own interface.  However, applications can
627299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * also monitor this Intent in order to be informed of mode changes or
637299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * prevent the normal car UI from being displayed by setting the result
647299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * of the broadcast to {@link Activity#RESULT_CANCELED}.
657299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
667299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static String ACTION_ENTER_CAR_MODE = "android.app.action.ENTER_CAR_MODE";
677299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
687299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /**
697299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * Broadcast sent when the device's UI has switch away from car mode back
707299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * to normal mode.  Typically used by a car mode app, to dismiss itself
717299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * when the user exits car mode.
727299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
737299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static String ACTION_EXIT_CAR_MODE = "android.app.action.EXIT_CAR_MODE";
747299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
757299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /**
767299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * Broadcast sent when the device's UI has switched to desk mode,
777299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * by being placed in a desk dock.  After
787299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * sending the broadcast, the system will start the intent
797299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * {@link android.content.Intent#ACTION_MAIN} with category
807299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * {@link android.content.Intent#CATEGORY_DESK_DOCK}
817299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * to display the desk UI, which typically what an application would
827299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * implement to provide their own interface.  However, applications can
837299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * also monitor this Intent in order to be informed of mode changes or
847299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * prevent the normal desk UI from being displayed by setting the result
857299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * of the broadcast to {@link Activity#RESULT_CANCELED}.
867299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
877299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static String ACTION_ENTER_DESK_MODE = "android.app.action.ENTER_DESK_MODE";
887299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
897299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /**
90b999abc3595dc6b06572cce19d4cfa839e83f29cDaniel Sandler     * Broadcast sent when the device's UI has switched away from desk mode back
91b999abc3595dc6b06572cce19d4cfa839e83f29cDaniel Sandler     * to normal mode.  Typically used by a desk mode app, to dismiss itself
92b999abc3595dc6b06572cce19d4cfa839e83f29cDaniel Sandler     * when the user exits desk mode.
937299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
947299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static String ACTION_EXIT_DESK_MODE = "android.app.action.EXIT_DESK_MODE";
957299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
967299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /** Constant for {@link #setNightMode(int)} and {@link #getNightMode()}:
977299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * automatically switch night mode on and off based on the time.
987299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
997299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static final int MODE_NIGHT_AUTO = Configuration.UI_MODE_NIGHT_UNDEFINED >> 4;
1007299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
1017299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /** Constant for {@link #setNightMode(int)} and {@link #getNightMode()}:
1027299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * never run in night mode.
1037299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
1047299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static final int MODE_NIGHT_NO = Configuration.UI_MODE_NIGHT_NO >> 4;
1057299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
1067299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /** Constant for {@link #setNightMode(int)} and {@link #getNightMode()}:
1077299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * always run in night mode.
1087299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
1097299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public static final int MODE_NIGHT_YES = Configuration.UI_MODE_NIGHT_YES >> 4;
11053332883543868fb83e111a07306368b7772b340Tobias Haamel
11153332883543868fb83e111a07306368b7772b340Tobias Haamel    private IUiModeManager mService;
11253332883543868fb83e111a07306368b7772b340Tobias Haamel
11353332883543868fb83e111a07306368b7772b340Tobias Haamel    /*package*/ UiModeManager() {
11453332883543868fb83e111a07306368b7772b340Tobias Haamel        mService = IUiModeManager.Stub.asInterface(
1157299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn                ServiceManager.getService(Context.UI_MODE_SERVICE));
11653332883543868fb83e111a07306368b7772b340Tobias Haamel    }
11753332883543868fb83e111a07306368b7772b340Tobias Haamel
11853332883543868fb83e111a07306368b7772b340Tobias Haamel    /**
119f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * Flag for use with {@link #enableCarMode(int)}: go to the car
120f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * home activity as part of the enable.  Enabling this way ensures
121f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * a clean transition between the current activity (in non-car-mode) and
122f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * the car home activity that will serve as home while in car mode.  This
123f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * will switch to the car home activity even if we are already in car mode.
124d49258fed489bcd72a2b2a6ce3a3c38d4b2531e6Dianne Hackborn     */
125f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn    public static final int ENABLE_CAR_MODE_GO_CAR_HOME = 0x0001;
126d49258fed489bcd72a2b2a6ce3a3c38d4b2531e6Dianne Hackborn
127d49258fed489bcd72a2b2a6ce3a3c38d4b2531e6Dianne Hackborn    /**
1289c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn     * Force device into car mode, like it had been placed in the car dock.
1299c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn     * This will cause the device to switch to the car home UI as part of
1309c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn     * the mode switch.
1319c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn     * @param flags Must be 0.
1329c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn     */
1339c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn    public void enableCarMode(int flags) {
1349c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn        if (mService != null) {
1359c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn            try {
136f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn                mService.enableCarMode(flags);
1379c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn            } catch (RemoteException e) {
1389c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn                Log.e(TAG, "disableCarMode: RemoteException", e);
1399c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn            }
1409c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn        }
1419c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn    }
1429c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn
1439c9c532d3625ba2485eb4ea6924ed0a0163fd958Dianne Hackborn    /**
144f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * Flag for use with {@link #disableCarMode(int)}: go to the normal
145f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * home activity as part of the disable.  Disabling this way ensures
146f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * a clean transition between the current activity (in car mode) and
147f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * the original home activity (which was typically last running without
148f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     * being in car mode).
149f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn     */
150f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn    public static final int DISABLE_CAR_MODE_GO_HOME = 0x0001;
151f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn
152f5c5d22c471f399f215662a8e471bf02b5b6bcfaDianne Hackborn    /**
1537299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * Turn off special mode if currently in car mode.
154d49258fed489bcd72a2b2a6ce3a3c38d4b2531e6Dianne Hackborn     * @param flags May be 0 or {@link #DISABLE_CAR_MODE_GO_HOME}.
15553332883543868fb83e111a07306368b7772b340Tobias Haamel     */
156d49258fed489bcd72a2b2a6ce3a3c38d4b2531e6Dianne Hackborn    public void disableCarMode(int flags) {
15753332883543868fb83e111a07306368b7772b340Tobias Haamel        if (mService != null) {
15853332883543868fb83e111a07306368b7772b340Tobias Haamel            try {
159d49258fed489bcd72a2b2a6ce3a3c38d4b2531e6Dianne Hackborn                mService.disableCarMode(flags);
16053332883543868fb83e111a07306368b7772b340Tobias Haamel            } catch (RemoteException e) {
16153332883543868fb83e111a07306368b7772b340Tobias Haamel                Log.e(TAG, "disableCarMode: RemoteException", e);
16253332883543868fb83e111a07306368b7772b340Tobias Haamel            }
16353332883543868fb83e111a07306368b7772b340Tobias Haamel        }
16453332883543868fb83e111a07306368b7772b340Tobias Haamel    }
16553332883543868fb83e111a07306368b7772b340Tobias Haamel
16653332883543868fb83e111a07306368b7772b340Tobias Haamel    /**
1677299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * Return the current running mode type.  May be one of
1687299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * {@link Configuration#UI_MODE_TYPE_NORMAL Configuration.UI_MODE_TYPE_NORMAL},
1697299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * {@link Configuration#UI_MODE_TYPE_DESK Configuration.UI_MODE_TYPE_DESK}, or
170e360bb6bd8ea84b8d37604fc11dfc744b18fb0deDianne Hackborn     * {@link Configuration#UI_MODE_TYPE_CAR Configuration.UI_MODE_TYPE_CAR}, or
17144fcb83b38b062a650ddf556fe7f5e34905df9eaJoe Onorato     * {@link Configuration#UI_MODE_TYPE_TELEVISION Configuration.UI_MODE_TYPE_APPLIANCE}.
1727299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     */
1737299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    public int getCurrentModeType() {
1747299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn        if (mService != null) {
1757299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn            try {
1767299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn                return mService.getCurrentModeType();
1777299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn            } catch (RemoteException e) {
1787299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn                Log.e(TAG, "getCurrentModeType: RemoteException", e);
1797299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn            }
1807299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn        }
1817299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn        return Configuration.UI_MODE_TYPE_NORMAL;
1827299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    }
1837299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn
1847299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn    /**
18553332883543868fb83e111a07306368b7772b340Tobias Haamel     * Sets the night mode.  Changes to the night mode are only effective when
1867299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * the car or desk mode is enabled on a device.
18753332883543868fb83e111a07306368b7772b340Tobias Haamel     *
18853332883543868fb83e111a07306368b7772b340Tobias Haamel     * <p>The mode can be one of:
18953332883543868fb83e111a07306368b7772b340Tobias Haamel     * <ul>
1907299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     *   <li><em>{@link #MODE_NIGHT_NO}<em> - sets the device into notnight
19153332883543868fb83e111a07306368b7772b340Tobias Haamel     *       mode.</li>
1927299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     *   <li><em>{@link #MODE_NIGHT_YES}</em> - sets the device into night mode.
19353332883543868fb83e111a07306368b7772b340Tobias Haamel     *   </li>
1947299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     *   <li><em>{@link #MODE_NIGHT_AUTO}</em> - automatic night/notnight switching
19553332883543868fb83e111a07306368b7772b340Tobias Haamel     *       depending on the location and certain other sensors.</li>
1967299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * </ul>
19753332883543868fb83e111a07306368b7772b340Tobias Haamel     */
19853332883543868fb83e111a07306368b7772b340Tobias Haamel    public void setNightMode(int mode) {
19953332883543868fb83e111a07306368b7772b340Tobias Haamel        if (mService != null) {
20053332883543868fb83e111a07306368b7772b340Tobias Haamel            try {
20153332883543868fb83e111a07306368b7772b340Tobias Haamel                mService.setNightMode(mode);
20253332883543868fb83e111a07306368b7772b340Tobias Haamel            } catch (RemoteException e) {
20353332883543868fb83e111a07306368b7772b340Tobias Haamel                Log.e(TAG, "setNightMode: RemoteException", e);
20453332883543868fb83e111a07306368b7772b340Tobias Haamel            }
20553332883543868fb83e111a07306368b7772b340Tobias Haamel        }
20653332883543868fb83e111a07306368b7772b340Tobias Haamel    }
20753332883543868fb83e111a07306368b7772b340Tobias Haamel
20853332883543868fb83e111a07306368b7772b340Tobias Haamel    /**
20953332883543868fb83e111a07306368b7772b340Tobias Haamel     * Returns the currently configured night mode.
21053332883543868fb83e111a07306368b7772b340Tobias Haamel     *
2117299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     * @return {@link #MODE_NIGHT_NO}, {@link #MODE_NIGHT_YES}, or
2127299c41630935a2b106e73e5603579a7747f7535Dianne Hackborn     *  {@link #MODE_NIGHT_AUTO}.  When an error occurred -1 is returned.
21353332883543868fb83e111a07306368b7772b340Tobias Haamel     */
21453332883543868fb83e111a07306368b7772b340Tobias Haamel    public int getNightMode() {
21553332883543868fb83e111a07306368b7772b340Tobias Haamel        if (mService != null) {
21653332883543868fb83e111a07306368b7772b340Tobias Haamel            try {
21753332883543868fb83e111a07306368b7772b340Tobias Haamel                return mService.getNightMode();
21853332883543868fb83e111a07306368b7772b340Tobias Haamel            } catch (RemoteException e) {
21953332883543868fb83e111a07306368b7772b340Tobias Haamel                Log.e(TAG, "getNightMode: RemoteException", e);
22053332883543868fb83e111a07306368b7772b340Tobias Haamel            }
22153332883543868fb83e111a07306368b7772b340Tobias Haamel        }
22253332883543868fb83e111a07306368b7772b340Tobias Haamel        return -1;
22353332883543868fb83e111a07306368b7772b340Tobias Haamel    }
22453332883543868fb83e111a07306368b7772b340Tobias Haamel}
225