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

Commit ac7b10c1 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

[DO NOT MERGE] Split access-media-storage from read-external-storage

And also pre-grant it to all apps that currently get any storage
permission pre-granted

Test: atest SplitPermissionTest
      m -j gts && gts-tradefed run commandAndExit gts-dev -m GtsPermissionTestCases --test=com.google.android.permission.gts.DefaultPermissionGrantPolicyTest#testDefaultGrantsWithRemoteExceptions
      Manual testing:
         All combinations of
           - App targetSdk = 28 and 29 (and 22 for extra credit)
           - App having the <uses-permission> tag for
             ACCESS_MEDIA_LOCATION or not
           - Upgrade from P->Q-QPR and from vanilla Q->Q-QPR
         Further upgrade of targetSdk from 28->29 while on Q-QPR
         ==> All permission behavior should make sense. Sometimes there
             are weird, but expected behaviors. Hence we need to
             collect the results and then look at the unexpected ones.
             See SplitPermissionTest for some tests I added for the
             location-background permission which was split from
             the fine/coarse-location permissions
Fixes: 141048840,140961754
Change-Id: Ib9f50d25c002036f13cf2d42fc4d1b214f20920c
parent e569faf5
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -834,9 +834,12 @@ public class AppOpsManager {
    public static final int OP_ACCESS_ACCESSIBILITY = 88;
    /** @hide Read the device identifiers (IMEI / MEID, IMSI, SIM / Build serial) */
    public static final int OP_READ_DEVICE_IDENTIFIERS = 89;
    /** @hide Read location metadata from media */
    public static final int OP_ACCESS_MEDIA_LOCATION = 90;

    /** @hide */
    @UnsupportedAppUsage
    public static final int _NUM_OP = 90;
    public static final int _NUM_OP = 91;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -1107,6 +1110,9 @@ public class AppOpsManager {
    @TestApi
    @SystemApi
    public static final String OPSTR_LEGACY_STORAGE = "android:legacy_storage";
    /** @hide Read location metadata from media */
    public static final String OPSTR_ACCESS_MEDIA_LOCATION = "android:access_media_location";

    /** @hide Interact with accessibility. */
    @SystemApi
    public static final String OPSTR_ACCESS_ACCESSIBILITY = "android:access_accessibility";
@@ -1134,6 +1140,7 @@ public class AppOpsManager {
            // Storage
            OP_READ_EXTERNAL_STORAGE,
            OP_WRITE_EXTERNAL_STORAGE,
            OP_ACCESS_MEDIA_LOCATION,
            // Location
            OP_COARSE_LOCATION,
            OP_FINE_LOCATION,
@@ -1273,6 +1280,7 @@ public class AppOpsManager {
            OP_LEGACY_STORAGE,                  // LEGACY_STORAGE
            OP_ACCESS_ACCESSIBILITY,            // ACCESS_ACCESSIBILITY
            OP_READ_DEVICE_IDENTIFIERS,         // READ_DEVICE_IDENTIFIERS
            OP_ACCESS_MEDIA_LOCATION,           // ACCESS_MEDIA_LOCATION
    };

    /**
@@ -1369,6 +1377,7 @@ public class AppOpsManager {
            OPSTR_LEGACY_STORAGE,
            OPSTR_ACCESS_ACCESSIBILITY,
            OPSTR_READ_DEVICE_IDENTIFIERS,
            OPSTR_ACCESS_MEDIA_LOCATION,
    };

    /**
@@ -1466,6 +1475,7 @@ public class AppOpsManager {
            "LEGACY_STORAGE",
            "ACCESS_ACCESSIBILITY",
            "READ_DEVICE_IDENTIFIERS",
            "ACCESS_MEDIA_LOCATION",
    };

    /**
@@ -1564,6 +1574,7 @@ public class AppOpsManager {
            null, // no permission for OP_LEGACY_STORAGE
            null, // no permission for OP_ACCESS_ACCESSIBILITY
            null, // no direct permission for OP_READ_DEVICE_IDENTIFIERS
            Manifest.permission.ACCESS_MEDIA_LOCATION,
    };

    /**
@@ -1662,6 +1673,7 @@ public class AppOpsManager {
            null, // LEGACY_STORAGE
            null, // ACCESS_ACCESSIBILITY
            null, // READ_DEVICE_IDENTIFIERS
            null, // ACCESS_MEDIA_LOCATION
    };

    /**
@@ -1759,6 +1771,7 @@ public class AppOpsManager {
            false, // LEGACY_STORAGE
            false, // ACCESS_ACCESSIBILITY
            false, // READ_DEVICE_IDENTIFIERS
            false, // ACCESS_MEDIA_LOCATION
    };

    /**
@@ -1855,6 +1868,7 @@ public class AppOpsManager {
            AppOpsManager.MODE_DEFAULT, // LEGACY_STORAGE
            AppOpsManager.MODE_ALLOWED, // ACCESS_ACCESSIBILITY
            AppOpsManager.MODE_ERRORED, // READ_DEVICE_IDENTIFIERS
            AppOpsManager.MODE_ALLOWED, // ALLOW_MEDIA_LOCATION
    };

    /**
@@ -1955,6 +1969,7 @@ public class AppOpsManager {
            false, // LEGACY_STORAGE
            false, // ACCESS_ACCESSIBILITY
            false, // READ_DEVICE_IDENTIFIERS
            false, // ACCESS_MEDIA_LOCATION
    };

    /**
+4 −0
Original line number Diff line number Diff line
@@ -205,6 +205,10 @@
                      targetSdk="29">
        <new-permission name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    </split-permission>
    <split-permission name="android.permission.READ_EXTERNAL_STORAGE"
                      targetSdk="29">
        <new-permission name="android.permission.ACCESS_MEDIA_LOCATION" />
    </split-permission>

    <!-- This is a list of all the libraries available for application
         code to link against. -->
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ public final class DefaultPermissionGrantPolicy {
    static {
        STORAGE_PERMISSIONS.add(Manifest.permission.READ_EXTERNAL_STORAGE);
        STORAGE_PERMISSIONS.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
        STORAGE_PERMISSIONS.add(Manifest.permission.ACCESS_MEDIA_LOCATION);
    }

    private static final int MSG_READ_DEFAULT_PERMISSION_EXCEPTIONS = 1;