diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2014-09-12 18:53:06 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-12 18:53:06 +0000 |
commit | 5bf4747484e3c29f500a6b00a96f5638b140148a (patch) | |
tree | 7c23d70342173259a712841b95f7896ed3e51883 | |
parent | acf174bca72aab594d7f5fa309ec9f42f41a77bf (diff) | |
parent | a409cdba60a3237f6822acfa570e0f66bb67eb34 (diff) | |
download | frameworks_base-5bf4747484e3c29f500a6b00a96f5638b140148a.zip frameworks_base-5bf4747484e3c29f500a6b00a96f5638b140148a.tar.gz frameworks_base-5bf4747484e3c29f500a6b00a96f5638b140148a.tar.bz2 |
am 6b3b63e2: Merge "AudioService: modify stream delay for touch exploration" into lmp-dev
* commit '6b3b63e24da7eb243e0d44ca592f1898c5588373':
AudioService: modify stream delay for touch exploration
-rw-r--r-- | media/java/android/media/AudioService.java | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 91a8468..6c9fb9a 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -76,6 +76,7 @@ import android.util.Slog; import android.view.KeyEvent; import android.view.Surface; import android.view.WindowManager; +import android.view.accessibility.AccessibilityManager; import com.android.internal.telephony.ITelephony; import com.android.internal.util.XmlUtils; @@ -451,11 +452,6 @@ public class AudioService extends IAudioService.Stub { private Looper mSoundPoolLooper = null; // volume applied to sound played with playSoundEffect() private static int sSoundEffectVolumeDb; - // getActiveStreamType() will return: - // - STREAM_NOTIFICATION on tablets during this period after a notification stopped - // - STREAM_MUSIC on phones during this period after music or talkback/voice search prompt - // stopped - private static final int DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS = 5000; // previous volume adjustment direction received by checkForRingerModeChange() private int mPrevVolDirection = AudioManager.ADJUST_SAME; // Keyguard manager proxy @@ -683,6 +679,8 @@ public class AudioService extends IAudioService.Stub { 0, null, SAFE_VOLUME_CONFIGURE_TIMEOUT_MS); + + StreamOverride.init(mContext); } private void createAudioSystemThread() { @@ -2972,7 +2970,7 @@ public class AudioService extends IAudioService.Stub { return AudioSystem.STREAM_VOICE_CALL; } } else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) { - if (isAfMusicActiveRecently(DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS)) { + if (isAfMusicActiveRecently(StreamOverride.sDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC stream active"); return AudioSystem.STREAM_MUSIC; @@ -3004,13 +3002,13 @@ public class AudioService extends IAudioService.Stub { return AudioSystem.STREAM_VOICE_CALL; } } else if (AudioSystem.isStreamActive(AudioSystem.STREAM_NOTIFICATION, - DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS) || + StreamOverride.sDelayMs) || AudioSystem.isStreamActive(AudioSystem.STREAM_RING, - DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS)) { + StreamOverride.sDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); return AudioSystem.STREAM_NOTIFICATION; } else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) { - if (isAfMusicActiveRecently(DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS)) { + if (isAfMusicActiveRecently(StreamOverride.sDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: forcing STREAM_MUSIC"); return AudioSystem.STREAM_MUSIC; } else { @@ -5111,6 +5109,47 @@ public class AudioService extends IAudioService.Stub { } //========================================================================================== + // Accessibility: taking touch exploration into account for selecting the default + // stream override timeout when adjusting volume + //========================================================================================== + private static class StreamOverride + implements AccessibilityManager.TouchExplorationStateChangeListener { + + // AudioService.getActiveStreamType() will return: + // - STREAM_NOTIFICATION on tablets during this period after a notification stopped + // - STREAM_MUSIC on phones during this period after music or talkback/voice search prompt + // stopped + private static final int DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS = 5000; + private static final int TOUCH_EXPLORE_STREAM_TYPE_OVERRIDE_DELAY_MS = 1000; + + static int sDelayMs; + + static void init(Context ctxt) { + AccessibilityManager accessibilityManager = + (AccessibilityManager) ctxt.getSystemService(Context.ACCESSIBILITY_SERVICE); + updateDefaultStreamOverrideDelay( + accessibilityManager.isTouchExplorationEnabled()); + accessibilityManager.addTouchExplorationStateChangeListener( + new StreamOverride()); + } + + @Override + public void onTouchExplorationStateChanged(boolean enabled) { + updateDefaultStreamOverrideDelay(enabled); + } + + private static void updateDefaultStreamOverrideDelay(boolean touchExploreEnabled) { + if (touchExploreEnabled) { + sDelayMs = TOUCH_EXPLORE_STREAM_TYPE_OVERRIDE_DELAY_MS; + } else { + sDelayMs = DEFAULT_STREAM_TYPE_OVERRIDE_DELAY_MS; + } + if (DEBUG_VOL) Log.d(TAG, "Touch exploration enabled=" + touchExploreEnabled + + " stream override delay is now " + sDelayMs + " ms"); + } + } + + //========================================================================================== // Camera shutter sound policy. // config_camera_sound_forced configuration option in config.xml defines if the camera shutter // sound is forced (sound even if the device is in silent mode) or not. This option is false by |