Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96a77167 authored by Svetoslav's avatar Svetoslav
Browse files

Apps can request permissions only on platforms that have runtime permissions.

Change-Id: Id0e53c37c9d472287f5bd6a610d446aef6b695b9
parent 1fd5d21e
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -1487,7 +1487,11 @@ public class PackageParser {
                    return null;
                    return null;
                }
                }
            } else if (tagName.equals("uses-permission")) {
            } else if (tagName.equals("uses-permission")) {
                if (!parseUsesPermission(pkg, res, parser, attrs, outError)) {
                if (!parseUsesPermission(pkg, res, parser, attrs)) {
                    return null;
                }
            } else if (tagName.equals("uses-permission-sdk-m")) {
                if (!parseUsesPermission(pkg, res, parser, attrs)) {
                    return null;
                    return null;
                }
                }
            } else if (tagName.equals("uses-configuration")) {
            } else if (tagName.equals("uses-configuration")) {
@@ -1887,8 +1891,7 @@ public class PackageParser {
    }
    }


    private boolean parseUsesPermission(Package pkg, Resources res, XmlResourceParser parser,
    private boolean parseUsesPermission(Package pkg, Resources res, XmlResourceParser parser,
                                        AttributeSet attrs, String[] outError)
            AttributeSet attrs) throws XmlPullParserException, IOException {
            throws XmlPullParserException, IOException {
        TypedArray sa = res.obtainAttributes(attrs,
        TypedArray sa = res.obtainAttributes(attrs,
                com.android.internal.R.styleable.AndroidManifestUsesPermission);
                com.android.internal.R.styleable.AndroidManifestUsesPermission);


@@ -1914,8 +1917,9 @@ public class PackageParser {
                if (index == -1) {
                if (index == -1) {
                    pkg.requestedPermissions.add(name.intern());
                    pkg.requestedPermissions.add(name.intern());
                } else {
                } else {
                    Slog.w(TAG, "Ignoring duplicate uses-permission: " + name + " in package: "
                    Slog.w(TAG, "Ignoring duplicate uses-permissions/uses-permissions-sdk-m: "
                            + pkg.packageName + " at: " + parser.getPositionDescription());
                            + name + " in package: " + pkg.packageName + " at: "
                            + parser.getPositionDescription());
                }
                }
            }
            }
        }
        }
+7 −10
Original line number Original line Diff line number Diff line
@@ -1269,8 +1269,13 @@
    
    
    <!-- The <code>uses-permission</code> tag requests a
    <!-- The <code>uses-permission</code> tag requests a
         {@link #AndroidManifestPermission &lt;permission&gt;} that the containing
         {@link #AndroidManifestPermission &lt;permission&gt;} that the containing
         package must be granted in order for it to operate correctly.
         package must be granted in order for it to operate correctly. For runtime
         See the <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
         permissions, i.e. ones with <code>dangerous</code> protection level, on a
         platform that supports runtime permissions, the permission will not be
         granted until the app explicitly requests it at runtime and the user approves
         the grant. You cannot request at runtime permissions that are not declared
         as used in the manifest. See the
         <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
         document for more information on permissions.  Also available is a
         document for more information on permissions.  Also available is a
         {@link android.Manifest.permission list of permissions} included
         {@link android.Manifest.permission list of permissions} included
         with the base platform.
         with the base platform.
@@ -1289,14 +1294,6 @@
             of Android higher than the number given here, the permission will not
             of Android higher than the number given here, the permission will not
             be requested.  -->
             be requested.  -->
        <attr name="maxSdkVersion" format="integer" />
        <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.
              If you set this to false, then in some cases the application may
              be installed with it being granted the permission, and it will
              need to request the permission later if it needs it.
        <attr name="required" format="boolean" />
        -->
    </declare-styleable>
    </declare-styleable>


    <!-- The <code>uses-configuration</code> tag specifies
    <!-- The <code>uses-configuration</code> tag specifies