Introduce new UI_MODE_TYPE_VR_HEADSET and qualifier.
Bug: 30989383 Test: Unit test for aapt2 Change-Id: I66dc65af6327b94fed74538bee08cada0b8be4fa
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user