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

Commit 38f130e1 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

PackageParser: ignore <uses-permission> android:required on older apps

Don't honor <uses-permission android:required="false"> on older apps.
Lots of apps in the wild are improperly using this, and we don't
want to break them.

Bug: 8528162
Change-Id: I6e0a10bc9feac58d13ef624239c6b91e9fc34590
parent 8712e4cc
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1398,6 +1398,17 @@ public class PackageParser {
            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
        }

        /*
         * b/8528162: Ignore the <uses-permission android:required> attribute if
         * targetSdkVersion < JELLY_BEAN_MR2. There are lots of apps in the wild
         * which are improperly using this attribute, even though it never worked.
         */
        if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2) {
            for (int i = 0; i < pkg.requestedPermissionsRequired.size(); i++) {
                pkg.requestedPermissionsRequired.set(i, Boolean.TRUE);
            }
        }

        return pkg;
    }