am 60fcce6c: Merge "Introduce maxSdkVersion for <uses-permission>" into klp-dev
* commit '60fcce6cb1bbe720634ae5e3d94aeae5e4c1e53e': Introduce maxSdkVersion for <uses-permission>
This commit is contained in:
@@ -1441,18 +1441,29 @@ public class PackageParser {
|
||||
*/
|
||||
boolean required = true; // Optional <uses-permission> not supported
|
||||
|
||||
int maxSdkVersion = 0;
|
||||
TypedValue val = sa.peekValue(
|
||||
com.android.internal.R.styleable.AndroidManifestUsesPermission_maxSdkVersion);
|
||||
if (val != null) {
|
||||
if (val.type >= TypedValue.TYPE_FIRST_INT && val.type <= TypedValue.TYPE_LAST_INT) {
|
||||
maxSdkVersion = val.data;
|
||||
}
|
||||
}
|
||||
|
||||
sa.recycle();
|
||||
|
||||
if (name != null) {
|
||||
int index = pkg.requestedPermissions.indexOf(name);
|
||||
if (index == -1) {
|
||||
pkg.requestedPermissions.add(name.intern());
|
||||
pkg.requestedPermissionsRequired.add(required ? Boolean.TRUE : Boolean.FALSE);
|
||||
} else {
|
||||
if (pkg.requestedPermissionsRequired.get(index) != required) {
|
||||
outError[0] = "conflicting <uses-permission> entries";
|
||||
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
|
||||
return false;
|
||||
if ((maxSdkVersion == 0) || (maxSdkVersion >= Build.VERSION.RESOURCES_SDK_INT)) {
|
||||
if (name != null) {
|
||||
int index = pkg.requestedPermissions.indexOf(name);
|
||||
if (index == -1) {
|
||||
pkg.requestedPermissions.add(name.intern());
|
||||
pkg.requestedPermissionsRequired.add(required ? Boolean.TRUE : Boolean.FALSE);
|
||||
} else {
|
||||
if (pkg.requestedPermissionsRequired.get(index) != required) {
|
||||
outError[0] = "conflicting <uses-permission> entries";
|
||||
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,6 +1048,11 @@
|
||||
tag; often this is one of the {@link android.Manifest.permission standard
|
||||
system permissions}. -->
|
||||
<attr name="name" />
|
||||
<!-- Optional: specify the maximum version of the Android OS for which the
|
||||
application wishes to request the permission. When running on a version
|
||||
of Android higher than the number given here, the permission will not
|
||||
be requested. -->
|
||||
<attr name="maxSdkVersion" format="integer" />
|
||||
<!-- Specify whether this permission is required for the application.
|
||||
The default is true, meaning the application requires the
|
||||
permission, and it must always be granted when it is installed.
|
||||
@@ -1129,7 +1134,7 @@
|
||||
on. You can use this to ensure your application is filtered out
|
||||
of later versions of the platform when you know you have
|
||||
incompatibility with them. -->
|
||||
<attr name="maxSdkVersion" format="integer" />
|
||||
<attr name="maxSdkVersion" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- The <code>library</code> tag declares that this apk is providing itself
|
||||
|
||||
Reference in New Issue
Block a user