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

Commit fc2740ae authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Hand out storage to more system apps." into mnc-dev

parents 80abf887 7186dd3a
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);
        }
    }