Add a new ui mode for "appliance"

The idea is that this is a device which is more-or-less headless.  It
might have some limited interaction capabilities, but it's not something
that you want to rely on having.

Change-Id: Ib92f53a120bf83de781728011721a4859def7d9f
This commit is contained in:
Joe Onorato
2011-12-14 20:59:30 -08:00
parent 3766a7a275
commit 44fcb83b38
9 changed files with 30 additions and 6 deletions

View File

@@ -6558,6 +6558,7 @@ package android.content.res {
field public static final int UI_MODE_NIGHT_NO = 16; // 0x10
field public static final int UI_MODE_NIGHT_UNDEFINED = 0; // 0x0
field public static final int UI_MODE_NIGHT_YES = 32; // 0x20
field public static final int UI_MODE_TYPE_APPLIANCE = 5; // 0x5
field public static final int UI_MODE_TYPE_CAR = 3; // 0x3
field public static final int UI_MODE_TYPE_DESK = 2; // 0x2
field public static final int UI_MODE_TYPE_MASK = 15; // 0xf

View File

@@ -168,7 +168,7 @@ public class UiModeManager {
* {@link Configuration#UI_MODE_TYPE_NORMAL Configuration.UI_MODE_TYPE_NORMAL},
* {@link Configuration#UI_MODE_TYPE_DESK Configuration.UI_MODE_TYPE_DESK}, or
* {@link Configuration#UI_MODE_TYPE_CAR Configuration.UI_MODE_TYPE_CAR}, or
* {@link Configuration#UI_MODE_TYPE_TELEVISION Configuration.UI_MODE_TYPE_TV}.
* {@link Configuration#UI_MODE_TYPE_TELEVISION Configuration.UI_MODE_TYPE_APPLIANCE}.
*/
public int getCurrentModeType() {
if (mService != null) {

View File

@@ -228,6 +228,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
public static final int UI_MODE_TYPE_DESK = 0x02;
public static final int UI_MODE_TYPE_CAR = 0x03;
public static final int UI_MODE_TYPE_TELEVISION = 0x04;
public static final int UI_MODE_TYPE_APPLIANCE = 0x05;
public static final int UI_MODE_NIGHT_MASK = 0x30;
public static final int UI_MODE_NIGHT_UNDEFINED = 0x00;
@@ -239,7 +240,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
* <p>The {@link #UI_MODE_TYPE_MASK} bits define the overall ui mode of the
* device. They may be one of {@link #UI_MODE_TYPE_UNDEFINED},
* {@link #UI_MODE_TYPE_NORMAL}, {@link #UI_MODE_TYPE_DESK},
* or {@link #UI_MODE_TYPE_CAR}.
* {@link #UI_MODE_TYPE_CAR}, {@link #UI_MODE_TYPE_TELEVISION}, or
* {@link #UI_MODE_TYPE_APPLIANCE}.
*
* <p>The {@link #UI_MODE_NIGHT_MASK} defines whether the screen
* is in a special mode. They may be one of {@link #UI_MODE_NIGHT_UNDEFINED},
@@ -391,6 +393,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
case UI_MODE_TYPE_DESK: sb.append(" desk"); break;
case UI_MODE_TYPE_CAR: sb.append(" car"); break;
case UI_MODE_TYPE_TELEVISION: sb.append(" television"); break;
case UI_MODE_TYPE_APPLIANCE: sb.append(" appliance"); break;
default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
}
switch ((uiMode&UI_MODE_NIGHT_MASK)) {

View File

@@ -270,14 +270,14 @@
<!-- Don't name config resources like this. It should look like config_annoyDianne -->
<bool name="config_annoy_dianne">true</bool>
<!-- XXXXXX END OF RESOURCES USING WRONG NAMING CONVENTION -->
<!-- If this is true, the screen will come on when you unplug usb/power/whatever. -->
<bool name="config_unplugTurnsOnScreen">false</bool>
<!-- If this is true, the screen will fade off. -->
<bool name="config_animateScreenLights">true</bool>
<!-- XXXXXX END OF RESOURCES USING WRONG NAMING CONVENTION -->
<!-- If true, the screen can be rotated via the accelerometer in all 4
rotations as the default behavior. -->
<bool name="config_allowAllRotations">false</bool>
@@ -301,6 +301,14 @@
A value of -1 means no change in orientation by default. -->
<integer name="config_carDockRotation">-1</integer>
<!-- Control the default UI mode type to use when there is no other type override
happening. One of the following values (See Configuration.java):
1 UI_MODE_TYPE_NORMAL
4 UI_MODE_TYPE_TELEVISION
5 UI_MODE_TYPE_APPLIANCE
Any other values will have surprising consequences. -->
<integer name="config_defaultUiModeType">1</integer>
<!-- Control whether being in the desk dock (and powered) always
keeps the screen on. By default it stays on when plugged in to
AC. 0 will not keep it on; or together 1 to stay on when plugged

View File

@@ -955,6 +955,7 @@ struct ResTable_config
UI_MODE_TYPE_DESK = ACONFIGURATION_UI_MODE_TYPE_DESK,
UI_MODE_TYPE_CAR = ACONFIGURATION_UI_MODE_TYPE_CAR,
UI_MODE_TYPE_TELEVISION = ACONFIGURATION_UI_MODE_TYPE_TELEVISION,
UI_MODE_TYPE_APPLIANCE = ACONFIGURATION_UI_MODE_TYPE_APPLIANCE,
// uiMode bits for the night switch.
MASK_UI_MODE_NIGHT = 0x30,

View File

@@ -79,6 +79,7 @@ enum {
ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02,
ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03,
ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04,
ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05,
ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00,
ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,

View File

@@ -319,7 +319,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mSystemReady;
boolean mSystemBooted;
boolean mHdmiPlugged;
int mUiMode = Configuration.UI_MODE_TYPE_NORMAL;
int mUiMode;
int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED;
int mLidOpenRotation;
int mCarDockRotation;
@@ -793,6 +793,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
settingsObserver.observe();
mShortcutManager = new ShortcutManager(context, mHandler);
mShortcutManager.observe();
mUiMode = context.getResources().getInteger(
com.android.internal.R.integer.config_defaultUiModeType);
mHomeIntent = new Intent(Intent.ACTION_MAIN, null);
mHomeIntent.addCategory(Intent.CATEGORY_HOME);
mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK

View File

@@ -90,6 +90,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
private int mNightMode = UiModeManager.MODE_NIGHT_NO;
private boolean mCarModeEnabled = false;
private boolean mCharging = false;
private final int mDefaultUiModeType;
private final boolean mCarModeKeepsScreenOn;
private final boolean mDeskModeKeepsScreenOn;
@@ -347,6 +348,8 @@ class UiModeManagerService extends IUiModeManager.Stub {
mConfiguration.setToDefaults();
mDefaultUiModeType = context.getResources().getInteger(
com.android.internal.R.integer.config_defaultUiModeType);
mCarModeKeepsScreenOn = (context.getResources().getInteger(
com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1);
mDeskModeKeepsScreenOn = (context.getResources().getInteger(
@@ -452,7 +455,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
}
final void updateConfigurationLocked(boolean sendIt) {
int uiMode = Configuration.UI_MODE_TYPE_NORMAL;
int uiMode = mDefaultUiModeType;
if (mCarModeEnabled) {
uiMode = Configuration.UI_MODE_TYPE_CAR;
} else if (isDeskDockState(mDockState)) {

View File

@@ -1019,6 +1019,11 @@ bool AaptGroupEntry::getUiModeTypeName(const char* name,
(out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
| ResTable_config::UI_MODE_TYPE_TELEVISION;
return true;
} else if (strcmp(name, "appliance") == 0) {
if (out) out->uiMode =
(out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
| ResTable_config::UI_MODE_TYPE_APPLIANCE;
return true;
}
return false;