AAPT: faketouch feature implied if no touchscreen feature requested.
This changes the default implied feature of 'android.hardware.touchscreen'
to 'android.hardware.faketouch' if no 'android.hardware.touchscreen'
feature is requested, required or otherwise.
Bug:30571641
Change-Id: I1e41242d4b1dc549cf69741d2a309baf476d084e
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 9976d00..59da467 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -529,6 +529,16 @@
int openGLESVersion;
};
+static bool hasFeature(const char* name, const FeatureGroup& grp,
+ const KeyedVector<String8, ImpliedFeature>& implied) {
+ String8 name8(name);
+ ssize_t idx = grp.features.indexOfKey(name8);
+ if (idx < 0) {
+ idx = implied.indexOfKey(name8);
+ }
+ return idx >= 0;
+}
+
static void addImpliedFeature(KeyedVector<String8, ImpliedFeature>* impliedFeatures,
const char* name, const char* reason, bool sdk23) {
String8 name8(name);
@@ -616,9 +626,16 @@
} else if (name == "android.hardware.location.gps" ||
name == "android.hardware.location.network") {
grp->features.add(String8("android.hardware.location"), Feature(true));
+ } else if (name == "android.hardware.faketouch.multitouch") {
+ grp->features.add(String8("android.hardware.faketouch"), Feature(true));
+ } else if (name == "android.hardware.faketouch.multitouch.distinct" ||
+ name == "android.hardware.faketouch.multitouch.jazzhands") {
+ grp->features.add(String8("android.hardware.faketouch.multitouch"), Feature(true));
+ grp->features.add(String8("android.hardware.faketouch"), Feature(true));
} else if (name == "android.hardware.touchscreen.multitouch") {
grp->features.add(String8("android.hardware.touchscreen"), Feature(true));
- } else if (name == "android.hardware.touchscreen.multitouch.distinct") {
+ } else if (name == "android.hardware.touchscreen.multitouch.distinct" ||
+ name == "android.hardware.touchscreen.multitouch.jazzhands") {
grp->features.add(String8("android.hardware.touchscreen.multitouch"), Feature(true));
grp->features.add(String8("android.hardware.touchscreen"), Feature(true));
} else if (name == "android.hardware.opengles.aep") {
@@ -2005,8 +2022,12 @@
}
}
- addImpliedFeature(&impliedFeatures, "android.hardware.touchscreen",
- "default feature for all apps", false);
+ // If the app hasn't declared the touchscreen as a feature requirement (either
+ // directly or implied, required or not), then the faketouch feature is implied.
+ if (!hasFeature("android.hardware.touchscreen", commonFeatures, impliedFeatures)) {
+ addImpliedFeature(&impliedFeatures, "android.hardware.faketouch",
+ "default feature for all apps", false);
+ }
const size_t numFeatureGroups = featureGroups.size();
if (numFeatureGroups == 0) {