AAPT: Don't imply specific location hardware for dump badging
Permissions such as android.permission.ACCESS_FINE_LOCATION and android.permission.ACCESS_COARSE_LOCATION assumed the underlying feature technology and aapt dump badging would emit an implied feature. This is no longer accurate, so the only implied feature is on the general android.hardware.location when the target SDK of the app is 21+. Bug:25218770 Change-Id: Ica9ebf7d4f360b137af54a8c8fd6c0358cd9be6a
This commit is contained in:
@@ -540,7 +540,7 @@ static bool hasFeature(const char* name, const FeatureGroup& grp,
|
||||
}
|
||||
|
||||
static void addImpliedFeature(KeyedVector<String8, ImpliedFeature>* impliedFeatures,
|
||||
const char* name, const char* reason, bool sdk23) {
|
||||
const char* name, const String8& reason, bool sdk23) {
|
||||
String8 name8(name);
|
||||
ssize_t idx = impliedFeatures->indexOfKey(name8);
|
||||
if (idx < 0) {
|
||||
@@ -553,7 +553,7 @@ static void addImpliedFeature(KeyedVector<String8, ImpliedFeature>* impliedFeatu
|
||||
if (feature->impliedBySdk23 && !sdk23) {
|
||||
feature->impliedBySdk23 = false;
|
||||
}
|
||||
feature->reasons.add(String8(reason));
|
||||
feature->reasons.add(reason);
|
||||
}
|
||||
|
||||
static void printFeatureGroupImpl(const FeatureGroup& grp,
|
||||
@@ -651,50 +651,58 @@ static void addImpliedFeaturesForPermission(const int targetSdk, const String8&
|
||||
bool impliedBySdk23Permission) {
|
||||
if (name == "android.permission.CAMERA") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.camera",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.ACCESS_FINE_LOCATION") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location.gps",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
if (targetSdk < SDK_LOLLIPOP) {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location.gps",
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location.gps",
|
||||
String8::format("targetSdkVersion < %d", SDK_LOLLIPOP),
|
||||
impliedBySdk23Permission);
|
||||
}
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.ACCESS_MOCK_LOCATION") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.ACCESS_COARSE_LOCATION") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location.network",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
if (targetSdk < SDK_LOLLIPOP) {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location.network",
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location.network",
|
||||
String8::format("targetSdkVersion < %d", SDK_LOLLIPOP),
|
||||
impliedBySdk23Permission);
|
||||
}
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" ||
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.ACCESS_MOCK_LOCATION" ||
|
||||
name == "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" ||
|
||||
name == "android.permission.INSTALL_LOCATION_PROVIDER") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.location",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.BLUETOOTH" ||
|
||||
name == "android.permission.BLUETOOTH_ADMIN") {
|
||||
if (targetSdk > 4) {
|
||||
if (targetSdk > SDK_DONUT) {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.bluetooth",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.bluetooth",
|
||||
"targetSdkVersion > 4", impliedBySdk23Permission);
|
||||
String8::format("targetSdkVersion > %d", SDK_DONUT),
|
||||
impliedBySdk23Permission);
|
||||
}
|
||||
} else if (name == "android.permission.RECORD_AUDIO") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.microphone",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.ACCESS_WIFI_STATE" ||
|
||||
name == "android.permission.CHANGE_WIFI_STATE" ||
|
||||
name == "android.permission.CHANGE_WIFI_MULTICAST_STATE") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.wifi",
|
||||
String8::format("requested %s permission", name.string())
|
||||
.string(), impliedBySdk23Permission);
|
||||
String8::format("requested %s permission", name.string()),
|
||||
impliedBySdk23Permission);
|
||||
} else if (name == "android.permission.CALL_PHONE" ||
|
||||
name == "android.permission.CALL_PRIVILEGED" ||
|
||||
name == "android.permission.MODIFY_PHONE_STATE" ||
|
||||
@@ -707,8 +715,8 @@ static void addImpliedFeaturesForPermission(const int targetSdk, const String8&
|
||||
name == "android.permission.WRITE_APN_SETTINGS" ||
|
||||
name == "android.permission.WRITE_SMS") {
|
||||
addImpliedFeature(impliedFeatures, "android.hardware.telephony",
|
||||
String8("requested a telephony permission").string(),
|
||||
impliedBySdk23Permission);
|
||||
String8("requested a telephony permission"),
|
||||
impliedBySdk23Permission);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1659,18 +1667,18 @@ int doDump(Bundle* bundle)
|
||||
if (error == "") {
|
||||
if (orien == 0 || orien == 6 || orien == 8) {
|
||||
// Requests landscape, sensorLandscape, or reverseLandscape.
|
||||
addImpliedFeature(&impliedFeatures,
|
||||
"android.hardware.screen.landscape",
|
||||
"one or more activities have specified a "
|
||||
"landscape orientation",
|
||||
false);
|
||||
addImpliedFeature(
|
||||
&impliedFeatures, "android.hardware.screen.landscape",
|
||||
String8("one or more activities have specified a "
|
||||
"landscape orientation"),
|
||||
false);
|
||||
} else if (orien == 1 || orien == 7 || orien == 9) {
|
||||
// Requests portrait, sensorPortrait, or reversePortrait.
|
||||
addImpliedFeature(&impliedFeatures,
|
||||
"android.hardware.screen.portrait",
|
||||
"one or more activities have specified a "
|
||||
"portrait orientation",
|
||||
false);
|
||||
addImpliedFeature(
|
||||
&impliedFeatures, "android.hardware.screen.portrait",
|
||||
String8("one or more activities have specified a "
|
||||
"portrait orientation"),
|
||||
false);
|
||||
}
|
||||
}
|
||||
} else if (tag == "uses-library") {
|
||||
@@ -2026,7 +2034,7 @@ int doDump(Bundle* bundle)
|
||||
// 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);
|
||||
String8("default feature for all apps"), false);
|
||||
}
|
||||
|
||||
const size_t numFeatureGroups = featureGroups.size();
|
||||
|
||||
Reference in New Issue
Block a user