+ } else if (depth == 2) {
+ withinApplication = false;
+ if (tag == "application") {
+ withinApplication = true;
+ String8 label = getResolvedAttribute(&res, tree, LABEL_ATTR, &error);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n", error.string());
+ goto bail;
+ }
+ printf("application: label='%s' ", label.string());
+ String8 icon = getResolvedAttribute(&res, tree, ICON_ATTR, &error);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string());
+ goto bail;
+ }
+ printf("icon='%s'\n", icon.string());
+ int32_t testOnly = getIntegerAttribute(tree, TEST_ONLY_ATTR, &error, 0);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:testOnly' attribute: %s\n", error.string());
+ goto bail;
+ }
+ if (testOnly != 0) {
+ printf("testOnly='%d'\n", testOnly);
+ }
+ } else if (tag == "uses-sdk") {
+ int32_t code = getIntegerAttribute(tree, MIN_SDK_VERSION_ATTR, &error);
+ if (error != "") {
+ error = "";
+ String8 name = getResolvedAttribute(&res, tree, MIN_SDK_VERSION_ATTR, &error);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:minSdkVersion' attribute: %s\n",
+ error.string());
+ goto bail;
+ }
+ if (name == "Donut") targetSdk = 4;
+ printf("sdkVersion:'%s'\n", name.string());
+ } else if (code != -1) {
+ targetSdk = code;
+ printf("sdkVersion:'%d'\n", code);
+ }
+ code = getIntegerAttribute(tree, MAX_SDK_VERSION_ATTR, NULL, -1);
+ if (code != -1) {
+ printf("maxSdkVersion:'%d'\n", code);
+ }
+ code = getIntegerAttribute(tree, TARGET_SDK_VERSION_ATTR, &error);
+ if (error != "") {
+ error = "";
+ String8 name = getResolvedAttribute(&res, tree, TARGET_SDK_VERSION_ATTR, &error);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:targetSdkVersion' attribute: %s\n",
+ error.string());
+ goto bail;
+ }
+ if (name == "Donut" && targetSdk < 4) targetSdk = 4;
+ printf("targetSdkVersion:'%s'\n", name.string());
+ } else if (code != -1) {
+ if (targetSdk < code) {
+ targetSdk = code;
+ }
+ printf("targetSdkVersion:'%d'\n", code);
+ }
+ } else if (tag == "uses-configuration") {
+ int32_t reqTouchScreen = getIntegerAttribute(tree,
+ REQ_TOUCH_SCREEN_ATTR, NULL, 0);
+ int32_t reqKeyboardType = getIntegerAttribute(tree,
+ REQ_KEYBOARD_TYPE_ATTR, NULL, 0);
+ int32_t reqHardKeyboard = getIntegerAttribute(tree,
+ REQ_HARD_KEYBOARD_ATTR, NULL, 0);
+ int32_t reqNavigation = getIntegerAttribute(tree,
+ REQ_NAVIGATION_ATTR, NULL, 0);
+ int32_t reqFiveWayNav = getIntegerAttribute(tree,
+ REQ_FIVE_WAY_NAV_ATTR, NULL, 0);
+ printf("uses-configuration:");
+ if (reqTouchScreen != 0) {
+ printf(" reqTouchScreen='%d'", reqTouchScreen);
+ }
+ if (reqKeyboardType != 0) {
+ printf(" reqKeyboardType='%d'", reqKeyboardType);
+ }
+ if (reqHardKeyboard != 0) {
+ printf(" reqHardKeyboard='%d'", reqHardKeyboard);
+ }
+ if (reqNavigation != 0) {
+ printf(" reqNavigation='%d'", reqNavigation);
+ }
+ if (reqFiveWayNav != 0) {
+ printf(" reqFiveWayNav='%d'", reqFiveWayNav);
+ }
+ printf("\n");
+ } else if (tag == "supports-density") {
+ int32_t dens = getIntegerAttribute(tree, DENSITY_ATTR, &error);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:density' attribute: %s\n",
+ error.string());
+ goto bail;
+ }
+ printf("supports-density:'%d'\n", dens);
+ } else if (tag == "supports-screens") {
+ smallScreen = getIntegerAttribute(tree,
+ SMALL_SCREEN_ATTR, NULL, 1);
+ normalScreen = getIntegerAttribute(tree,
+ NORMAL_SCREEN_ATTR, NULL, 1);
+ largeScreen = getIntegerAttribute(tree,
+ LARGE_SCREEN_ATTR, NULL, 1);
+ } else if (tag == "uses-feature") {
+ String8 name = getAttribute(tree, NAME_ATTR, &error);
+
+ if (name != "" && error == "") {
+ int req = getIntegerAttribute(tree,
+ REQUIRED_ATTR, NULL, 1);
+
+ if (name == "android.hardware.camera") {
+ specCameraFeature = true;
+ } else if (name == "android.hardware.camera.autofocus") {
+ // these have no corresponding permission to check for,
+ // but should imply the foundational camera permission
+ reqCameraAutofocusFeature = reqCameraAutofocusFeature || req;
+ specCameraAutofocusFeature = true;
+ } else if (req && (name == "android.hardware.camera.flash")) {
+ // these have no corresponding permission to check for,
+ // but should imply the foundational camera permission
+ reqCameraFlashFeature = true;
+ } else if (name == "android.hardware.location") {
+ specLocationFeature = true;
+ } else if (name == "android.hardware.location.network") {
+ specNetworkLocFeature = true;
+ reqNetworkLocFeature = reqNetworkLocFeature || req;
+ } else if (name == "android.hardware.location.gps") {
+ specGpsFeature = true;
+ reqGpsFeature = reqGpsFeature || req;
+ } else if (name == "android.hardware.bluetooth") {
+ specBluetoothFeature = true;
+ } else if (name == "android.hardware.touchscreen") {
+ specTouchscreenFeature = true;
+ } else if (name == "android.hardware.touchscreen.multitouch") {
+ specMultitouchFeature = true;
+ } else if (name == "android.hardware.touchscreen.multitouch.distinct") {
+ reqDistinctMultitouchFeature = reqDistinctMultitouchFeature || req;
+ } else if (name == "android.hardware.microphone") {
+ specMicrophoneFeature = true;
+ } else if (name == "android.hardware.wifi") {
+ specWiFiFeature = true;
+ } else if (name == "android.hardware.telephony") {
+ specTelephonyFeature = true;
+ } else if (req && (name == "android.hardware.telephony.gsm" ||
+ name == "android.hardware.telephony.cdma")) {
+ // these have no corresponding permission to check for,
+ // but should imply the foundational telephony permission
+ reqTelephonySubFeature = true;
+ }
+ printf("uses-feature%s:'%s'\n",
+ req ? "" : "-not-required", name.string());
+ } else {
+ int vers = getIntegerAttribute(tree,
+ GL_ES_VERSION_ATTR, &error);
+ if (error == "") {
+ printf("uses-gl-es:'0x%x'\n", vers);
+ }
+ }
+ } else if (tag == "uses-permission") {
+ String8 name = getAttribute(tree, NAME_ATTR, &error);
+ if (name != "" && error == "") {
+ if (name == "android.permission.CAMERA") {
+ hasCameraPermission = true;
+ } else if (name == "android.permission.ACCESS_FINE_LOCATION") {
+ hasGpsPermission = true;
+ } else if (name == "android.permission.ACCESS_MOCK_LOCATION") {
+ hasMockLocPermission = true;
+ } else if (name == "android.permission.ACCESS_COARSE_LOCATION") {
+ hasCoarseLocPermission = true;
+ } else if (name == "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" ||
+ name == "android.permission.INSTALL_LOCATION_PROVIDER") {
+ hasGeneralLocPermission = true;
+ } else if (name == "android.permission.BLUETOOTH" ||
+ name == "android.permission.BLUETOOTH_ADMIN") {
+ hasBluetoothPermission = true;
+ } else if (name == "android.permission.RECORD_AUDIO") {
+ hasRecordAudioPermission = true;
+ } else if (name == "android.permission.ACCESS_WIFI_STATE" ||
+ name == "android.permission.CHANGE_WIFI_STATE" ||
+ name == "android.permission.CHANGE_WIFI_MULTICAST_STATE") {
+ hasWiFiPermission = true;
+ } 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") {
+ hasTelephonyPermission = true;
+ }
+ printf("uses-permission:'%s'\n", name.string());
+ } else {
+ fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
+ error.string());
+ goto bail;
+ }
+ } else if (tag == "original-package") {
+ String8 name = getAttribute(tree, NAME_ATTR, &error);
+ if (name != "" && error == "") {
+ printf("original-package:'%s'\n", name.string());
+ } else {
+ fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
+ error.string());
+ goto bail;
+ }