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

Commit ee888a9b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove RingtoneManager.*SyncFromParent APIs"

parents 0b93c3b8 9959d337
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -267,8 +267,6 @@ interface IAudioService {

    List<AudioPlaybackConfiguration> getActivePlaybackConfigurations();

    void disableRingtoneSync(in int userId);

    int getFocusRampTimeMs(in int focusGain, in AudioAttributes attr);

    int dispatchFocusChange(in AudioFocusInfo afi, in int focusChange,
+0 −31
Original line number Diff line number Diff line
@@ -748,32 +748,6 @@ public class RingtoneManager {
        return null;
    }

    /**
     * Disables Settings.System.SYNC_PARENT_SOUNDS.
     *
     * @hide
     */
    public static void disableSyncFromParent(Context userContext) {
        IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
        IAudioService audioService = IAudioService.Stub.asInterface(b);
        try {
            audioService.disableRingtoneSync(userContext.getUserId());
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to disable ringtone sync.");
        }
    }

    /**
     * Enables Settings.System.SYNC_PARENT_SOUNDS for the content's user
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
    public static void enableSyncFromParent(Context userContext) {
        Settings.Secure.putIntForUser(userContext.getContentResolver(),
                Settings.Secure.SYNC_PARENT_SOUNDS, 1 /* true */, userContext.getUserId());
    }

    /**
     * Gets the current default sound's {@link Uri}. This will give the actual
     * sound {@link Uri}, instead of using this, most clients can use
@@ -818,11 +792,6 @@ public class RingtoneManager {
        if (setting == null) return;

        final ContentResolver resolver = context.getContentResolver();
        if (Settings.Secure.getIntForUser(resolver, Settings.Secure.SYNC_PARENT_SOUNDS, 0,
                    context.getUserId()) == 1) {
            // Parent sound override is enabled. Disable it using the audio service.
            disableSyncFromParent(context);
        }
        if(!isInternalRingtoneUri(ringtoneUri)) {
            ringtoneUri = ContentProvider.maybeAddUserId(ringtoneUri, context.getUserId());
        }
+0 −16
Original line number Diff line number Diff line
@@ -10012,22 +10012,6 @@ public class AudioService extends IAudioService.Stub
        mRecordMonitor.releaseRecorder(riid);
    }

    public void disableRingtoneSync(final int userId) {
        final int callingUserId = UserHandle.getCallingUserId();
        if (callingUserId != userId) {
            mContext.enforceCallingOrSelfPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                    "disable sound settings syncing for another profile");
        }
        final long token = Binder.clearCallingIdentity();
        try {
            // Disable the sync setting so the profile uses its own sound settings.
            Settings.Secure.putIntForUser(mContentResolver, Settings.Secure.SYNC_PARENT_SOUNDS,
                    0 /* false */, userId);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    //======================
    // Audio playback notification
    //======================