Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27b28b3f authored by Tobias Haamel's avatar Tobias Haamel
Browse files

Introduce special UI modes for night and car usage.

The device mode is now called ui mode. Furthermore is the order of
precedence for the resources now in such a way that the ui mode needs
to be specified after the orientation and before the density.

The ui mode can be set, like it is done for the locale, as follows:

IActivityManager am = ActivityManagerNative.getDefault();
Configuration config = am.getConfiguration();
config.uiMode = Configuration.UI_MODE_TYPE_CAR | Configuration.UI_MODE_NIGHT_ANY;
am.updateConfiguration(config);

To allow users to disable the car mode and set the night mode the IUiModeManager
interface is used.

The automatic night mode switching will be added in a separate change.
parent d5663a10
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ LOCAL_SRC_FILES += \
	core/java/android/app/IStatusBar.aidl \
	core/java/android/app/IThumbnailReceiver.aidl \
	core/java/android/app/ITransientNotification.aidl \
	core/java/android/app/IUiModeManager.aidl \
	core/java/android/app/IWallpaperManager.aidl \
	core/java/android/app/IWallpaperManagerCallback.aidl \
	core/java/android/backup/IBackupManager.aidl \
+11 −0
Original line number Diff line number Diff line
@@ -38037,6 +38037,17 @@
 visibility="public"
>
</field>
<field name="EXTRA_CAR_MODE_ENABLED"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.intent.extra.CAR_MODE_ENABLED&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_CC"
 type="java.lang.String"
 transient="false"
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app;

/**
 * Interface used to control special UI modes.
 * @hide
 */
interface IUiModeManager {
    /**
     * Enables the car mode. Only the system can do this.
     * @hide
     */
    void enableCarMode();

    /**
     * Disables the car mode.
     */
    void disableCarMode();

    /**
     * Sets the night mode.
     * The mode can be one of:
     *   1 - notnight mode
     *   2 - night mode
     *   3 - automatic mode switching
     */
    void setNightMode(int mode);

    /**
     * Gets the currently configured night mode.  Return 1 for notnight,
     * 2 for night, and 3 for automatic mode switching.
     */
    int getNightMode();
}
+9 −1
Original line number Diff line number Diff line
@@ -1816,7 +1816,9 @@ public class Intent implements Parcelable, Cloneable {
    /**
     * Broadcast Action:  A sticky broadcast indicating the phone was docked
     * or undocked.  Includes the extra
     * field {@link #EXTRA_DOCK_STATE}, containing the current dock state.
     * field {@link #EXTRA_DOCK_STATE}, containing the current dock state. It also
     * includes the boolean extra field {@link #EXTRA_CAR_MODE_ENABLED}, indicating
     * the state of the car mode.
     * This is intended for monitoring the current dock state.
     * To launch an activity from a dock state change, use {@link #CATEGORY_CAR_DOCK}
     * or {@link #CATEGORY_DESK_DOCK} instead.
@@ -2151,6 +2153,12 @@ public class Intent implements Parcelable, Cloneable {
     */
    public static final int EXTRA_DOCK_STATE_CAR = 2;

    /**
     * Used as an boolean extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
     * intents to indicate that the car mode is enabled or not.
     */
    public static final String EXTRA_CAR_MODE_ENABLED = "android.intent.extra.CAR_MODE_ENABLED";

    /**
     * Boolean that can be supplied as meta-data with a dock activity, to
     * indicate that the dock should take over the home key when it is active.
+7 −0
Original line number Diff line number Diff line
@@ -249,6 +249,13 @@ public class ActivityInfo extends ComponentInfo
     * {@link android.R.attr#configChanges} attribute.
     */
    public static final int CONFIG_SCREEN_LAYOUT = 0x0100;
    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle the ui mode. Set from the
     * {@link android.R.attr#configChanges} attribute.
     * @hide (UIMODE) Pending API council approval
     */
    public static final int CONFIG_UI_MODE = 0x0200;
    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle changes to the font scaling factor.  Set from the
Loading