diff options
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-rw-r--r-- | api/test-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/app/UiModeManager.java | 5 | ||||
-rw-r--r-- | core/java/android/content/res/Configuration.java | 12 | ||||
-rw-r--r-- | core/res/res/values/config.xml | 1 | ||||
-rw-r--r-- | docs/html/guide/topics/resources/providing-resources.jd | 4 | ||||
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 3 | ||||
-rw-r--r-- | libs/androidfw/include/androidfw/ResourceTypes.h | 1 | ||||
-rw-r--r-- | tools/aapt/AaptConfig.cpp | 10 | ||||
-rw-r--r-- | tools/aapt/SdkConstants.h | 3 | ||||
-rw-r--r-- | tools/aapt2/ConfigDescription.cpp | 10 | ||||
-rw-r--r-- | tools/aapt2/ConfigDescription_test.cpp | 8 | ||||
-rw-r--r-- | 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, Comparable<Configuration * <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}: a {@link #UI_MODE_TYPE_MASK} + * value that corresponds to the + * <a href="{@docRoot}guide/topics/resources/providing-resources.html#UiModeQualifier">vrheadset</a> + * 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, Comparable<Configuration * 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_CAR}, {@link #UI_MODE_TYPE_TELEVISION}, - * {@link #UI_MODE_TYPE_APPLIANCE}, or {@link #UI_MODE_TYPE_WATCH}. + * {@link #UI_MODE_TYPE_APPLIANCE}, {@link #UI_MODE_TYPE_WATCH}, + * or {@link #UI_MODE_TYPE_VR_HEADSET}. * * <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}, @@ -869,6 +875,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration case UI_MODE_TYPE_TELEVISION: sb.append(" television"); break; case UI_MODE_TYPE_APPLIANCE: sb.append(" appliance"); break; case UI_MODE_TYPE_WATCH: sb.append(" watch"); break; + case UI_MODE_TYPE_VR_HEADSET: sb.append(" vrheadset"); break; default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break; } switch ((uiMode&UI_MODE_NIGHT_MASK)) { @@ -1746,6 +1753,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration case Configuration.UI_MODE_TYPE_WATCH: parts.add("watch"); break; + case Configuration.UI_MODE_TYPE_VR_HEADSET: + parts.add("vrheadset"); + break; default: break; } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 89581bbb3ac4..db157bf9cbf3 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -755,6 +755,7 @@ 4 UI_MODE_TYPE_TELEVISION 5 UI_MODE_TYPE_APPLIANCE 6 UI_MODE_TYPE_WATCH + 7 UI_MODE_TYPE_VR_HEADSET Any other values will have surprising consequences. --> <integer name="config_defaultUiModeType">1</integer> 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.</p> <code>television<br/> <code>appliance</code> <code>watch</code> + <code>vrheadset</code> </td> <td> <ul class="nolist"> @@ -605,8 +606,9 @@ which indicates the current device orientation.</p> <li>{@code appliance}: Device is serving as an appliance, with no display</li> <li>{@code watch}: Device has a display and is worn on the wrist</li> + <li>{@code vrheadset}: Device has a virtual reality capable display and is showing the the apps UI on a virtual display</li> </ul> - <p><em>Added in API level 8, television added in API 13, watch added in API 20.</em></p> + <p><em>Added in API level 8, television added in API 13, watch added in API 20, vrheadset added in API 26.</em></p> <p>For information about how your app can respond when the device is inserted into or removed from a dock, read <a href="{@docRoot}training/monitoring-device-state/docking-monitoring.html">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); |