Added support for supports-input manifest element

Change-Id: Ifa7c87908081585c1940b5a47fdf5138a287d9ea
This commit is contained in:
Michael Wright
2013-09-05 18:15:57 -07:00
parent 56960fbd39
commit eaeb190486
3 changed files with 109 additions and 56 deletions

View File

@@ -1311,6 +1311,9 @@ public class PackageParser {
// Just skip this tag
XmlUtils.skipCurrentTag(parser);
continue;
} else if (tagName.equals("supports-input")) {
XmlUtils.skipCurrentTag(parser);
continue;
} else if (tagName.equals("eat-comment")) {
// Just skip this tag

View File

@@ -1718,20 +1718,20 @@
<!-- Attributes that can be supplied in an AndroidManifest.xml
<code>screen</code> tag, a child of <code>compatible-screens</code>,
which is itseld a child of the root
which is itself a child of the root
{@link #AndroidManifest manifest} tag. -->
<declare-styleable name="AndroidManifestCompatibleScreensScreen"
parent="AndroidManifest.AndroidManifestCompatibleScreens">
<!-- Specifies a compatible screen size, as per the device
configuration screen size bins. -->
<attr name="screenSize">
<!-- A small screen configuration, at least 240x320db. -->
<!-- A small screen configuration, at least 240x320dp. -->
<enum name="small" value="200" />
<!-- A normal screen configuration, at least 320x480db. -->
<!-- A normal screen configuration, at least 320x480dp. -->
<enum name="normal" value="300" />
<!-- A large screen configuration, at least 400x530db. -->
<!-- A large screen configuration, at least 400x530dp. -->
<enum name="large" value="400" />
<!-- An extra large screen configuration, at least 600x800db. -->
<!-- An extra large screen configuration, at least 600x800dp. -->
<enum name="xlarge" value="500" />
</attr>
<!-- Specifies a compatible screen density, as per the device
@@ -1748,6 +1748,19 @@
</attr>
</declare-styleable>
<!-- The <code>input-type</code> tag is a child of the <code>supports-input</code> tag, which
is itself a child of the root {@link #AndroidManifest manifest} tag. Each
<code>input-type</code> tag specifices the name of a specific input device type. When
grouped with the other elements of the parent <code>supports-input</code> tag it defines
a collection of input devices, which when all used together, are considered a supported
input mechanism for the application. There may be multiple <code>supports-input</code>
tags defined, each containing a different combination of input device types. -->
<declare-styleable name="AndroidManifestSupportsInputInputType"
parent="AndroidManifest.AndroidManifestSupportsInput">
<!-- Specifices the name of the input device type -->
<attr name="name" />
</declare-styleable>
<!-- The attribute that holds a Base64-encoded public key. -->
<attr name="publicKey" format="string" />

View File

@@ -621,6 +621,7 @@ int doDump(Bundle* bundle)
bool isLauncherActivity = false;
bool isSearchable = false;
bool withinApplication = false;
bool withinSupportsInput = false;
bool withinReceiver = false;
bool withinService = false;
bool withinIntentFilter = false;
@@ -711,11 +712,26 @@ int doDump(Bundle* bundle)
String8 activityIcon;
String8 receiverName;
String8 serviceName;
Vector<String8> supportedInput;
while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {
if (code == ResXMLTree::END_TAG) {
depth--;
if (depth < 2) {
if (withinSupportsInput && !supportedInput.isEmpty()) {
printf("supports-input: '");
const size_t N = supportedInput.size();
for (size_t i=0; i<N; i++) {
printf("%s", supportedInput[i].string());
if (i != N - 1) {
printf("' '");
} else {
printf("'\n");
}
}
supportedInput.clear();
}
withinApplication = false;
withinSupportsInput = false;
} else if (depth < 3) {
if (withinActivity && isMainActivity && isLauncherActivity) {
const char *aName = getComponentName(pkg, activityName);
@@ -910,6 +926,8 @@ int doDump(Bundle* bundle)
printf(" reqFiveWayNav='%d'", reqFiveWayNav);
}
printf("\n");
} else if (tag == "supports-input") {
withinSupportsInput = true;
} else if (tag == "supports-screens") {
smallScreen = getIntegerAttribute(tree,
SMALL_SCREEN_ATTR, NULL, 1);
@@ -1086,66 +1104,85 @@ int doDump(Bundle* bundle)
}
}
}
} else if (depth == 3 && withinApplication) {
} else if (depth == 3) {
withinActivity = false;
withinReceiver = false;
withinService = false;
hasIntentFilter = false;
if(tag == "activity") {
withinActivity = true;
activityName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string());
goto bail;
}
if (withinApplication) {
if(tag == "activity") {
withinActivity = true;
activityName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
error.string());
goto bail;
}
activityLabel = getResolvedAttribute(&res, tree, LABEL_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n", error.string());
goto bail;
}
activityLabel = getResolvedAttribute(&res, tree, LABEL_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n",
error.string());
goto bail;
}
activityIcon = getResolvedAttribute(&res, tree, ICON_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string());
goto bail;
}
activityIcon = getResolvedAttribute(&res, tree, ICON_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n",
error.string());
goto bail;
}
int32_t orien = getResolvedIntegerAttribute(&res, tree,
SCREEN_ORIENTATION_ATTR, &error);
if (error == "") {
if (orien == 0 || orien == 6 || orien == 8) {
// Requests landscape, sensorLandscape, or reverseLandscape.
reqScreenLandscapeFeature = true;
} else if (orien == 1 || orien == 7 || orien == 9) {
// Requests portrait, sensorPortrait, or reversePortrait.
reqScreenPortraitFeature = true;
int32_t orien = getResolvedIntegerAttribute(&res, tree,
SCREEN_ORIENTATION_ATTR, &error);
if (error == "") {
if (orien == 0 || orien == 6 || orien == 8) {
// Requests landscape, sensorLandscape, or reverseLandscape.
reqScreenLandscapeFeature = true;
} else if (orien == 1 || orien == 7 || orien == 9) {
// Requests portrait, sensorPortrait, or reversePortrait.
reqScreenPortraitFeature = true;
}
}
} else if (tag == "uses-library") {
String8 libraryName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr,
"ERROR getting 'android:name' attribute for uses-library"
" %s\n", error.string());
goto bail;
}
int req = getIntegerAttribute(tree,
REQUIRED_ATTR, NULL, 1);
printf("uses-library%s:'%s'\n",
req ? "" : "-not-required", libraryName.string());
} else if (tag == "receiver") {
withinReceiver = true;
receiverName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr,
"ERROR getting 'android:name' attribute for receiver:"
" %s\n", error.string());
goto bail;
}
} else if (tag == "service") {
withinService = true;
serviceName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute for"
" service: %s\n", error.string());
goto bail;
}
}
} else if (tag == "uses-library") {
String8 libraryName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute for uses-library: %s\n", error.string());
goto bail;
}
int req = getIntegerAttribute(tree,
REQUIRED_ATTR, NULL, 1);
printf("uses-library%s:'%s'\n",
req ? "" : "-not-required", libraryName.string());
} else if (tag == "receiver") {
withinReceiver = true;
receiverName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute for receiver: %s\n", error.string());
goto bail;
}
} else if (tag == "service") {
withinService = true;
serviceName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
fprintf(stderr, "ERROR getting 'android:name' attribute for service: %s\n", error.string());
} else if (withinSupportsInput && tag == "input-type") {
String8 name = getAttribute(tree, NAME_ATTR, &error);
if (name != "" && error == "") {
supportedInput.add(name);
} else {
fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
error.string());
goto bail;
}
}