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

Commit d51101c9 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix cancelSync() permission check for periodic syncs.

Bug: 64810615
Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsContentTestCases -t android.content.cts.ContentResolverSyncTestCase
Change-Id: I2aedbe3e67dbaccfd848a2725042c33a440ce705
parent 454c831d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -644,6 +644,11 @@ public final class ContentService extends IContentService.Stub {
        int userId = UserHandle.getCallingUserId();
        final int callingUid = Binder.getCallingUid();

        if (request.isPeriodic()) {
            mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
                    "no permission to write the sync settings");
        }

        long identityToken = clearCallingIdentity();
        try {
            SyncStorageEngine.EndPoint info;
@@ -653,8 +658,6 @@ public final class ContentService extends IContentService.Stub {
            info = new SyncStorageEngine.EndPoint(account, provider, userId);
            if (request.isPeriodic()) {
                // Remove periodic sync.
                mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
                        "no permission to write the sync settings");
                getSyncManager().removePeriodicSync(info, extras,
                        "cancelRequest() by uid=" + callingUid);
            }