OSDN Git Service

Reduce jank on 'touch sounds' switch.
authorJulia Reynolds <juliacr@google.com>
Thu, 20 Aug 2015 14:08:07 +0000 (10:08 -0400)
committerJulia Reynolds <juliacr@google.com>
Thu, 20 Aug 2015 14:42:14 +0000 (10:42 -0400)
Bug: 23360053
Change-Id: Iec47e1464cfa0bd53f40977f7fa58c37dd635853

src/com/android/settings/notification/OtherSoundSettings.java

index 969ec90..dcafc65 100644 (file)
@@ -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);
         }
     };