DO NOT MERGE: AAPT: Dump uses-permission-sdk-23 am: b2c5155638 am: 40d1ab91d2 am: 8c9209183f am: 7f5ad22330

am: 1f7a36b8e6

* commit '1f7a36b8e6aa55dcb22a63c250fb318260ac349f':
  DO NOT MERGE: AAPT: Dump uses-permission-sdk-23
This commit is contained in:
Adam Lesinski
2015-12-16 23:44:25 +00:00
committed by android-build-merger

View File

@@ -383,6 +383,16 @@ static void printUsesPermission(const String8& name, bool optional=false, int ma
} }
} }
static void printUsesPermissionSdk23(const String8& name, int maxSdkVersion=-1) {
printf("uses-permission-sdk-23: ");
printf("name='%s'", ResTable::normalizeForOutput(name.string()).string());
if (maxSdkVersion != -1) {
printf(" maxSdkVersion='%d'", maxSdkVersion);
}
printf("\n");
}
static void printUsesImpliedPermission(const String8& name, const String8& reason) { static void printUsesImpliedPermission(const String8& name, const String8& reason) {
printf("uses-implied-permission: name='%s' reason='%s'\n", printf("uses-implied-permission: name='%s' reason='%s'\n",
ResTable::normalizeForOutput(name.string()).string(), ResTable::normalizeForOutput(name.string()).string(),
@@ -463,11 +473,19 @@ static void printComponentPresence(const char* componentName) {
* a pre-requisite or some other reason. * a pre-requisite or some other reason.
*/ */
struct ImpliedFeature { struct ImpliedFeature {
ImpliedFeature() : impliedBySdk23(false) {}
ImpliedFeature(const String8& n, bool sdk23) : name(n), impliedBySdk23(sdk23) {}
/** /**
* Name of the implied feature. * Name of the implied feature.
*/ */
String8 name; String8 name;
/**
* Was this implied by a permission from SDK 23 (<uses-permission-sdk-23 />)?
*/
bool impliedBySdk23;
/** /**
* List of human-readable reasons for why this feature was implied. * List of human-readable reasons for why this feature was implied.
*/ */
@@ -497,18 +515,24 @@ struct FeatureGroup {
}; };
static void addImpliedFeature(KeyedVector<String8, ImpliedFeature>* impliedFeatures, static void addImpliedFeature(KeyedVector<String8, ImpliedFeature>* impliedFeatures,
const char* name, const char* reason) { const char* name, const char* reason, bool sdk23) {
String8 name8(name); String8 name8(name);
ssize_t idx = impliedFeatures->indexOfKey(name8); ssize_t idx = impliedFeatures->indexOfKey(name8);
if (idx < 0) { if (idx < 0) {
idx = impliedFeatures->add(name8, ImpliedFeature()); idx = impliedFeatures->add(name8, ImpliedFeature(name8, sdk23));
impliedFeatures->editValueAt(idx).name = name8;
}
impliedFeatures->editValueAt(idx).reasons.add(String8(reason));
} }
static void printFeatureGroup(const FeatureGroup& grp, ImpliedFeature* feature = &impliedFeatures->editValueAt(idx);
const KeyedVector<String8, ImpliedFeature>* impliedFeatures = NULL) {
// A non-sdk 23 implied feature takes precedence.
if (feature->impliedBySdk23 && !sdk23) {
feature->impliedBySdk23 = false;
}
feature->reasons.add(String8(reason));
}
static void printFeatureGroupImpl(const FeatureGroup& grp,
const KeyedVector<String8, ImpliedFeature>* impliedFeatures) {
printf("feature-group: label='%s'\n", grp.label.string()); printf("feature-group: label='%s'\n", grp.label.string());
if (grp.openGLESVersion > 0) { if (grp.openGLESVersion > 0) {
@@ -536,8 +560,10 @@ static void printFeatureGroup(const FeatureGroup& grp,
String8 printableFeatureName(ResTable::normalizeForOutput( String8 printableFeatureName(ResTable::normalizeForOutput(
impliedFeature.name.string())); impliedFeature.name.string()));
printf(" uses-feature: name='%s'\n", printableFeatureName.string()); const char* sdk23Suffix = impliedFeature.impliedBySdk23 ? "-sdk-23" : "";
printf(" uses-implied-feature: name='%s' reason='",
printf(" uses-feature%s: name='%s'\n", sdk23Suffix, printableFeatureName.string());
printf(" uses-implied-feature%s: name='%s' reason='", sdk23Suffix,
printableFeatureName.string()); printableFeatureName.string());
const size_t numReasons = impliedFeature.reasons.size(); const size_t numReasons = impliedFeature.reasons.size();
for (size_t j = 0; j < numReasons; j++) { for (size_t j = 0; j < numReasons; j++) {
@@ -552,6 +578,15 @@ static void printFeatureGroup(const FeatureGroup& grp,
} }
} }
static void printFeatureGroup(const FeatureGroup& grp) {
printFeatureGroupImpl(grp, NULL);
}
static void printDefaultFeatureGroup(const FeatureGroup& grp,
const KeyedVector<String8, ImpliedFeature>& impliedFeatures) {
printFeatureGroupImpl(grp, &impliedFeatures);
}
static void addParentFeatures(FeatureGroup* grp, const String8& name) { static void addParentFeatures(FeatureGroup* grp, const String8& name) {
if (name == "android.hardware.camera.autofocus" || if (name == "android.hardware.camera.autofocus" ||
name == "android.hardware.camera.flash") { name == "android.hardware.camera.flash") {
@@ -572,6 +607,72 @@ static void addParentFeatures(FeatureGroup* grp, const String8& name) {
} }
} }
static void addImpliedFeaturesForPermission(const int targetSdk, const String8& name,
KeyedVector<String8, ImpliedFeature>* impliedFeatures,
bool impliedBySdk23Permission) {
if (name == "android.permission.CAMERA") {
addImpliedFeature(impliedFeatures, "android.hardware.camera",
String8::format("requested %s permission", name.string())
.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);
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);
} else if (name == "android.permission.ACCESS_COARSE_LOCATION") {
addImpliedFeature(impliedFeatures, "android.hardware.location.network",
String8::format("requested %s permission", name.string())
.string(), impliedBySdk23Permission);
addImpliedFeature(impliedFeatures, "android.hardware.location",
String8::format("requested %s permission", name.string())
.string(), impliedBySdk23Permission);
} else if (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);
} else if (name == "android.permission.BLUETOOTH" ||
name == "android.permission.BLUETOOTH_ADMIN") {
if (targetSdk > 4) {
addImpliedFeature(impliedFeatures, "android.hardware.bluetooth",
String8::format("requested %s permission", name.string())
.string(), impliedBySdk23Permission);
addImpliedFeature(impliedFeatures, "android.hardware.bluetooth",
"targetSdkVersion > 4", impliedBySdk23Permission);
}
} else if (name == "android.permission.RECORD_AUDIO") {
addImpliedFeature(impliedFeatures, "android.hardware.microphone",
String8::format("requested %s permission", name.string())
.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);
} else if (name == "android.permission.CALL_PHONE" ||
name == "android.permission.CALL_PRIVILEGED" ||
name == "android.permission.MODIFY_PHONE_STATE" ||
name == "android.permission.PROCESS_OUTGOING_CALLS" ||
name == "android.permission.READ_SMS" ||
name == "android.permission.RECEIVE_SMS" ||
name == "android.permission.RECEIVE_MMS" ||
name == "android.permission.RECEIVE_WAP_PUSH" ||
name == "android.permission.SEND_SMS" ||
name == "android.permission.WRITE_APN_SETTINGS" ||
name == "android.permission.WRITE_SMS") {
addImpliedFeature(impliedFeatures, "android.hardware.telephony",
String8("requested a telephony permission").string(),
impliedBySdk23Permission);
}
}
/* /*
* Handle the "dump" command, to extract select data from an archive. * Handle the "dump" command, to extract select data from an archive.
*/ */
@@ -712,7 +813,8 @@ int doDump(Bundle* bundle)
size_t len; size_t len;
ResXMLTree::event_code_t code; ResXMLTree::event_code_t code;
int depth = 0; int depth = 0;
while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { while ((code=tree.next()) != ResXMLTree::END_DOCUMENT &&
code != ResXMLTree::BAD_DOCUMENT) {
if (code == ResXMLTree::END_TAG) { if (code == ResXMLTree::END_TAG) {
depth--; depth--;
continue; continue;
@@ -735,25 +837,53 @@ int doDump(Bundle* bundle)
} }
String8 pkg = AaptXml::getAttribute(tree, NULL, "package", NULL); String8 pkg = AaptXml::getAttribute(tree, NULL, "package", NULL);
printf("package: %s\n", ResTable::normalizeForOutput(pkg.string()).string()); printf("package: %s\n", ResTable::normalizeForOutput(pkg.string()).string());
} else if (depth == 2 && tag == "permission") { } else if (depth == 2) {
if (tag == "permission") {
String8 error; String8 error;
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error); String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR: %s\n", error.string()); fprintf(stderr, "ERROR: %s\n", error.string());
goto bail; goto bail;
} }
if (name == "") {
fprintf(stderr, "ERROR: missing 'android:name' for permission\n");
goto bail;
}
printf("permission: %s\n", printf("permission: %s\n",
ResTable::normalizeForOutput(name.string()).string()); ResTable::normalizeForOutput(name.string()).string());
} else if (depth == 2 && tag == "uses-permission") { } else if (tag == "uses-permission") {
String8 error; String8 error;
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error); String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR: %s\n", error.string()); fprintf(stderr, "ERROR: %s\n", error.string());
goto bail; goto bail;
} }
if (name == "") {
fprintf(stderr, "ERROR: missing 'android:name' for uses-permission\n");
goto bail;
}
printUsesPermission(name, printUsesPermission(name,
AaptXml::getIntegerAttribute(tree, REQUIRED_ATTR, 1) == 0, AaptXml::getIntegerAttribute(tree, REQUIRED_ATTR, 1) == 0,
AaptXml::getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR)); AaptXml::getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR));
} else if (tag == "uses-permission-sdk-23" || tag == "uses-permission-sdk-m") {
String8 error;
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR: %s\n", error.string());
goto bail;
}
if (name == "") {
fprintf(stderr, "ERROR: missing 'android:name' for "
"uses-permission-sdk-23\n");
goto bail;
}
printUsesPermissionSdk23(
name,
AaptXml::getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR));
}
} }
} }
} else if (strcmp("badging", option) == 0) { } else if (strcmp("badging", option) == 0) {
@@ -893,7 +1023,8 @@ int doDump(Bundle* bundle)
Vector<FeatureGroup> featureGroups; Vector<FeatureGroup> featureGroups;
KeyedVector<String8, ImpliedFeature> impliedFeatures; KeyedVector<String8, ImpliedFeature> impliedFeatures;
while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { while ((code=tree.next()) != ResXMLTree::END_DOCUMENT &&
code != ResXMLTree::BAD_DOCUMENT) {
if (code == ResXMLTree::END_TAG) { if (code == ResXMLTree::END_TAG) {
depth--; depth--;
if (depth < 2) { if (depth < 2) {
@@ -924,8 +1055,10 @@ int doDump(Bundle* bundle)
ResTable::normalizeForOutput(aName.string()).string()); ResTable::normalizeForOutput(aName.string()).string());
} }
printf(" label='%s' icon='%s'\n", printf(" label='%s' icon='%s'\n",
ResTable::normalizeForOutput(activityLabel.string()).string(), ResTable::normalizeForOutput(activityLabel.string())
ResTable::normalizeForOutput(activityIcon.string()).string()); .string(),
ResTable::normalizeForOutput(activityIcon.string())
.string());
} }
if (isLeanbackLauncherActivity) { if (isLeanbackLauncherActivity) {
printf("leanback-launchable-activity:"); printf("leanback-launchable-activity:");
@@ -934,9 +1067,12 @@ int doDump(Bundle* bundle)
ResTable::normalizeForOutput(aName.string()).string()); ResTable::normalizeForOutput(aName.string()).string());
} }
printf(" label='%s' icon='%s' banner='%s'\n", printf(" label='%s' icon='%s' banner='%s'\n",
ResTable::normalizeForOutput(activityLabel.string()).string(), ResTable::normalizeForOutput(activityLabel.string())
ResTable::normalizeForOutput(activityIcon.string()).string(), .string(),
ResTable::normalizeForOutput(activityBanner.string()).string()); ResTable::normalizeForOutput(activityIcon.string())
.string(),
ResTable::normalizeForOutput(activityBanner.string())
.string());
} }
} }
if (!hasIntentFilter) { if (!hasIntentFilter) {
@@ -964,18 +1100,21 @@ int doDump(Bundle* bundle)
hasLauncher |= catLauncher; hasLauncher |= catLauncher;
hasCameraActivity |= actCamera; hasCameraActivity |= actCamera;
hasCameraSecureActivity |= actCameraSecure; hasCameraSecureActivity |= actCameraSecure;
hasOtherActivities |= !actMainActivity && !actCamera && !actCameraSecure; hasOtherActivities |=
!actMainActivity && !actCamera && !actCameraSecure;
} else if (withinReceiver) { } else if (withinReceiver) {
hasWidgetReceivers |= actWidgetReceivers; hasWidgetReceivers |= actWidgetReceivers;
hasDeviceAdminReceiver |= (actDeviceAdminEnabled && hasDeviceAdminReceiver |= (actDeviceAdminEnabled &&
hasBindDeviceAdminPermission); hasBindDeviceAdminPermission);
hasOtherReceivers |= (!actWidgetReceivers && !actDeviceAdminEnabled); hasOtherReceivers |=
(!actWidgetReceivers && !actDeviceAdminEnabled);
} else if (withinService) { } else if (withinService) {
hasImeService |= actImeService; hasImeService |= actImeService;
hasWallpaperService |= actWallpaperService; hasWallpaperService |= actWallpaperService;
hasAccessibilityService |= (actAccessibilityService && hasAccessibilityService |= (actAccessibilityService &&
hasBindAccessibilityServicePermission); hasBindAccessibilityServicePermission);
hasPrintService |= (actPrintService && hasBindPrintServicePermission); hasPrintService |=
(actPrintService && hasBindPrintServicePermission);
hasNotificationListenerService |= actNotificationListenerService && hasNotificationListenerService |= actNotificationListenerService &&
hasBindNotificationListenerServicePermission; hasBindNotificationListenerServicePermission;
hasDreamService |= actDreamService && hasBindDreamServicePermission; hasDreamService |= actDreamService && hasBindDreamServicePermission;
@@ -984,7 +1123,8 @@ int doDump(Bundle* bundle)
!actHostApduService && !actOffHostApduService && !actHostApduService && !actOffHostApduService &&
!actNotificationListenerService); !actNotificationListenerService);
} else if (withinProvider) { } else if (withinProvider) {
hasDocumentsProvider |= actDocumentsProvider && hasRequiredSafAttributes; hasDocumentsProvider |=
actDocumentsProvider && hasRequiredSafAttributes;
} }
} }
withinIntentFilter = false; withinIntentFilter = false;
@@ -1125,7 +1265,8 @@ int doDump(Bundle* bundle)
goto bail; goto bail;
} }
String8 banner = AaptXml::getResolvedAttribute(res, tree, BANNER_ATTR, &error); String8 banner = AaptXml::getResolvedAttribute(res, tree, BANNER_ATTR,
&error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:banner' attribute: %s\n", fprintf(stderr, "ERROR getting 'android:banner' attribute: %s\n",
error.string()); error.string());
@@ -1135,7 +1276,8 @@ int doDump(Bundle* bundle)
ResTable::normalizeForOutput(label.string()).string()); ResTable::normalizeForOutput(label.string()).string());
printf("icon='%s'", ResTable::normalizeForOutput(icon.string()).string()); printf("icon='%s'", ResTable::normalizeForOutput(icon.string()).string());
if (banner != "") { if (banner != "") {
printf(" banner='%s'", ResTable::normalizeForOutput(banner.string()).string()); printf(" banner='%s'",
ResTable::normalizeForOutput(banner.string()).string());
} }
printf("\n"); printf("\n");
if (testOnly != 0) { if (testOnly != 0) {
@@ -1178,13 +1320,15 @@ int doDump(Bundle* bundle)
} }
} }
} else if (tag == "uses-sdk") { } else if (tag == "uses-sdk") {
int32_t code = AaptXml::getIntegerAttribute(tree, MIN_SDK_VERSION_ATTR, &error); int32_t code = AaptXml::getIntegerAttribute(tree, MIN_SDK_VERSION_ATTR,
&error);
if (error != "") { if (error != "") {
error = ""; error = "";
String8 name = AaptXml::getResolvedAttribute(res, tree, String8 name = AaptXml::getResolvedAttribute(res, tree,
MIN_SDK_VERSION_ATTR, &error); MIN_SDK_VERSION_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:minSdkVersion' attribute: %s\n", fprintf(stderr,
"ERROR getting 'android:minSdkVersion' attribute: %s\n",
error.string()); error.string());
goto bail; goto bail;
} }
@@ -1205,7 +1349,8 @@ int doDump(Bundle* bundle)
String8 name = AaptXml::getResolvedAttribute(res, tree, String8 name = AaptXml::getResolvedAttribute(res, tree,
TARGET_SDK_VERSION_ATTR, &error); TARGET_SDK_VERSION_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:targetSdkVersion' attribute: %s\n", fprintf(stderr,
"ERROR getting 'android:targetSdkVersion' attribute: %s\n",
error.string()); error.string());
goto bail; goto bail;
} }
@@ -1297,67 +1442,20 @@ int doDump(Bundle* bundle)
} }
} else if (tag == "uses-permission") { } else if (tag == "uses-permission") {
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error); String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (name != "" && error == "") { if (error != "") {
if (name == "android.permission.CAMERA") { fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
addImpliedFeature(&impliedFeatures, "android.hardware.camera", error.string());
String8::format("requested %s permission", name.string()) goto bail;
.string());
} else if (name == "android.permission.ACCESS_FINE_LOCATION") {
addImpliedFeature(&impliedFeatures, "android.hardware.location.gps",
String8::format("requested %s permission", name.string())
.string());
addImpliedFeature(&impliedFeatures, "android.hardware.location",
String8::format("requested %s permission", name.string())
.string());
} else if (name == "android.permission.ACCESS_MOCK_LOCATION") {
addImpliedFeature(&impliedFeatures, "android.hardware.location",
String8::format("requested %s permission", name.string())
.string());
} else if (name == "android.permission.ACCESS_COARSE_LOCATION") {
addImpliedFeature(&impliedFeatures, "android.hardware.location.network",
String8::format("requested %s permission", name.string())
.string());
addImpliedFeature(&impliedFeatures, "android.hardware.location",
String8::format("requested %s permission", name.string())
.string());
} else if (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());
} else if (name == "android.permission.BLUETOOTH" ||
name == "android.permission.BLUETOOTH_ADMIN") {
if (targetSdk > 4) {
addImpliedFeature(&impliedFeatures, "android.hardware.bluetooth",
String8::format("requested %s permission", name.string())
.string());
addImpliedFeature(&impliedFeatures, "android.hardware.bluetooth",
"targetSdkVersion > 4");
} }
} else if (name == "android.permission.RECORD_AUDIO") {
addImpliedFeature(&impliedFeatures, "android.hardware.microphone", if (name == "") {
String8::format("requested %s permission", name.string()) fprintf(stderr, "ERROR: missing 'android:name' for uses-permission\n");
.string()); goto bail;
} else if (name == "android.permission.ACCESS_WIFI_STATE" || }
name == "android.permission.CHANGE_WIFI_STATE" ||
name == "android.permission.CHANGE_WIFI_MULTICAST_STATE") { addImpliedFeaturesForPermission(targetSdk, name, &impliedFeatures, false);
addImpliedFeature(&impliedFeatures, "android.hardware.wifi",
String8::format("requested %s permission", name.string()) if (name == "android.permission.WRITE_EXTERNAL_STORAGE") {
.string());
} else if (name == "android.permission.CALL_PHONE" ||
name == "android.permission.CALL_PRIVILEGED" ||
name == "android.permission.MODIFY_PHONE_STATE" ||
name == "android.permission.PROCESS_OUTGOING_CALLS" ||
name == "android.permission.READ_SMS" ||
name == "android.permission.RECEIVE_SMS" ||
name == "android.permission.RECEIVE_MMS" ||
name == "android.permission.RECEIVE_WAP_PUSH" ||
name == "android.permission.SEND_SMS" ||
name == "android.permission.WRITE_APN_SETTINGS" ||
name == "android.permission.WRITE_SMS") {
addImpliedFeature(&impliedFeatures, "android.hardware.telephony",
String8("requested a telephony permission").string());
} else if (name == "android.permission.WRITE_EXTERNAL_STORAGE") {
hasWriteExternalStoragePermission = true; hasWriteExternalStoragePermission = true;
} else if (name == "android.permission.READ_EXTERNAL_STORAGE") { } else if (name == "android.permission.READ_EXTERNAL_STORAGE") {
hasReadExternalStoragePermission = true; hasReadExternalStoragePermission = true;
@@ -1376,11 +1474,26 @@ int doDump(Bundle* bundle)
printUsesPermission(name, printUsesPermission(name,
AaptXml::getIntegerAttribute(tree, REQUIRED_ATTR, 1) == 0, AaptXml::getIntegerAttribute(tree, REQUIRED_ATTR, 1) == 0,
AaptXml::getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR)); AaptXml::getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR));
} else {
} else if (tag == "uses-permission-sdk-23" || tag == "uses-permission-sdk-m") {
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
error.string()); error.string());
goto bail; goto bail;
} }
if (name == "") {
fprintf(stderr, "ERROR: missing 'android:name' for "
"uses-permission-sdk-23\n");
goto bail;
}
addImpliedFeaturesForPermission(targetSdk, name, &impliedFeatures, true);
printUsesPermissionSdk23(
name, AaptXml::getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR));
} else if (tag == "uses-package") { } else if (tag == "uses-package") {
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error); String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (name != "" && error == "") { if (name != "" && error == "") {
@@ -1422,7 +1535,8 @@ int doDump(Bundle* bundle)
} else if (tag == "package-verifier") { } else if (tag == "package-verifier") {
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error); String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (name != "" && error == "") { if (name != "" && error == "") {
String8 publicKey = AaptXml::getAttribute(tree, PUBLIC_KEY_ATTR, &error); String8 publicKey = AaptXml::getAttribute(tree, PUBLIC_KEY_ATTR,
&error);
if (publicKey != "" && error == "") { if (publicKey != "" && error == "") {
printf("package-verifier: name='%s' publicKey='%s'\n", printf("package-verifier: name='%s' publicKey='%s'\n",
ResTable::normalizeForOutput(name.string()).string(), ResTable::normalizeForOutput(name.string()).string(),
@@ -1485,12 +1599,18 @@ int doDump(Bundle* bundle)
if (error == "") { if (error == "") {
if (orien == 0 || orien == 6 || orien == 8) { if (orien == 0 || orien == 6 || orien == 8) {
// Requests landscape, sensorLandscape, or reverseLandscape. // Requests landscape, sensorLandscape, or reverseLandscape.
addImpliedFeature(&impliedFeatures, "android.hardware.screen.landscape", addImpliedFeature(&impliedFeatures,
"one or more activities have specified a landscape orientation"); "android.hardware.screen.landscape",
"one or more activities have specified a "
"landscape orientation",
false);
} else if (orien == 1 || orien == 7 || orien == 9) { } else if (orien == 1 || orien == 7 || orien == 9) {
// Requests portrait, sensorPortrait, or reversePortrait. // Requests portrait, sensorPortrait, or reversePortrait.
addImpliedFeature(&impliedFeatures, "android.hardware.screen.portrait", addImpliedFeature(&impliedFeatures,
"one or more activities have specified a portrait orientation"); "android.hardware.screen.portrait",
"one or more activities have specified a "
"portrait orientation",
false);
} }
} }
} else if (tag == "uses-library") { } else if (tag == "uses-library") {
@@ -1524,8 +1644,10 @@ int doDump(Bundle* bundle)
hasBindDeviceAdminPermission = true; hasBindDeviceAdminPermission = true;
} }
} else { } else {
fprintf(stderr, "ERROR getting 'android:permission' attribute for" fprintf(stderr,
" receiver '%s': %s\n", receiverName.string(), error.string()); "ERROR getting 'android:permission' attribute for"
" receiver '%s': %s\n",
receiverName.string(), error.string());
} }
} else if (tag == "service") { } else if (tag == "service") {
withinService = true; withinService = true;
@@ -1542,13 +1664,17 @@ int doDump(Bundle* bundle)
if (error == "") { if (error == "") {
if (permission == "android.permission.BIND_INPUT_METHOD") { if (permission == "android.permission.BIND_INPUT_METHOD") {
hasBindInputMethodPermission = true; hasBindInputMethodPermission = true;
} else if (permission == "android.permission.BIND_ACCESSIBILITY_SERVICE") { } else if (permission ==
"android.permission.BIND_ACCESSIBILITY_SERVICE") {
hasBindAccessibilityServicePermission = true; hasBindAccessibilityServicePermission = true;
} else if (permission == "android.permission.BIND_PRINT_SERVICE") { } else if (permission ==
"android.permission.BIND_PRINT_SERVICE") {
hasBindPrintServicePermission = true; hasBindPrintServicePermission = true;
} else if (permission == "android.permission.BIND_NFC_SERVICE") { } else if (permission ==
"android.permission.BIND_NFC_SERVICE") {
hasBindNfcServicePermission = true; hasBindNfcServicePermission = true;
} else if (permission == "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE") { } else if (permission ==
"android.permission.BIND_NOTIFICATION_LISTENER_SERVICE") {
hasBindNotificationListenerServicePermission = true; hasBindNotificationListenerServicePermission = true;
} else if (permission == "android.permission.BIND_DREAM_SERVICE") { } else if (permission == "android.permission.BIND_DREAM_SERVICE") {
hasBindDreamServicePermission = true; hasBindDreamServicePermission = true;
@@ -1563,7 +1689,8 @@ int doDump(Bundle* bundle)
bool exported = AaptXml::getResolvedIntegerAttribute(res, tree, bool exported = AaptXml::getResolvedIntegerAttribute(res, tree,
EXPORTED_ATTR, &error); EXPORTED_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:exported' attribute for provider:" fprintf(stderr,
"ERROR getting 'android:exported' attribute for provider:"
" %s\n", error.string()); " %s\n", error.string());
goto bail; goto bail;
} }
@@ -1571,16 +1698,17 @@ int doDump(Bundle* bundle)
bool grantUriPermissions = AaptXml::getResolvedIntegerAttribute( bool grantUriPermissions = AaptXml::getResolvedIntegerAttribute(
res, tree, GRANT_URI_PERMISSIONS_ATTR, &error); res, tree, GRANT_URI_PERMISSIONS_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:grantUriPermissions' attribute for provider:" fprintf(stderr,
" %s\n", error.string()); "ERROR getting 'android:grantUriPermissions' attribute for "
"provider: %s\n", error.string());
goto bail; goto bail;
} }
String8 permission = AaptXml::getResolvedAttribute(res, tree, String8 permission = AaptXml::getResolvedAttribute(res, tree,
PERMISSION_ATTR, &error); PERMISSION_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:permission' attribute for provider:" fprintf(stderr, "ERROR getting 'android:permission' attribute for "
" %s\n", error.string()); "provider: %s\n", error.string());
goto bail; goto bail;
} }
@@ -1662,7 +1790,8 @@ int doDump(Bundle* bundle)
String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error); String8 name = AaptXml::getAttribute(tree, NAME_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute for " fprintf(stderr, "ERROR getting 'android:name' attribute for "
" meta-data tag in service '%s': %s\n", serviceName.string(), error.string()); "meta-data tag in service '%s': %s\n", serviceName.string(),
error.string());
goto bail; goto bail;
} }
@@ -1677,7 +1806,8 @@ int doDump(Bundle* bundle)
RESOURCE_ATTR, &error); RESOURCE_ATTR, &error);
if (error != "") { if (error != "") {
fprintf(stderr, "ERROR getting 'android:resource' attribute for " fprintf(stderr, "ERROR getting 'android:resource' attribute for "
" meta-data tag in service '%s': %s\n", serviceName.string(), error.string()); "meta-data tag in service '%s': %s\n",
serviceName.string(), error.string());
goto bail; goto bail;
} }
@@ -1731,15 +1861,19 @@ int doDump(Bundle* bundle)
actImeService = true; actImeService = true;
} else if (action == "android.service.wallpaper.WallpaperService") { } else if (action == "android.service.wallpaper.WallpaperService") {
actWallpaperService = true; actWallpaperService = true;
} else if (action == "android.accessibilityservice.AccessibilityService") { } else if (action ==
"android.accessibilityservice.AccessibilityService") {
actAccessibilityService = true; actAccessibilityService = true;
} else if (action =="android.printservice.PrintService") { } else if (action =="android.printservice.PrintService") {
actPrintService = true; actPrintService = true;
} else if (action == "android.nfc.cardemulation.action.HOST_APDU_SERVICE") { } else if (action ==
"android.nfc.cardemulation.action.HOST_APDU_SERVICE") {
actHostApduService = true; actHostApduService = true;
} else if (action == "android.nfc.cardemulation.action.OFF_HOST_APDU_SERVICE") { } else if (action ==
"android.nfc.cardemulation.action.OFF_HOST_APDU_SERVICE") {
actOffHostApduService = true; actOffHostApduService = true;
} else if (action == "android.service.notification.NotificationListenerService") { } else if (action ==
"android.service.notification.NotificationListenerService") {
actNotificationListenerService = true; actNotificationListenerService = true;
} else if (action == "android.service.dreams.DreamService") { } else if (action == "android.service.dreams.DreamService") {
actDreamService = true; actDreamService = true;
@@ -1814,12 +1948,12 @@ int doDump(Bundle* bundle)
} }
addImpliedFeature(&impliedFeatures, "android.hardware.touchscreen", addImpliedFeature(&impliedFeatures, "android.hardware.touchscreen",
"default feature for all apps"); "default feature for all apps", false);
const size_t numFeatureGroups = featureGroups.size(); const size_t numFeatureGroups = featureGroups.size();
if (numFeatureGroups == 0) { if (numFeatureGroups == 0) {
// If no <feature-group> tags were defined, apply auto-implied features. // If no <feature-group> tags were defined, apply auto-implied features.
printFeatureGroup(commonFeatures, &impliedFeatures); printDefaultFeatureGroup(commonFeatures, impliedFeatures);
} else { } else {
// <feature-group> tags are defined, so we ignore implied features and // <feature-group> tags are defined, so we ignore implied features and