summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2014-09-12 17:48:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-12 17:48:40 +0000
commita409cdba60a3237f6822acfa570e0f66bb67eb34 (patch)
treecf7b9255a454a9215b41f4966e882624827c156a
parentcffd540c1511cac42fa8ff98c2c3c20e7d5d51b5 (diff)
parent873cc45da2463a11182fe94a2565364d7e1709bb (diff)
downloadframeworks_base-a409cdba60a3237f6822acfa570e0f66bb67eb34.zip
frameworks_base-a409cdba60a3237f6822acfa570e0f66bb67eb34.tar.gz
frameworks_base-a409cdba60a3237f6822acfa570e0f66bb67eb34.tar.bz2
Merge "AudioService: modify stream delay for touch exploration" into lmp-dev
-rw-r--r--media/java/android/media/AudioService.java57
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