Merge "Introduce new UI_MODE_TYPE_WATCH and qualifier." into klp-modular-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5c31e487c4
@@ -7681,6 +7681,7 @@ package android.content.res {
|
|||||||
field public static final int UI_MODE_TYPE_NORMAL = 1; // 0x1
|
field public static final int UI_MODE_TYPE_NORMAL = 1; // 0x1
|
||||||
field public static final int UI_MODE_TYPE_TELEVISION = 4; // 0x4
|
field public static final int UI_MODE_TYPE_TELEVISION = 4; // 0x4
|
||||||
field public static final int UI_MODE_TYPE_UNDEFINED = 0; // 0x0
|
field public static final int UI_MODE_TYPE_UNDEFINED = 0; // 0x0
|
||||||
|
field public static final int UI_MODE_TYPE_WATCH = 6; // 0x6
|
||||||
field public int densityDpi;
|
field public int densityDpi;
|
||||||
field public float fontScale;
|
field public float fontScale;
|
||||||
field public int hardKeyboardHidden;
|
field public int hardKeyboardHidden;
|
||||||
|
|||||||
@@ -166,9 +166,11 @@ public class UiModeManager {
|
|||||||
/**
|
/**
|
||||||
* Return the current running mode type. May be one of
|
* Return the current running mode type. May be one of
|
||||||
* {@link Configuration#UI_MODE_TYPE_NORMAL Configuration.UI_MODE_TYPE_NORMAL},
|
* {@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_DESK Configuration.UI_MODE_TYPE_DESK},
|
||||||
* {@link Configuration#UI_MODE_TYPE_CAR Configuration.UI_MODE_TYPE_CAR}, or
|
* {@link Configuration#UI_MODE_TYPE_CAR Configuration.UI_MODE_TYPE_CAR},
|
||||||
* {@link Configuration#UI_MODE_TYPE_TELEVISION Configuration.UI_MODE_TYPE_APPLIANCE}.
|
* {@link Configuration#UI_MODE_TYPE_TELEVISION Configuration.UI_MODE_TYPE_TELEVISION},
|
||||||
|
* {@link Configuration#UI_MODE_TYPE_APPLIANCE Configuration.UI_MODE_TYPE_APPLIANCE}, or
|
||||||
|
* {@link Configuration#UI_MODE_TYPE_WATCH Configuration.UI_MODE_TYPE_WATCH}.
|
||||||
*/
|
*/
|
||||||
public int getCurrentModeType() {
|
public int getCurrentModeType() {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
|
|||||||
@@ -440,6 +440,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|||||||
* <a href="{@docRoot}guide/topics/resources/providing-resources.html#UiModeQualifier">appliance</a>
|
* <a href="{@docRoot}guide/topics/resources/providing-resources.html#UiModeQualifier">appliance</a>
|
||||||
* resource qualifier. */
|
* resource qualifier. */
|
||||||
public static final int UI_MODE_TYPE_APPLIANCE = 0x05;
|
public static final int UI_MODE_TYPE_APPLIANCE = 0x05;
|
||||||
|
/** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK}
|
||||||
|
* value that corresponds to the
|
||||||
|
* <a href="{@docRoot}guide/topics/resources/providing-resources.html#UiModeQualifier">watch</a>
|
||||||
|
* resource qualifier. */
|
||||||
|
public static final int UI_MODE_TYPE_WATCH = 0x06;
|
||||||
|
|
||||||
/** Constant for {@link #uiMode}: bits that encode the night mode. */
|
/** Constant for {@link #uiMode}: bits that encode the night mode. */
|
||||||
public static final int UI_MODE_NIGHT_MASK = 0x30;
|
public static final int UI_MODE_NIGHT_MASK = 0x30;
|
||||||
@@ -462,8 +467,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|||||||
* <p>The {@link #UI_MODE_TYPE_MASK} bits define the overall ui mode of the
|
* <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},
|
* device. They may be one of {@link #UI_MODE_TYPE_UNDEFINED},
|
||||||
* {@link #UI_MODE_TYPE_NORMAL}, {@link #UI_MODE_TYPE_DESK},
|
* {@link #UI_MODE_TYPE_NORMAL}, {@link #UI_MODE_TYPE_DESK},
|
||||||
* {@link #UI_MODE_TYPE_CAR}, {@link #UI_MODE_TYPE_TELEVISION}, or
|
* {@link #UI_MODE_TYPE_CAR}, {@link #UI_MODE_TYPE_TELEVISION},
|
||||||
* {@link #UI_MODE_TYPE_APPLIANCE}.
|
* {@link #UI_MODE_TYPE_APPLIANCE}, or {@link #UI_MODE_TYPE_WATCH}.
|
||||||
*
|
*
|
||||||
* <p>The {@link #UI_MODE_NIGHT_MASK} defines whether the screen
|
* <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},
|
* is in a special mode. They may be one of {@link #UI_MODE_NIGHT_UNDEFINED},
|
||||||
@@ -700,6 +705,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
|||||||
case UI_MODE_TYPE_CAR: sb.append(" car"); break;
|
case UI_MODE_TYPE_CAR: sb.append(" car"); break;
|
||||||
case UI_MODE_TYPE_TELEVISION: sb.append(" television"); break;
|
case UI_MODE_TYPE_TELEVISION: sb.append(" television"); break;
|
||||||
case UI_MODE_TYPE_APPLIANCE: sb.append(" appliance"); break;
|
case UI_MODE_TYPE_APPLIANCE: sb.append(" appliance"); break;
|
||||||
|
case UI_MODE_TYPE_WATCH: sb.append(" watch"); break;
|
||||||
default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
|
default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
|
||||||
}
|
}
|
||||||
switch ((uiMode&UI_MODE_NIGHT_MASK)) {
|
switch ((uiMode&UI_MODE_NIGHT_MASK)) {
|
||||||
|
|||||||
@@ -471,6 +471,7 @@
|
|||||||
1 UI_MODE_TYPE_NORMAL
|
1 UI_MODE_TYPE_NORMAL
|
||||||
4 UI_MODE_TYPE_TELEVISION
|
4 UI_MODE_TYPE_TELEVISION
|
||||||
5 UI_MODE_TYPE_APPLIANCE
|
5 UI_MODE_TYPE_APPLIANCE
|
||||||
|
6 UI_MODE_TYPE_WATCH
|
||||||
Any other values will have surprising consequences. -->
|
Any other values will have surprising consequences. -->
|
||||||
<integer name="config_defaultUiModeType">1</integer>
|
<integer name="config_defaultUiModeType">1</integer>
|
||||||
|
|
||||||
|
|||||||
@@ -562,6 +562,7 @@ which indicates the current device orientation.</p>
|
|||||||
<code>desk</code><br/>
|
<code>desk</code><br/>
|
||||||
<code>television<br/>
|
<code>television<br/>
|
||||||
<code>appliance</code>
|
<code>appliance</code>
|
||||||
|
<code>watch</code>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul class="nolist">
|
<ul class="nolist">
|
||||||
@@ -573,8 +574,9 @@ which indicates the current device orientation.</p>
|
|||||||
non-pointer interaction</li>
|
non-pointer interaction</li>
|
||||||
<li>{@code appliance}: Device is serving as an appliance, with
|
<li>{@code appliance}: Device is serving as an appliance, with
|
||||||
no display</li>
|
no display</li>
|
||||||
|
<li>{@code watch}: Device has a display and is worn on the wrist</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><em>Added in API level 8, television added in API 13.</em></p>
|
<p><em>Added in API level 8, television added in API 13, watch added in API 20.</em></p>
|
||||||
<p>For information about how your app can respond when the device is inserted into or
|
<p>For information about how your app can respond when the device is inserted into or
|
||||||
removed from a dock, read <a
|
removed from a dock, read <a
|
||||||
href="{@docRoot}training/monitoring-device-state/docking-monitoring.html">Determining
|
href="{@docRoot}training/monitoring-device-state/docking-monitoring.html">Determining
|
||||||
|
|||||||
@@ -980,6 +980,7 @@ struct ResTable_config
|
|||||||
UI_MODE_TYPE_CAR = ACONFIGURATION_UI_MODE_TYPE_CAR,
|
UI_MODE_TYPE_CAR = ACONFIGURATION_UI_MODE_TYPE_CAR,
|
||||||
UI_MODE_TYPE_TELEVISION = ACONFIGURATION_UI_MODE_TYPE_TELEVISION,
|
UI_MODE_TYPE_TELEVISION = ACONFIGURATION_UI_MODE_TYPE_TELEVISION,
|
||||||
UI_MODE_TYPE_APPLIANCE = ACONFIGURATION_UI_MODE_TYPE_APPLIANCE,
|
UI_MODE_TYPE_APPLIANCE = ACONFIGURATION_UI_MODE_TYPE_APPLIANCE,
|
||||||
|
UI_MODE_TYPE_WATCH = ACONFIGURATION_UI_MODE_TYPE_WATCH,
|
||||||
|
|
||||||
// uiMode bits for the night switch.
|
// uiMode bits for the night switch.
|
||||||
MASK_UI_MODE_NIGHT = 0x30,
|
MASK_UI_MODE_NIGHT = 0x30,
|
||||||
|
|||||||
@@ -2293,6 +2293,9 @@ String8 ResTable_config::toString() const {
|
|||||||
case ResTable_config::UI_MODE_TYPE_APPLIANCE:
|
case ResTable_config::UI_MODE_TYPE_APPLIANCE:
|
||||||
res.append("appliance");
|
res.append("appliance");
|
||||||
break;
|
break;
|
||||||
|
case ResTable_config::UI_MODE_TYPE_WATCH:
|
||||||
|
res.append("watch");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
res.appendFormat("uiModeType=%d",
|
res.appendFormat("uiModeType=%d",
|
||||||
dtohs(screenLayout&ResTable_config::MASK_UI_MODE_TYPE));
|
dtohs(screenLayout&ResTable_config::MASK_UI_MODE_TYPE));
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ final class UiModeManagerService extends SystemService {
|
|||||||
private boolean mCarModeKeepsScreenOn;
|
private boolean mCarModeKeepsScreenOn;
|
||||||
private boolean mDeskModeKeepsScreenOn;
|
private boolean mDeskModeKeepsScreenOn;
|
||||||
private boolean mTelevision;
|
private boolean mTelevision;
|
||||||
|
private boolean mWatch;
|
||||||
private boolean mComputedNightMode;
|
private boolean mComputedNightMode;
|
||||||
|
|
||||||
int mCurUiMode = 0;
|
int mCurUiMode = 0;
|
||||||
@@ -176,6 +177,7 @@ final class UiModeManagerService extends SystemService {
|
|||||||
PackageManager.FEATURE_TELEVISION) ||
|
PackageManager.FEATURE_TELEVISION) ||
|
||||||
context.getPackageManager().hasSystemFeature(
|
context.getPackageManager().hasSystemFeature(
|
||||||
PackageManager.FEATURE_LEANBACK);
|
PackageManager.FEATURE_LEANBACK);
|
||||||
|
mWatch = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
|
||||||
|
|
||||||
mNightMode = Settings.Secure.getInt(context.getContentResolver(),
|
mNightMode = Settings.Secure.getInt(context.getContentResolver(),
|
||||||
Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO);
|
Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO);
|
||||||
@@ -339,8 +341,12 @@ final class UiModeManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateConfigurationLocked() {
|
private void updateConfigurationLocked() {
|
||||||
int uiMode = mTelevision ? Configuration.UI_MODE_TYPE_TELEVISION : mDefaultUiModeType;
|
int uiMode = mDefaultUiModeType;
|
||||||
if (mCarModeEnabled) {
|
if (mTelevision) {
|
||||||
|
uiMode = Configuration.UI_MODE_TYPE_TELEVISION;
|
||||||
|
} else if (mWatch) {
|
||||||
|
uiMode = Configuration.UI_MODE_TYPE_WATCH;
|
||||||
|
} else if (mCarModeEnabled) {
|
||||||
uiMode = Configuration.UI_MODE_TYPE_CAR;
|
uiMode = Configuration.UI_MODE_TYPE_CAR;
|
||||||
} else if (isDeskDockState(mDockState)) {
|
} else if (isDeskDockState(mDockState)) {
|
||||||
uiMode = Configuration.UI_MODE_TYPE_DESK;
|
uiMode = Configuration.UI_MODE_TYPE_DESK;
|
||||||
|
|||||||
@@ -1117,6 +1117,11 @@ bool AaptGroupEntry::getUiModeTypeName(const char* name,
|
|||||||
(out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
|
(out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
|
||||||
| ResTable_config::UI_MODE_TYPE_APPLIANCE;
|
| ResTable_config::UI_MODE_TYPE_APPLIANCE;
|
||||||
return true;
|
return true;
|
||||||
|
} else if (strcmp(name, "watch") == 0) {
|
||||||
|
if (out) out->uiMode =
|
||||||
|
(out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
|
||||||
|
| ResTable_config::UI_MODE_TYPE_WATCH;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user