summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2015-03-25 18:09:51 -0400
committerJohn Spurlock <jspurlock@google.com>2015-04-02 14:03:57 -0400
commitf88d8082a86bee00c604cbbcfb5261f5573936fe (patch)
treec6d3448fd8cd1e43d00b2896efd482f55d27068e /packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java
parent356c628e1b3ff6a3f327fdc512deb5288710ab47 (diff)
downloadframeworks_base-f88d8082a86bee00c604cbbcfb5261f5573936fe.zip
frameworks_base-f88d8082a86bee00c604cbbcfb5261f5573936fe.tar.gz
frameworks_base-f88d8082a86bee00c604cbbcfb5261f5573936fe.tar.bz2
Introduce new volume dialog.
- New VolumeDialog (presentation) + VolumeDialogController (state) to implement a volume dialog that keeps track of multiple audio streams, including all remote streams. - The dialog starts out with a single stream, with more detail available behind an expand chevron. - Existing zen options reorganized under a master switch bar named "Block interruptions", with "None" renamed to "No interruptions" and "Priority" renamed to "Priority only". - Combined "Block interruptions" icon replaces the now-obsolete star/no-smoking icons in the status bar. - New icons for all sliders. - All sliders present a continuous facade, mapped to discrete integer units under the hood. - All interesting volume events and state changes piped through one central helper for future routing. - VolumePanel is obsolete, still accessible via a sysprop if needed. Complete removal / garbage collection deferred until all needed functionality is ported over. Bug: 19260237 Change-Id: I6689de3e4d14ae666d3e8da302cc9da2d4d77b9b
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java184
1 files changed, 184 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java
new file mode 100644
index 0000000..fa6ea9e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanelComponent.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.systemui.volume;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.media.AudioManager;
+import android.media.IRemoteVolumeController;
+import android.media.IVolumeController;
+import android.media.VolumePolicy;
+import android.media.session.ISessionController;
+import android.media.session.MediaController;
+import android.media.session.MediaSessionManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
+
+import com.android.systemui.R;
+import com.android.systemui.SystemUI;
+import com.android.systemui.keyguard.KeyguardViewMediator;
+import com.android.systemui.qs.tiles.DndTile;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+import com.android.systemui.statusbar.policy.ZenModeController;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+/**
+ * Implementation of VolumeComponent backed by the old volume panel.
+ */
+public class VolumePanelComponent implements VolumeComponent {
+
+ private final SystemUI mSysui;
+ private final Context mContext;
+ private final Handler mHandler;
+ private final VolumeController mVolumeController;
+ private final RemoteVolumeController mRemoteVolumeController;
+ private final AudioManager mAudioManager;
+ private final MediaSessionManager mMediaSessionManager;
+
+ private VolumePanel mPanel;
+ private int mDismissDelay;
+
+ public VolumePanelComponent(SystemUI sysui, Context context, Handler handler,
+ ZenModeController controller) {
+ mSysui = sysui;
+ mContext = context;
+ mHandler = handler;
+ mAudioManager = context.getSystemService(AudioManager.class);
+ mMediaSessionManager = context.getSystemService(MediaSessionManager.class);
+ mVolumeController = new VolumeController();
+ mRemoteVolumeController = new RemoteVolumeController();
+ mDismissDelay = mContext.getResources().getInteger(R.integer.volume_panel_dismiss_delay);
+ mPanel = new VolumePanel(mContext, controller);
+ mPanel.setCallback(new VolumePanel.Callback() {
+ @Override
+ public void onZenSettings() {
+ mHandler.removeCallbacks(mStartZenSettings);
+ mHandler.post(mStartZenSettings);
+ }
+
+ @Override
+ public void onInteraction() {
+ final KeyguardViewMediator kvm = mSysui.getComponent(KeyguardViewMediator.class);
+ if (kvm != null) {
+ kvm.userActivity();
+ }
+ }
+
+ @Override
+ public void onVisible(boolean visible) {
+ if (mAudioManager != null && mVolumeController != null) {
+ mAudioManager.notifyVolumeControllerVisible(mVolumeController, visible);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ if (mPanel != null) {
+ mPanel.dump(fd, pw, args);
+ }
+ }
+
+ public void register() {
+ mAudioManager.setVolumeController(mVolumeController);
+ mAudioManager.setVolumePolicy(VolumePolicy.DEFAULT);
+ mMediaSessionManager.setRemoteVolumeController(mRemoteVolumeController);
+ DndTile.setVisible(mContext, false);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ if (mPanel != null) {
+ mPanel.onConfigurationChanged(newConfig);
+ }
+ }
+
+ @Override
+ public ZenModeController getZenController() {
+ return mPanel.getZenController();
+ }
+
+ @Override
+ public void dispatchDemoCommand(String command, Bundle args) {
+ mPanel.dispatchDemoCommand(command, args);
+ }
+
+ @Override
+ public void dismissNow() {
+ mPanel.postDismiss(0);
+ }
+
+ private final Runnable mStartZenSettings = new Runnable() {
+ @Override
+ public void run() {
+ mSysui.getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(
+ ZenModePanel.ZEN_SETTINGS, true /* onlyProvisioned */, true /* dismissShade */);
+ mPanel.postDismiss(mDismissDelay);
+ }
+ };
+
+ private final class RemoteVolumeController extends IRemoteVolumeController.Stub {
+ @Override
+ public void remoteVolumeChanged(ISessionController binder, int flags)
+ throws RemoteException {
+ MediaController controller = new MediaController(mContext, binder);
+ mPanel.postRemoteVolumeChanged(controller, flags);
+ }
+
+ @Override
+ public void updateRemoteController(ISessionController session) throws RemoteException {
+ mPanel.postRemoteSliderVisibility(session != null);
+ // TODO stash default session in case the slider can be opened other
+ // than by remoteVolumeChanged.
+ }
+ }
+
+ /** For now, simply host an unmodified base volume panel in this process. */
+ private final class VolumeController extends IVolumeController.Stub {
+
+ @Override
+ public void displaySafeVolumeWarning(int flags) throws RemoteException {
+ mPanel.postDisplaySafeVolumeWarning(flags);
+ }
+
+ @Override
+ public void volumeChanged(int streamType, int flags)
+ throws RemoteException {
+ mPanel.postVolumeChanged(streamType, flags);
+ }
+
+ @Override
+ public void masterMuteChanged(int flags) throws RemoteException {
+ // no-op
+ }
+
+ @Override
+ public void setLayoutDirection(int layoutDirection)
+ throws RemoteException {
+ mPanel.postLayoutDirection(layoutDirection);
+ }
+
+ @Override
+ public void dismiss() throws RemoteException {
+ dismissNow();
+ }
+ }
+}