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

Commit 828c16f1 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

Reenable optional permissions parsing and expose APIs

Modify the package parsing code to understand optional permissions
(android:required="false"). This is essentially a rollback of
e8241200 with some minor changes.

Expose the requestPermission API to third party apps. This allows
an app to request an Intent which, when passed to
startActivityForResult, will prompt the user to approve permissions
for an app.

In the event we decide to not launch with this feature, this change
can be rolled back.

Change-Id: Ie3626deae9b16e510323f94a2c80377f7c84b26f
parent 035f80d7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6716,6 +6716,7 @@ package android.content.pm {
    method public abstract java.util.List<android.content.pm.PermissionInfo> queryPermissionsByGroup(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract deprecated void removePackageFromPreferred(java.lang.String);
    method public abstract void removePermission(java.lang.String);
    method public android.content.Intent buildPermissionRequestIntent(java.lang.String...);
    method public abstract android.content.pm.ResolveInfo resolveActivity(android.content.Intent, int);
    method public abstract android.content.pm.ProviderInfo resolveContentProvider(java.lang.String, int);
    method public abstract android.content.pm.ResolveInfo resolveService(android.content.Intent, int);
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ public class PackageInfo implements Parcelable {
    /**
     * Flag for {@link #requestedPermissionsFlags}: the requested permission
     * is required for the application to run; the user can not optionally
     * disable it.  Currently all permissions are required.
     * disable it.
     */
    public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;

+0 −1
Original line number Diff line number Diff line
@@ -1754,7 +1754,6 @@ public abstract class PackageManager {
    /**
     * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
     * which prompts the user to grant {@code permissions} to this application.
     * @hide
     *
     * @throws NullPointerException if {@code permissions} is {@code null}.
     * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
+1 −3
Original line number Diff line number Diff line
@@ -1023,16 +1023,14 @@ public class PackageParser {
                // that may change.
                String name = sa.getNonResourceString(
                        com.android.internal.R.styleable.AndroidManifestUsesPermission_name);
                /* Not supporting optional permissions yet.
                boolean required = sa.getBoolean(
                        com.android.internal.R.styleable.AndroidManifestUsesPermission_required, true);
                */

                sa.recycle();

                if (name != null && !pkg.requestedPermissions.contains(name)) {
                    pkg.requestedPermissions.add(name.intern());
                    pkg.requestedPermissionsRequired.add(Boolean.TRUE);
                    pkg.requestedPermissionsRequired.add(required ? Boolean.TRUE : Boolean.FALSE);
                }

                XmlUtils.skipCurrentTag(parser);
+2 −3
Original line number Diff line number Diff line
@@ -991,9 +991,8 @@
              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.
              need to request the permission later if it needs it. -->
        <attr name="required" format="boolean" />
        -->
    </declare-styleable>

    <!-- The <code>uses-configuration</code> tag specifies
@@ -1036,7 +1035,7 @@
              don't support it.  If you set this to false, then this will
              not impose a restriction on where the application can be
              installed. -->
        <attr name="required" format="boolean" />
        <attr name="required" />
    </declare-styleable>

    <!-- The <code>uses-sdk</code> tag describes the SDK features that the