diff options
4 files changed, 85 insertions, 6 deletions
diff --git a/packages/SystemUI/res/drawable/ic_volume_accessibility.xml b/packages/SystemUI/res/drawable/ic_volume_accessibility.xml new file mode 100644 index 000000000000..657efaa213d4 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_volume_accessibility.xml @@ -0,0 +1,25 @@ +<!-- + Copyright (C) 2017 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License + --> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="32dp" + android:height="32dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FFFFFFFF" + android:pathData="M20.5,6c-2.61,0.7 -5.67,1 -8.5,1s-5.89,-0.3 -8.5,-1L3,8c1.86,0.5 4,0.83 6,1v13h2v-6h2v6h2V9c2,-0.17 4.14,-0.5 6,-1l-0.5,-2zM12,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z"/> +</vector>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java index d23ebc123e17..d057d863e9ef 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java @@ -127,6 +127,7 @@ public class VolumeDialog implements TunerService.Tunable { private boolean mShowing; private boolean mExpanded; + private boolean mShowA11yStream; private int mActiveStream; private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; @@ -244,7 +245,6 @@ public class VolumeDialog implements TunerService.Tunable { if (!AudioSystem.isSingleVolume(mContext)) { addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); - addRow(AudioManager.STREAM_ALARM, R.drawable.ic_volume_alarm, R.drawable.ic_volume_alarm_mute, false); addRow(AudioManager.STREAM_VOICE_CALL, @@ -253,6 +253,8 @@ public class VolumeDialog implements TunerService.Tunable { R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false); addRow(AudioManager.STREAM_SYSTEM, R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false); + addRow(AudioManager.STREAM_ACCESSIBILITY, R.drawable.ic_volume_accessibility, + R.drawable.ic_volume_accessibility, true); } } else { addExistingRows(); @@ -307,10 +309,24 @@ public class VolumeDialog implements TunerService.Tunable { } private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { + addRow(stream, iconRes, iconMuteRes, important, false); + } + + private void addRow(int stream, int iconRes, int iconMuteRes, boolean important, + boolean dynamic) { VolumeRow row = new VolumeRow(); initRow(row, stream, iconRes, iconMuteRes, important); - mDialogRowsView.addView(row.view); - mRows.add(row); + int rowSize; + int viewSize; + if (mShowA11yStream && dynamic && (rowSize = mRows.size()) > 1 + && (viewSize = mDialogRowsView.getChildCount()) > 1) { + // A11y Stream should be the last in the list + mDialogRowsView.addView(row.view, viewSize - 2); + mRows.add(rowSize - 2, row); + } else { + mDialogRowsView.addView(row.view); + mRows.add(row); + } } private void addExistingRows() { @@ -592,6 +608,9 @@ public class VolumeDialog implements TunerService.Tunable { } private boolean shouldBeVisibleH(VolumeRow row, boolean isActive) { + if (row.stream == AudioSystem.STREAM_ACCESSIBILITY) { + return mShowA11yStream; + } return mExpanded && row.view.getVisibility() == View.VISIBLE || (mExpanded && (row.important || isActive)) || !mExpanded && isActive; @@ -644,7 +663,8 @@ public class VolumeDialog implements TunerService.Tunable { if (!ss.dynamic) continue; mDynamic.put(stream, true); if (findRow(stream) == null) { - addRow(stream, R.drawable.ic_volume_remote, R.drawable.ic_volume_remote_mute, true); + addRow(stream, R.drawable.ic_volume_remote, R.drawable.ic_volume_remote_mute, true, + true); } } @@ -1009,6 +1029,14 @@ public class VolumeDialog implements TunerService.Tunable { public void onShowSafetyWarning(int flags) { showSafetyWarningH(flags); } + + @Override + public void onAccessibilityModeChanged(Boolean showA11yStream) { + boolean show = showA11yStream == null ? false : showA11yStream; + mShowA11yStream = show; + updateRowsH(getActiveRow()); + + } }; private final ZenModePanel.Callback mZenPanelCallback = new ZenModePanel.Callback() { diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java index 0e5ff43392d3..276b7c376867 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java @@ -75,13 +75,13 @@ public class VolumeDialogController { STREAMS.put(AudioSystem.STREAM_BLUETOOTH_SCO, R.string.stream_bluetooth_sco); STREAMS.put(AudioSystem.STREAM_DTMF, R.string.stream_dtmf); STREAMS.put(AudioSystem.STREAM_MUSIC, R.string.stream_music); + STREAMS.put(AudioSystem.STREAM_ACCESSIBILITY, R.string.stream_accessibility); STREAMS.put(AudioSystem.STREAM_NOTIFICATION, R.string.stream_notification); STREAMS.put(AudioSystem.STREAM_RING, R.string.stream_ring); STREAMS.put(AudioSystem.STREAM_SYSTEM, R.string.stream_system); STREAMS.put(AudioSystem.STREAM_SYSTEM_ENFORCED, R.string.stream_system_enforced); STREAMS.put(AudioSystem.STREAM_TTS, R.string.stream_tts); STREAMS.put(AudioSystem.STREAM_VOICE_CALL, R.string.stream_voice_call); - STREAMS.put(AudioSystem.STREAM_ACCESSIBILITY, R.string.stream_accessibility); } private final HandlerThread mWorkerThread; @@ -98,6 +98,7 @@ public class VolumeDialogController { private final MediaSessionsCallbacks mMediaSessionsCallbacksW = new MediaSessionsCallbacks(); private final Vibrator mVibrator; private final boolean mHasVibrator; + private boolean mShowA11yStream; private boolean mDestroyed; private VolumePolicy mVolumePolicy; @@ -204,6 +205,7 @@ public class VolumeDialogController { pw.print(" mHasVibrator: "); pw.println(mHasVibrator); pw.print(" mRemoteStreams: "); pw.println(mMediaSessionsCallbacksW.mRemoteStreams .values()); + pw.print(" mShowA11yStream: "); pw.println(mShowA11yStream); pw.println(); mMediaSessions.dump(pw); } @@ -301,6 +303,10 @@ public class VolumeDialogController { mCallbacks.onShowSafetyWarning(flags); } + private void onAccessibilityModeChanged(Boolean showA11yStream) { + mCallbacks.onAccessibilityModeChanged(showA11yStream); + } + private boolean checkRoutedToBluetoothW(int stream) { boolean changed = false; if (stream == AudioManager.STREAM_MUSIC) { @@ -570,13 +576,16 @@ public class VolumeDialogController { switch (mode) { case VolumePolicy.A11Y_MODE_MEDIA_A11Y_VOLUME: // "legacy" mode + mShowA11yStream = false; break; case VolumePolicy.A11Y_MODE_INDEPENDENT_A11Y_VOLUME: + mShowA11yStream = true; break; default: Log.e(TAG, "Invalid accessibility mode " + mode); break; } + mWorker.obtainMessage(W.ACCESSIBILITY_MODE_CHANGED, mShowA11yStream).sendToTarget(); } } @@ -595,6 +604,7 @@ public class VolumeDialogController { private static final int NOTIFY_VISIBLE = 12; private static final int USER_ACTIVITY = 13; private static final int SHOW_SAFETY_WARNING = 14; + private static final int ACCESSIBILITY_MODE_CHANGED = 15; W(Looper looper) { super(looper); @@ -617,6 +627,7 @@ public class VolumeDialogController { case NOTIFY_VISIBLE: onNotifyVisibleW(msg.arg1 != 0); break; case USER_ACTIVITY: onUserActivityW(); break; case SHOW_SAFETY_WARNING: onShowSafetyWarningW(msg.arg1); break; + case ACCESSIBILITY_MODE_CHANGED: onAccessibilityModeChanged((Boolean) msg.obj); } } } @@ -743,6 +754,19 @@ public class VolumeDialogController { }); } } + + @Override + public void onAccessibilityModeChanged(Boolean showA11yStream) { + boolean show = showA11yStream == null ? false : showA11yStream; + for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) { + entry.getValue().post(new Runnable() { + @Override + public void run() { + entry.getKey().onAccessibilityModeChanged(show); + } + }); + } + } } @@ -1004,6 +1028,7 @@ public class VolumeDialogController { .append('[').append(ss.levelMin).append("..").append(ss.levelMax) .append(']'); if (ss.muted) sb.append(" [MUTED]"); + if (ss.dynamic) sb.append(" [DYNAMIC]"); } sep(sb, indent); sb.append("ringerModeExternal:").append(ringerModeExternal); sep(sb, indent); sb.append("ringerModeInternal:").append(ringerModeInternal); @@ -1037,6 +1062,7 @@ public class VolumeDialogController { void onShowSilentHint(); void onScreenOff(); void onShowSafetyWarning(int flags); + void onAccessibilityModeChanged(Boolean showA11yStream); } public interface UserActivityListener { diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 49423b9e155e..31ef94fb5381 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -5932,7 +5932,7 @@ public class AudioService extends IAudioService.Stub * the whether any exposes the FLAG_ENABLE_ACCESSIBILITY_VOLUME flag * - set to false to listen to when accessibility services are started (e.g. "TalkBack started") */ - private static final boolean USE_FLAG_ENABLE_ACCESSIBILITY_VOLUME = true; + private static final boolean USE_FLAG_ENABLE_ACCESSIBILITY_VOLUME = false; private void initA11yMonitoring() { final AccessibilityManager accessibilityManager = |