From 1a6acdbb86c3e72bdb0a4dcab3bda58cbc4ea34c Mon Sep 17 00:00:00 2001
From: Zak Cohen
Date: Mon, 12 Dec 2016 15:21:21 -0800
Subject: Introduce new UI_MODE_TYPE_VR_HEADSET and qualifier.
Bug: 30989383
Test: Unit test for aapt2
Change-Id: I66dc65af6327b94fed74538bee08cada0b8be4fa
---
api/current.txt | 1 +
api/system-current.txt | 1 +
api/test-current.txt | 1 +
core/java/android/app/UiModeManager.java | 5 +++--
core/java/android/content/res/Configuration.java | 12 +++++++++++-
core/res/res/values/config.xml | 1 +
docs/html/guide/topics/resources/providing-resources.jd | 4 +++-
libs/androidfw/ResourceTypes.cpp | 3 +++
libs/androidfw/include/androidfw/ResourceTypes.h | 1 +
tools/aapt/AaptConfig.cpp | 10 +++++++++-
tools/aapt/SdkConstants.h | 3 +++
tools/aapt2/ConfigDescription.cpp | 10 +++++++++-
tools/aapt2/ConfigDescription_test.cpp | 8 ++++++++
tools/aapt2/SdkConstants.h | 3 +++
14 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/api/current.txt b/api/current.txt
index 9f6d358bca2f..83e6de4db349 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -10546,6 +10546,7 @@ package android.content.res {
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_UNDEFINED = 0; // 0x0
+ field public static final int UI_MODE_TYPE_VR_HEADSET = 7; // 0x7
field public static final int UI_MODE_TYPE_WATCH = 6; // 0x6
field public int densityDpi;
field public float fontScale;
diff --git a/api/system-current.txt b/api/system-current.txt
index f2b0eaeb2688..d98ea165dc94 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -11048,6 +11048,7 @@ package android.content.res {
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_UNDEFINED = 0; // 0x0
+ field public static final int UI_MODE_TYPE_VR_HEADSET = 7; // 0x7
field public static final int UI_MODE_TYPE_WATCH = 6; // 0x6
field public int densityDpi;
field public float fontScale;
diff --git a/api/test-current.txt b/api/test-current.txt
index c1ec21df688c..a599a8826f1b 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -10577,6 +10577,7 @@ package android.content.res {
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_UNDEFINED = 0; // 0x0
+ field public static final int UI_MODE_TYPE_VR_HEADSET = 7; // 0x7
field public static final int UI_MODE_TYPE_WATCH = 6; // 0x6
field public int densityDpi;
field public float fontScale;
diff --git a/core/java/android/app/UiModeManager.java b/core/java/android/app/UiModeManager.java
index 2e2172919dbc..2572a2021e24 100644
--- a/core/java/android/app/UiModeManager.java
+++ b/core/java/android/app/UiModeManager.java
@@ -194,8 +194,9 @@ public class UiModeManager {
* {@link Configuration#UI_MODE_TYPE_DESK Configuration.UI_MODE_TYPE_DESK},
* {@link Configuration#UI_MODE_TYPE_CAR Configuration.UI_MODE_TYPE_CAR},
* {@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}.
+ * {@link Configuration#UI_MODE_TYPE_APPLIANCE Configuration.UI_MODE_TYPE_APPLIANCE},
+ * {@link Configuration#UI_MODE_TYPE_WATCH Configuration.UI_MODE_TYPE_WATCH}, or
+ * {@link Configuration#UI_MODE_TYPE_VR_HEADSET Configuration.UI_MODE_TYPE_VR_HEADSET}.
*/
public int getCurrentModeType() {
if (mService != null) {
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 227dc91cf108..d44af7fe47a0 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -552,6 +552,11 @@ public final class Configuration implements Parcelable, Comparablewatch
* resource qualifier. */
public static final int UI_MODE_TYPE_WATCH = 0x06;
+ /** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK}
+ * value that corresponds to the
+ * vrheadset
+ * resource qualifier. */
+ public static final int UI_MODE_TYPE_VR_HEADSET = 0x07;
/** Constant for {@link #uiMode}: bits that encode the night mode. */
public static final int UI_MODE_NIGHT_MASK = 0x30;
@@ -575,7 +580,8 @@ public final class Configuration implements Parcelable, ComparableThe {@link #UI_MODE_NIGHT_MASK} defines whether the screen
* is in a special mode. They may be one of {@link #UI_MODE_NIGHT_UNDEFINED},
@@ -869,6 +875,7 @@ public final class Configuration implements Parcelable, Comparable
1
diff --git a/docs/html/guide/topics/resources/providing-resources.jd b/docs/html/guide/topics/resources/providing-resources.jd
index 99aeb4379eeb..77e8d7720c61 100644
--- a/docs/html/guide/topics/resources/providing-resources.jd
+++ b/docs/html/guide/topics/resources/providing-resources.jd
@@ -593,6 +593,7 @@ which indicates the current device orientation.
television
appliance
watch
+ vrheadset
@@ -605,8 +606,9 @@ which indicates the current device orientation.
- {@code appliance}: Device is serving as an appliance, with
no display
- {@code watch}: Device has a display and is worn on the wrist
+ - {@code vrheadset}: Device has a virtual reality capable display and is showing the the apps UI on a virtual display
- Added in API level 8, television added in API 13, watch added in API 20.
+ Added in API level 8, television added in API 13, watch added in API 20, vrheadset added in API 26.
For information about how your app can respond when the device is inserted into or
removed from a dock, read Determining
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 907d9145f4ea..7fbfffe2bde6 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -2994,6 +2994,9 @@ String8 ResTable_config::toString() const {
case ResTable_config::UI_MODE_TYPE_WATCH:
res.append("watch");
break;
+ case ResTable_config::UI_MODE_TYPE_VR_HEADSET:
+ res.append("vrheadset");
+ break;
default:
res.appendFormat("uiModeType=%d",
dtohs(screenLayout&ResTable_config::MASK_UI_MODE_TYPE));
diff --git a/libs/androidfw/include/androidfw/ResourceTypes.h b/libs/androidfw/include/androidfw/ResourceTypes.h
index 08d6591e6886..33b91b9a985e 100644
--- a/libs/androidfw/include/androidfw/ResourceTypes.h
+++ b/libs/androidfw/include/androidfw/ResourceTypes.h
@@ -1102,6 +1102,7 @@ struct ResTable_config
UI_MODE_TYPE_TELEVISION = ACONFIGURATION_UI_MODE_TYPE_TELEVISION,
UI_MODE_TYPE_APPLIANCE = ACONFIGURATION_UI_MODE_TYPE_APPLIANCE,
UI_MODE_TYPE_WATCH = ACONFIGURATION_UI_MODE_TYPE_WATCH,
+ UI_MODE_TYPE_VR_HEADSET = ACONFIGURATION_UI_MODE_TYPE_VR_HEADSET,
// uiMode bits for the night switch.
MASK_UI_MODE_NIGHT = 0x30,
diff --git a/tools/aapt/AaptConfig.cpp b/tools/aapt/AaptConfig.cpp
index b12867a0c135..565d2f0a0549 100644
--- a/tools/aapt/AaptConfig.cpp
+++ b/tools/aapt/AaptConfig.cpp
@@ -249,7 +249,10 @@ void applyVersionForCompatibility(ConfigDescription* config) {
}
uint16_t minSdk = 0;
- if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) {
+ if ((config->uiMode & ResTable_config::MASK_UI_MODE_TYPE)
+ == ResTable_config::UI_MODE_TYPE_VR_HEADSET) {
+ minSdk = SDK_O;
+ } else if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) {
minSdk = SDK_MNC;
} else if (config->density == ResTable_config::DENSITY_ANY) {
minSdk = SDK_LOLLIPOP;
@@ -477,6 +480,11 @@ bool parseUiModeType(const char* name, ResTable_config* out) {
(out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
| ResTable_config::UI_MODE_TYPE_WATCH;
return true;
+ } else if (strcmp(name, "vrheadset") == 0) {
+ if (out) out->uiMode =
+ (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
+ | ResTable_config::UI_MODE_TYPE_VR_HEADSET;
+ return true;
}
return false;
diff --git a/tools/aapt/SdkConstants.h b/tools/aapt/SdkConstants.h
index 16e622ab67ef..d92de062bcf0 100644
--- a/tools/aapt/SdkConstants.h
+++ b/tools/aapt/SdkConstants.h
@@ -39,6 +39,9 @@ enum {
SDK_LOLLIPOP = 21,
SDK_LOLLIPOP_MR1 = 22,
SDK_MNC = 23,
+ SDK_NOUGAT = 24,
+ SDK_NOUGAT_MR1 = 25,
+ SDK_O = 26, // STOPSHIP replace with real version
};
#endif // H_AAPT_SDK_CONSTANTS
diff --git a/tools/aapt2/ConfigDescription.cpp b/tools/aapt2/ConfigDescription.cpp
index 289919a39373..b1bd4012c1df 100644
--- a/tools/aapt2/ConfigDescription.cpp
+++ b/tools/aapt2/ConfigDescription.cpp
@@ -254,6 +254,11 @@ static bool parseUiModeType(const char* name, ResTable_config* out) {
out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
ResTable_config::UI_MODE_TYPE_WATCH;
return true;
+ } else if (strcmp(name, "vrheadset") == 0) {
+ if (out)
+ out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
+ ResTable_config::UI_MODE_TYPE_VR_HEADSET;
+ return true;
}
return false;
@@ -772,7 +777,10 @@ success:
void ConfigDescription::ApplyVersionForCompatibility(
ConfigDescription* config) {
uint16_t min_sdk = 0;
- if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) {
+ if ((config->uiMode & ResTable_config::MASK_UI_MODE_TYPE)
+ == ResTable_config::UI_MODE_TYPE_VR_HEADSET) {
+ min_sdk = SDK_O;
+ } else if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) {
min_sdk = SDK_MARSHMALLOW;
} else if (config->density == ResTable_config::DENSITY_ANY) {
min_sdk = SDK_LOLLIPOP;
diff --git a/tools/aapt2/ConfigDescription_test.cpp b/tools/aapt2/ConfigDescription_test.cpp
index c331dc0f6909..1d22ce03ef1c 100644
--- a/tools/aapt2/ConfigDescription_test.cpp
+++ b/tools/aapt2/ConfigDescription_test.cpp
@@ -99,4 +99,12 @@ TEST(ConfigDescriptionTest, TestParsingRoundQualifier) {
EXPECT_EQ(std::string("notround-v23"), config.toString().string());
}
+TEST(ConfigDescriptionTest, ParseVrAttribute) {
+ ConfigDescription config;
+ EXPECT_TRUE(TestParse("vrheadset", &config));
+ EXPECT_EQ(android::ResTable_config::UI_MODE_TYPE_VR_HEADSET, config.uiMode);
+ EXPECT_EQ(SDK_O, config.sdkVersion);
+ EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string());
+}
+
} // namespace aapt
diff --git a/tools/aapt2/SdkConstants.h b/tools/aapt2/SdkConstants.h
index 9b38ecbeae99..5352b5398544 100644
--- a/tools/aapt2/SdkConstants.h
+++ b/tools/aapt2/SdkConstants.h
@@ -45,6 +45,9 @@ enum {
SDK_LOLLIPOP = 21,
SDK_LOLLIPOP_MR1 = 22,
SDK_MARSHMALLOW = 23,
+ SDK_NOUGAT = 24,
+ SDK_NOUGAT_MR1 = 25,
+ SDK_O = 26, // STOPSHIP Replace with real version
};
size_t FindAttributeSdkLevel(const ResourceId& id);
--
cgit v1.2.3-59-g8ed1b
|