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

Commit 7186dd3a authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Hand out storage to more system apps.

Grant storage access to the Storage Access Framework provider that
offers to delegate access to storage devices.  Also grant to the
default music app.

Bug: 22104872
Change-Id: I8cf7dceec8b4c1e31f8ddd40b094ccd4ecb1caf8
parent faf3f692
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ final class DefaultPermissionGrantPolicy {
    private static final boolean DEBUG = false;

    private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
    private static final String AUDIO_MIME_TYPE = "audio/mpeg";

    private static final Set<String> PHONE_PERMISSIONS = new ArraySet<>();
    static {
@@ -208,7 +209,7 @@ final class DefaultPermissionGrantPolicy {
    }

    private void grantDefaultSystemHandlerPermissions(int userId) {
        Log.i(TAG, "Granting permissions to default platform handlers for user:" + userId);
        Log.i(TAG, "Granting permissions to default platform handlers for user " + userId);

        final PackagesProvider imePackagesProvider;
        final PackagesProvider locationPackagesProvider;
@@ -322,6 +323,13 @@ final class DefaultPermissionGrantPolicy {
                grantRuntimePermissionsLPw(downloadsUiPackage, STORAGE_PERMISSIONS, userId);
            }

            // Storage provider
            PackageParser.Package storagePackage = getDefaultProviderAuthorityPackageLPr(
                    "com.android.externalstorage.documents", userId);
            if (storagePackage != null) {
                grantRuntimePermissionsLPw(storagePackage, STORAGE_PERMISSIONS, userId);
            }

            // SMS
            if (smsAppPackageNames != null) {
                for (String smsPackageName : smsAppPackageNames) {
@@ -478,6 +486,18 @@ final class DefaultPermissionGrantPolicy {
                }
            }

            // Music
            Intent musicIntent = new Intent(Intent.ACTION_VIEW);
            musicIntent.addCategory(Intent.CATEGORY_DEFAULT);
            musicIntent.setDataAndType(Uri.fromFile(new File("foo.mp3")),
                    AUDIO_MIME_TYPE);
            PackageParser.Package musicPackage = getDefaultSystemHandlerActivityPackageLPr(
                    musicIntent, userId);
            if (musicPackage != null
                    && doesPackageSupportRuntimePermissions(musicPackage)) {
                grantRuntimePermissionsLPw(musicPackage, STORAGE_PERMISSIONS, userId);
            }

            mService.mSettings.onDefaultRuntimePermissionsGrantedLPr(userId);
        }
    }