Loading media/java/android/media/IAudioService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -192,5 +192,7 @@ interface IAudioService { oneway void releasePlayer(in int piid); void disableRingtoneSync(); // WARNING: read warning at top of file, it is recommended to add new methods at the end } media/java/android/media/RingtoneManager.java +15 −0 Original line number Diff line number Diff line Loading @@ -33,8 +33,11 @@ import android.database.Cursor; import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.net.Uri; import android.os.Environment; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.provider.MediaStore; Loading Loading @@ -850,6 +853,18 @@ public class RingtoneManager { public static void setActualDefaultRingtoneUri(Context context, int type, Uri ringtoneUri) { final ContentResolver resolver = context.getContentResolver(); if (Settings.Secure.getString(resolver, Settings.Secure.SYNC_PARENT_SOUNDS).equals("1")) { // Sync is enabled, so we need to disable it IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE); IAudioService audioService = IAudioService.Stub.asInterface(b); try { audioService.disableRingtoneSync(); } catch (RemoteException e) { Log.e(TAG, "Unable to disable ringtone sync."); return; } } String setting = getSettingForType(type); if (setting == null) return; if(!isInternalRingtoneUri(ringtoneUri)) { Loading services/core/java/com/android/server/audio/AudioService.java +29 −0 Original line number Diff line number Diff line Loading @@ -6502,6 +6502,35 @@ public class AudioService extends IAudioService.Stub return mRecordMonitor.getActiveRecordingConfigurations(); } public void disableRingtoneSync() { final int callingUserId = UserHandle.getCallingUserId(); final long token = Binder.clearCallingIdentity(); try { UserManager userManager = UserManager.get(mContext); // Disable the sync setting Settings.Secure.putIntForUser(mContentResolver, Settings.Secure.SYNC_PARENT_SOUNDS, 0 /* false */, callingUserId); UserInfo parentInfo = userManager.getProfileParent(callingUserId); if (parentInfo != null && parentInfo.id != callingUserId) { // This is a managed profile, so we clone the ringtones from the parent profile cloneRingtoneSetting(callingUserId, parentInfo.id, Settings.System.RINGTONE); cloneRingtoneSetting(callingUserId, parentInfo.id, Settings.System.NOTIFICATION_SOUND); cloneRingtoneSetting(callingUserId, parentInfo.id, Settings.System.ALARM_ALERT); } } finally { Binder.restoreCallingIdentity(token); } } private void cloneRingtoneSetting(int userId, int parentId, String ringtoneSetting) { String parentSetting = Settings.System.getStringForUser(mContentResolver, ringtoneSetting, parentId); Settings.System.putStringForUser(mContentResolver, ringtoneSetting, parentSetting, userId); } //====================== // Audio playback notification //====================== Loading Loading
media/java/android/media/IAudioService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -192,5 +192,7 @@ interface IAudioService { oneway void releasePlayer(in int piid); void disableRingtoneSync(); // WARNING: read warning at top of file, it is recommended to add new methods at the end }
media/java/android/media/RingtoneManager.java +15 −0 Original line number Diff line number Diff line Loading @@ -33,8 +33,11 @@ import android.database.Cursor; import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.net.Uri; import android.os.Environment; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.provider.MediaStore; Loading Loading @@ -850,6 +853,18 @@ public class RingtoneManager { public static void setActualDefaultRingtoneUri(Context context, int type, Uri ringtoneUri) { final ContentResolver resolver = context.getContentResolver(); if (Settings.Secure.getString(resolver, Settings.Secure.SYNC_PARENT_SOUNDS).equals("1")) { // Sync is enabled, so we need to disable it IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE); IAudioService audioService = IAudioService.Stub.asInterface(b); try { audioService.disableRingtoneSync(); } catch (RemoteException e) { Log.e(TAG, "Unable to disable ringtone sync."); return; } } String setting = getSettingForType(type); if (setting == null) return; if(!isInternalRingtoneUri(ringtoneUri)) { Loading
services/core/java/com/android/server/audio/AudioService.java +29 −0 Original line number Diff line number Diff line Loading @@ -6502,6 +6502,35 @@ public class AudioService extends IAudioService.Stub return mRecordMonitor.getActiveRecordingConfigurations(); } public void disableRingtoneSync() { final int callingUserId = UserHandle.getCallingUserId(); final long token = Binder.clearCallingIdentity(); try { UserManager userManager = UserManager.get(mContext); // Disable the sync setting Settings.Secure.putIntForUser(mContentResolver, Settings.Secure.SYNC_PARENT_SOUNDS, 0 /* false */, callingUserId); UserInfo parentInfo = userManager.getProfileParent(callingUserId); if (parentInfo != null && parentInfo.id != callingUserId) { // This is a managed profile, so we clone the ringtones from the parent profile cloneRingtoneSetting(callingUserId, parentInfo.id, Settings.System.RINGTONE); cloneRingtoneSetting(callingUserId, parentInfo.id, Settings.System.NOTIFICATION_SOUND); cloneRingtoneSetting(callingUserId, parentInfo.id, Settings.System.ALARM_ALERT); } } finally { Binder.restoreCallingIdentity(token); } } private void cloneRingtoneSetting(int userId, int parentId, String ringtoneSetting) { String parentSetting = Settings.System.getStringForUser(mContentResolver, ringtoneSetting, parentId); Settings.System.putStringForUser(mContentResolver, ringtoneSetting, parentSetting, userId); } //====================== // Audio playback notification //====================== Loading