Loading media/java/android/media/AudioManager.java +38 −33 Original line number Diff line number Diff line Loading @@ -3123,52 +3123,57 @@ public class AudioManager { /** * @hide Home sound * Played by the framework when the home app becomes active if config_enableHomeSound is set to * true. This is currently only used on TV devices. * <p> * To be played by the framework when the home app becomes active if config_enableHomeSound is * set to true. This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml. * @see #playSoundEffect(int) */ public static final int FX_HOME = 11; /** * @hide Fast scroll sound 1 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 1 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_1 = 12; public static final int FX_FOCUS_NAVIGATION_REPEAT_1 = 12; /** * @hide Fast scroll sound 2 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 2 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_2 = 13; public static final int FX_FOCUS_NAVIGATION_REPEAT_2 = 13; /** * @hide Fast scroll sound 3 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 3 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_3 = 14; public static final int FX_FOCUS_NAVIGATION_REPEAT_3 = 14; /** * @hide Fast scroll sound 4 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 4 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_4 = 15; public static final int FX_FOCUS_NAVIGATION_REPEAT_4 = 15; /** * @hide Number of sound effects Loading @@ -3177,27 +3182,27 @@ public class AudioManager { public static final int NUM_SOUND_EFFECTS = 16; /** * @hide Number of fast scroll sound effects * @hide Number of FX_FOCUS_NAVIGATION_REPEAT_* sound effects */ public static final int NUM_FAST_SCROLL_SOUND_EFFECTS = 4; public static final int NUM_NAVIGATION_REPEAT_SOUND_EFFECTS = 4; /** * @hide * @param n a value in [0, {@link #NUM_FAST_SCROLL_SOUND_EFFECTS}[ * @return The id of a fast scroll sound effect or -1 if out of bounds * @param n a value in [0, {@link #NUM_NAVIGATION_REPEAT_SOUND_EFFECTS}[ * @return The id of a navigation repeat sound effect or -1 if out of bounds */ public static int getNthFastScrollSoundEffectId(int n) { public static int getNthNavigationRepeatSoundEffect(int n) { switch (n) { case 0: return FX_FAST_SCROLL_1; return FX_FOCUS_NAVIGATION_REPEAT_1; case 1: return FX_FAST_SCROLL_2; return FX_FOCUS_NAVIGATION_REPEAT_2; case 2: return FX_FAST_SCROLL_3; return FX_FOCUS_NAVIGATION_REPEAT_3; case 3: return FX_FAST_SCROLL_4; return FX_FOCUS_NAVIGATION_REPEAT_4; default: Log.w(TAG, "Invalid fast-scroll sound effect id: " + n); Log.w(TAG, "Invalid navigation repeat sound effect id: " + n); return -1; } } Loading @@ -3205,9 +3210,9 @@ public class AudioManager { /** * @hide */ public void setFastScrollSoundEffectsEnabled(boolean enabled) { public void setNavigationRepeatSoundEffectsEnabled(boolean enabled) { try { getService().setFastScrollSoundEffectsEnabled(enabled); getService().setNavigationRepeatSoundEffectsEnabled(enabled); } catch (RemoteException e) { } Loading @@ -3215,11 +3220,11 @@ public class AudioManager { /** * @hide * @return true if the fast scroll sound effects are enabled * @return true if the navigation repeat sound effects are enabled */ public boolean areFastScrollSoundEffectsEnabled() { public boolean areNavigationRepeatSoundEffectsEnabled() { try { return getService().areFastScrollSoundEffectsEnabled(); return getService().areNavigationRepeatSoundEffectsEnabled(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading media/java/android/media/IAudioService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -351,9 +351,9 @@ interface IAudioService { oneway void unregisterCommunicationDeviceDispatcher( ICommunicationDeviceDispatcher dispatcher); boolean areFastScrollSoundEffectsEnabled(); boolean areNavigationRepeatSoundEffectsEnabled(); oneway void setFastScrollSoundEffectsEnabled(boolean enabled); oneway void setNavigationRepeatSoundEffectsEnabled(boolean enabled); boolean isHomeSoundEffectEnabled(); Loading services/core/java/com/android/server/audio/AudioService.java +5 −5 Original line number Diff line number Diff line Loading @@ -726,7 +726,7 @@ public class AudioService extends IAudioService.Stub // caches the value returned by AudioSystem.isMicrophoneMuted() private boolean mMicMuteFromSystemCached; private boolean mFastScrollSoundEffectsEnabled; private boolean mNavigationRepeatSoundEffectsEnabled; private boolean mHomeSoundEffectEnabled; @GuardedBy("mSettingsLock") Loading Loading @@ -2325,15 +2325,15 @@ public class AudioService extends IAudioService.Stub VOL_ADJUST_NORMAL); } public void setFastScrollSoundEffectsEnabled(boolean enabled) { mFastScrollSoundEffectsEnabled = enabled; public void setNavigationRepeatSoundEffectsEnabled(boolean enabled) { mNavigationRepeatSoundEffectsEnabled = enabled; } /** * @return true if the fast scroll sound effects are enabled */ public boolean areFastScrollSoundEffectsEnabled() { return mFastScrollSoundEffectsEnabled; public boolean areNavigationRepeatSoundEffectsEnabled() { return mNavigationRepeatSoundEffectsEnabled; } public void setHomeSoundEffectEnabled(boolean enabled) { Loading services/core/java/com/android/server/audio/SoundEffectsHelper.java +17 −13 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import java.util.Map; * used by AudioService. As its methods are called on the message handler thread * of AudioService, the actual work is offloaded to a dedicated thread. * This helps keeping AudioService responsive. * * @hide */ class SoundEffectsHelper { Loading Loading @@ -89,15 +90,18 @@ class SoundEffectsHelper { final String mFileName; int mSampleId; boolean mLoaded; // for effects in SoundPool Resource(String fileName) { mFileName = fileName; mSampleId = EFFECT_NOT_IN_SOUND_POOL; } void unload() { mSampleId = EFFECT_NOT_IN_SOUND_POOL; mLoaded = false; } } // All the fields below are accessed by the worker thread exclusively private final List<Resource> mResources = new ArrayList<Resource>(); private final int[] mEffects = new int[AudioManager.NUM_SOUND_EFFECTS]; // indexes in mResources Loading Loading @@ -385,12 +389,12 @@ class SoundEffectsHelper { } } boolean fastScrollSoundEffectsParsed = allFastScrollSoundsParsed(parserCounter); boolean navigationRepeatFxParsed = allNavigationRepeatSoundsParsed(parserCounter); boolean homeSoundParsed = parserCounter.getOrDefault(AudioManager.FX_HOME, 0) > 0; if (fastScrollSoundEffectsParsed || homeSoundParsed) { if (navigationRepeatFxParsed || homeSoundParsed) { AudioManager audioManager = mContext.getSystemService(AudioManager.class); if (audioManager != null && fastScrollSoundEffectsParsed) { audioManager.setFastScrollSoundEffectsEnabled(true); if (audioManager != null && navigationRepeatFxParsed) { audioManager.setNavigationRepeatSoundEffectsEnabled(true); } if (audioManager != null && homeSoundParsed) { audioManager.setHomeSoundEffectEnabled(true); Loading @@ -410,13 +414,13 @@ class SoundEffectsHelper { } } private boolean allFastScrollSoundsParsed(Map<Integer, Integer> parserCounter) { private boolean allNavigationRepeatSoundsParsed(Map<Integer, Integer> parserCounter) { int numFastScrollSoundEffectsParsed = parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_1, 0) + parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_2, 0) + parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_3, 0) + parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_4, 0); return numFastScrollSoundEffectsParsed == AudioManager.NUM_FAST_SCROLL_SOUND_EFFECTS; parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_1, 0) + parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_2, 0) + parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_3, 0) + parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_4, 0); return numFastScrollSoundEffectsParsed == AudioManager.NUM_NAVIGATION_REPEAT_SOUND_EFFECTS; } private int findOrAddResourceByFileName(String fileName) { Loading Loading
media/java/android/media/AudioManager.java +38 −33 Original line number Diff line number Diff line Loading @@ -3123,52 +3123,57 @@ public class AudioManager { /** * @hide Home sound * Played by the framework when the home app becomes active if config_enableHomeSound is set to * true. This is currently only used on TV devices. * <p> * To be played by the framework when the home app becomes active if config_enableHomeSound is * set to true. This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml. * @see #playSoundEffect(int) */ public static final int FX_HOME = 11; /** * @hide Fast scroll sound 1 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 1 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_1 = 12; public static final int FX_FOCUS_NAVIGATION_REPEAT_1 = 12; /** * @hide Fast scroll sound 2 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 2 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_2 = 13; public static final int FX_FOCUS_NAVIGATION_REPEAT_2 = 13; /** * @hide Fast scroll sound 3 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 3 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_3 = 14; public static final int FX_FOCUS_NAVIGATION_REPEAT_3 = 14; /** * @hide Fast scroll sound 4 * To be by the framework when a fast-scrolling is performed and * {@link #areFastScrollSoundEffectsEnabled()} is true. * @hide Navigation repeat sound 4 * <p> * To be played by the framework when a focus navigation is repeatedly triggered * (e.g. due to long-pressing) and {@link #areNavigationRepeatSoundEffectsEnabled()} is true. * This is currently only used on TV devices. * Note that this sound is only available if a sound file is specified in audio_assets.xml * @see #playSoundEffect(int) */ public static final int FX_FAST_SCROLL_4 = 15; public static final int FX_FOCUS_NAVIGATION_REPEAT_4 = 15; /** * @hide Number of sound effects Loading @@ -3177,27 +3182,27 @@ public class AudioManager { public static final int NUM_SOUND_EFFECTS = 16; /** * @hide Number of fast scroll sound effects * @hide Number of FX_FOCUS_NAVIGATION_REPEAT_* sound effects */ public static final int NUM_FAST_SCROLL_SOUND_EFFECTS = 4; public static final int NUM_NAVIGATION_REPEAT_SOUND_EFFECTS = 4; /** * @hide * @param n a value in [0, {@link #NUM_FAST_SCROLL_SOUND_EFFECTS}[ * @return The id of a fast scroll sound effect or -1 if out of bounds * @param n a value in [0, {@link #NUM_NAVIGATION_REPEAT_SOUND_EFFECTS}[ * @return The id of a navigation repeat sound effect or -1 if out of bounds */ public static int getNthFastScrollSoundEffectId(int n) { public static int getNthNavigationRepeatSoundEffect(int n) { switch (n) { case 0: return FX_FAST_SCROLL_1; return FX_FOCUS_NAVIGATION_REPEAT_1; case 1: return FX_FAST_SCROLL_2; return FX_FOCUS_NAVIGATION_REPEAT_2; case 2: return FX_FAST_SCROLL_3; return FX_FOCUS_NAVIGATION_REPEAT_3; case 3: return FX_FAST_SCROLL_4; return FX_FOCUS_NAVIGATION_REPEAT_4; default: Log.w(TAG, "Invalid fast-scroll sound effect id: " + n); Log.w(TAG, "Invalid navigation repeat sound effect id: " + n); return -1; } } Loading @@ -3205,9 +3210,9 @@ public class AudioManager { /** * @hide */ public void setFastScrollSoundEffectsEnabled(boolean enabled) { public void setNavigationRepeatSoundEffectsEnabled(boolean enabled) { try { getService().setFastScrollSoundEffectsEnabled(enabled); getService().setNavigationRepeatSoundEffectsEnabled(enabled); } catch (RemoteException e) { } Loading @@ -3215,11 +3220,11 @@ public class AudioManager { /** * @hide * @return true if the fast scroll sound effects are enabled * @return true if the navigation repeat sound effects are enabled */ public boolean areFastScrollSoundEffectsEnabled() { public boolean areNavigationRepeatSoundEffectsEnabled() { try { return getService().areFastScrollSoundEffectsEnabled(); return getService().areNavigationRepeatSoundEffectsEnabled(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
media/java/android/media/IAudioService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -351,9 +351,9 @@ interface IAudioService { oneway void unregisterCommunicationDeviceDispatcher( ICommunicationDeviceDispatcher dispatcher); boolean areFastScrollSoundEffectsEnabled(); boolean areNavigationRepeatSoundEffectsEnabled(); oneway void setFastScrollSoundEffectsEnabled(boolean enabled); oneway void setNavigationRepeatSoundEffectsEnabled(boolean enabled); boolean isHomeSoundEffectEnabled(); Loading
services/core/java/com/android/server/audio/AudioService.java +5 −5 Original line number Diff line number Diff line Loading @@ -726,7 +726,7 @@ public class AudioService extends IAudioService.Stub // caches the value returned by AudioSystem.isMicrophoneMuted() private boolean mMicMuteFromSystemCached; private boolean mFastScrollSoundEffectsEnabled; private boolean mNavigationRepeatSoundEffectsEnabled; private boolean mHomeSoundEffectEnabled; @GuardedBy("mSettingsLock") Loading Loading @@ -2325,15 +2325,15 @@ public class AudioService extends IAudioService.Stub VOL_ADJUST_NORMAL); } public void setFastScrollSoundEffectsEnabled(boolean enabled) { mFastScrollSoundEffectsEnabled = enabled; public void setNavigationRepeatSoundEffectsEnabled(boolean enabled) { mNavigationRepeatSoundEffectsEnabled = enabled; } /** * @return true if the fast scroll sound effects are enabled */ public boolean areFastScrollSoundEffectsEnabled() { return mFastScrollSoundEffectsEnabled; public boolean areNavigationRepeatSoundEffectsEnabled() { return mNavigationRepeatSoundEffectsEnabled; } public void setHomeSoundEffectEnabled(boolean enabled) { Loading
services/core/java/com/android/server/audio/SoundEffectsHelper.java +17 −13 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import java.util.Map; * used by AudioService. As its methods are called on the message handler thread * of AudioService, the actual work is offloaded to a dedicated thread. * This helps keeping AudioService responsive. * * @hide */ class SoundEffectsHelper { Loading Loading @@ -89,15 +90,18 @@ class SoundEffectsHelper { final String mFileName; int mSampleId; boolean mLoaded; // for effects in SoundPool Resource(String fileName) { mFileName = fileName; mSampleId = EFFECT_NOT_IN_SOUND_POOL; } void unload() { mSampleId = EFFECT_NOT_IN_SOUND_POOL; mLoaded = false; } } // All the fields below are accessed by the worker thread exclusively private final List<Resource> mResources = new ArrayList<Resource>(); private final int[] mEffects = new int[AudioManager.NUM_SOUND_EFFECTS]; // indexes in mResources Loading Loading @@ -385,12 +389,12 @@ class SoundEffectsHelper { } } boolean fastScrollSoundEffectsParsed = allFastScrollSoundsParsed(parserCounter); boolean navigationRepeatFxParsed = allNavigationRepeatSoundsParsed(parserCounter); boolean homeSoundParsed = parserCounter.getOrDefault(AudioManager.FX_HOME, 0) > 0; if (fastScrollSoundEffectsParsed || homeSoundParsed) { if (navigationRepeatFxParsed || homeSoundParsed) { AudioManager audioManager = mContext.getSystemService(AudioManager.class); if (audioManager != null && fastScrollSoundEffectsParsed) { audioManager.setFastScrollSoundEffectsEnabled(true); if (audioManager != null && navigationRepeatFxParsed) { audioManager.setNavigationRepeatSoundEffectsEnabled(true); } if (audioManager != null && homeSoundParsed) { audioManager.setHomeSoundEffectEnabled(true); Loading @@ -410,13 +414,13 @@ class SoundEffectsHelper { } } private boolean allFastScrollSoundsParsed(Map<Integer, Integer> parserCounter) { private boolean allNavigationRepeatSoundsParsed(Map<Integer, Integer> parserCounter) { int numFastScrollSoundEffectsParsed = parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_1, 0) + parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_2, 0) + parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_3, 0) + parserCounter.getOrDefault(AudioManager.FX_FAST_SCROLL_4, 0); return numFastScrollSoundEffectsParsed == AudioManager.NUM_FAST_SCROLL_SOUND_EFFECTS; parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_1, 0) + parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_2, 0) + parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_3, 0) + parserCounter.getOrDefault(AudioManager.FX_FOCUS_NAVIGATION_REPEAT_4, 0); return numFastScrollSoundEffectsParsed == AudioManager.NUM_NAVIGATION_REPEAT_SOUND_EFFECTS; } private int findOrAddResourceByFileName(String fileName) { Loading