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

Commit 3b7e688d authored by Songchun Fan's avatar Songchun Fan
Browse files

Revert "Revert "[SettingsProvider] enforce permission on openFile""

Prevent third-party apps to write to ring tone files without permission.

This reverts commit 3726d524.

Reason for revert: use appops manager's permission check method

BUG: 222687217
Test: atest android.appsecurity.cts.ExternalStorageHostTest#testExternalStorageReadDefaultUris
Change-Id: I5121bb7975e7a3893eefbf2ddbe6c9c6a82c6c74
parent c54e991b
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -818,6 +818,13 @@ public class SettingsProvider extends ContentProvider {
            getContext().enforceCallingPermission(Manifest.permission.INTERACT_ACROSS_USERS,
            getContext().enforceCallingPermission(Manifest.permission.INTERACT_ACROSS_USERS,
                    "Access files from the settings of another user");
                    "Access files from the settings of another user");
        }
        }
        final String callingPackage = getCallingPackage();
        if (mode.contains("w") && !Settings.checkAndNoteWriteSettingsOperation(getContext(),
                Binder.getCallingUid(), callingPackage, getCallingAttributionTag(),
                true /* throwException */)) {
            Slog.e(LOG_TAG, "Package: " + callingPackage + " is not allowed to modify "
                    + "system settings files.");
        }
        uri = ContentProvider.getUriWithoutUserId(uri);
        uri = ContentProvider.getUriWithoutUserId(uri);


        final String cacheRingtoneSetting;
        final String cacheRingtoneSetting;