diff options
| author | 2021-02-18 13:55:54 +0100 | |
|---|---|---|
| committer | 2021-02-19 10:50:07 +0100 | |
| commit | 6d9a0969a13e0fd40f8cf8845df66ae901850e19 (patch) | |
| tree | 1bf71b63fdcac9014e1d0ff756f8e9f16d5985d5 | |
| parent | 7f1eadbe6a460671509f850600b863608b188edf (diff) | |
Rename fast-scroll sound effects to navigation repeat
To match the nomenclature in view/SoundEffectConstants.java
Test: manual
Bug: 157407957
Change-Id: I54cb83a0d0cf1a02d1288af546385634fc6d4aec
4 files changed, 62 insertions, 53 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index d896c1fc82b5..f87f90d8e0a2 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -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 @@ -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; } } @@ -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) { } @@ -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(); } diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index 71ee57e3d471..0073b5cc93b9 100755 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -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(); diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 6f625a745ef6..f4cef044a0f8 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -724,7 +724,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") @@ -2323,15 +2323,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) { diff --git a/services/core/java/com/android/server/audio/SoundEffectsHelper.java b/services/core/java/com/android/server/audio/SoundEffectsHelper.java index c14bb3ee5df1..7031e02af05a 100644 --- a/services/core/java/com/android/server/audio/SoundEffectsHelper.java +++ b/services/core/java/com/android/server/audio/SoundEffectsHelper.java @@ -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 { @@ -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 @@ -116,9 +120,9 @@ class SoundEffectsHelper { } /** - * Unloads samples from the sound pool. - * This method can be called to free some memory when - * sound effects are disabled. + * Unloads samples from the sound pool. + * This method can be called to free some memory when + * sound effects are disabled. */ /*package*/ void unloadSoundEffects() { sendMsg(MSG_UNLOAD_EFFECTS, 0, 0, null, 0); @@ -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); @@ -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) { |