From 975645c0ca86b6d27ce6cb3be35bad95a691f4e5 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 20 Aug 2015 10:08:07 -0400 Subject: [PATCH] Reduce jank on 'touch sounds' switch. Bug: 23360053 Change-Id: Iec47e1464cfa0bd53f40977f7fa58c37dd635853 --- .../notification/OtherSoundSettings.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/notification/OtherSoundSettings.java b/src/com/android/settings/notification/OtherSoundSettings.java index 969ec90b3b4..dcafc65ccd8 100644 --- a/src/com/android/settings/notification/OtherSoundSettings.java +++ b/src/com/android/settings/notification/OtherSoundSettings.java @@ -25,6 +25,7 @@ import android.content.res.Resources; import android.database.ContentObserver; import android.media.AudioManager; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Vibrator; @@ -92,13 +93,19 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In private static final SettingPref PREF_TOUCH_SOUNDS = new SettingPref( TYPE_SYSTEM, KEY_TOUCH_SOUNDS, System.SOUND_EFFECTS_ENABLED, DEFAULT_ON) { @Override - protected boolean setSetting(Context context, int value) { - final AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - if (value != 0) { - am.loadSoundEffects(); - } else { - am.unloadSoundEffects(); - } + protected boolean setSetting(final Context context, final int value) { + AsyncTask.execute(new Runnable() { + @Override + public void run() { + final AudioManager am = + (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + if (value != 0) { + am.loadSoundEffects(); + } else { + am.unloadSoundEffects(); + } + } + }); return super.setSetting(context, value); } };