Loading packages/CarSystemUI/res/values/config.xml +2 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ <item>com.android.systemui.util.NotificationChannels</item> <item>com.android.systemui.keyguard.KeyguardViewMediator</item> <!-- <item>com.android.systemui.recents.Recents</item>--> <item>com.android.systemui.volume.VolumeUI</item> <!-- <item>com.android.systemui.volume.VolumeUI</item>--> <!-- <item>com.android.systemui.stackdivider.Divider</item>--> <!-- <item>com.android.systemui.statusbar.phone.StatusBar</item>--> <item>com.android.systemui.usb.StorageNotification</item> Loading @@ -110,5 +110,6 @@ <item>com.android.systemui.toast.ToastUI</item> <item>com.android.systemui.car.voicerecognition.ConnectedDeviceVoiceRecognitionNotifier</item> <item>com.android.systemui.window.SystemUIOverlayWindowManager</item> <item>com.android.systemui.car.volume.VolumeUI</item> </string-array> </resources> packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java +2 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.android.systemui.biometrics.AuthController; import com.android.systemui.bubbles.dagger.BubbleModule; import com.android.systemui.car.notification.CarNotificationModule; import com.android.systemui.car.voicerecognition.ConnectedDeviceVoiceRecognitionNotifier; import com.android.systemui.car.volume.VolumeUI; import com.android.systemui.globalactions.GlobalActionsComponent; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.dagger.KeyguardModule; Loading @@ -39,7 +40,6 @@ import com.android.systemui.statusbar.tv.TvStatusBar; import com.android.systemui.theme.ThemeOverlayController; import com.android.systemui.toast.ToastUI; import com.android.systemui.util.leak.GarbageMonitor; import com.android.systemui.volume.VolumeUI; import com.android.systemui.window.OverlayWindowModule; import com.android.systemui.window.SystemUIOverlayWindowManager; Loading @@ -65,7 +65,7 @@ public abstract class CarSystemUIBinder { @ClassKey(Divider.class) public abstract SystemUI bindDivider(Divider sysui); /** */ /** Inject Car Navigation Bar. */ @Binds @IntoMap @ClassKey(CarNavigationBar.class) Loading packages/CarSystemUI/src/com/android/systemui/car/volume/VolumeUI.java 0 → 100644 +125 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.car.volume; import android.car.Car; import android.car.media.CarAudioManager; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Handler; import android.util.Log; import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.car.CarServiceProvider; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.volume.VolumeDialogComponent; import java.io.FileDescriptor; import java.io.PrintWriter; import javax.inject.Inject; import javax.inject.Singleton; import dagger.Lazy; /** The entry point for controlling the volume ui in cars. */ @Singleton public class VolumeUI extends SystemUI { private static final String TAG = "VolumeUI"; private final Resources mResources; private final Handler mMainHandler; private final CarServiceProvider mCarServiceProvider; private final Lazy<VolumeDialogComponent> mVolumeDialogComponentLazy; private final CarAudioManager.CarVolumeCallback mVolumeChangeCallback = new CarAudioManager.CarVolumeCallback() { @Override public void onGroupVolumeChanged(int zoneId, int groupId, int flags) { if (mVolumeDialogComponent == null) { mMainHandler.post(() -> { mVolumeDialogComponent = mVolumeDialogComponentLazy.get(); mVolumeDialogComponent.register(); }); mCarAudioManager.unregisterCarVolumeCallback(mVolumeChangeCallback); } } @Override public void onMasterMuteChanged(int zoneId, int flags) { // ignored } }; private boolean mEnabled; private CarAudioManager mCarAudioManager; private VolumeDialogComponent mVolumeDialogComponent; @Inject public VolumeUI( Context context, @Main Resources resources, @Main Handler mainHandler, CarServiceProvider carServiceProvider, Lazy<VolumeDialogComponent> volumeDialogComponentLazy ) { super(context); mResources = resources; mMainHandler = mainHandler; mCarServiceProvider = carServiceProvider; mVolumeDialogComponentLazy = volumeDialogComponentLazy; } @Override public void start() { boolean enableVolumeUi = mResources.getBoolean(R.bool.enable_volume_ui); mEnabled = enableVolumeUi; if (!mEnabled) return; mCarServiceProvider.addListener(car -> { if (mCarAudioManager != null) { return; } mCarAudioManager = (CarAudioManager) car.getCarManager(Car.AUDIO_SERVICE); Log.d(TAG, "Registering mVolumeChangeCallback."); // This volume call back is never unregistered because CarStatusBar is // never destroyed. mCarAudioManager.registerCarVolumeCallback(mVolumeChangeCallback); }); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (!mEnabled) return; if (mVolumeDialogComponent != null) { mVolumeDialogComponent.onConfigurationChanged(newConfig); } } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.print("mEnabled="); pw.println(mEnabled); if (!mEnabled) return; if (mVolumeDialogComponent != null) { mVolumeDialogComponent.dump(fd, pw, args); } } } packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ public class CarVolumeDialogComponent extends VolumeDialogComponent { @Override protected VolumeDialog createDefault() { mCarVolumeDialog = new CarVolumeDialogImpl(mContext); mCarVolumeDialog.show(Events.SHOW_REASON_VOLUME_CHANGED); return mCarVolumeDialog; } } packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java +14 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,20 @@ public class CarVolumeDialogImpl implements VolumeDialog { cleanupAudioManager(); } /** * Reveals volume dialog. */ public void show(int reason) { mHandler.obtainMessage(H.SHOW, reason).sendToTarget(); } /** * Hides volume dialog. */ public void dismiss(int reason) { mHandler.obtainMessage(H.DISMISS, reason).sendToTarget(); } private void initDialog() { loadAudioUsageItems(); mCarVolumeLineItems.clear(); Loading Loading
packages/CarSystemUI/res/values/config.xml +2 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ <item>com.android.systemui.util.NotificationChannels</item> <item>com.android.systemui.keyguard.KeyguardViewMediator</item> <!-- <item>com.android.systemui.recents.Recents</item>--> <item>com.android.systemui.volume.VolumeUI</item> <!-- <item>com.android.systemui.volume.VolumeUI</item>--> <!-- <item>com.android.systemui.stackdivider.Divider</item>--> <!-- <item>com.android.systemui.statusbar.phone.StatusBar</item>--> <item>com.android.systemui.usb.StorageNotification</item> Loading @@ -110,5 +110,6 @@ <item>com.android.systemui.toast.ToastUI</item> <item>com.android.systemui.car.voicerecognition.ConnectedDeviceVoiceRecognitionNotifier</item> <item>com.android.systemui.window.SystemUIOverlayWindowManager</item> <item>com.android.systemui.car.volume.VolumeUI</item> </string-array> </resources>
packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java +2 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.android.systemui.biometrics.AuthController; import com.android.systemui.bubbles.dagger.BubbleModule; import com.android.systemui.car.notification.CarNotificationModule; import com.android.systemui.car.voicerecognition.ConnectedDeviceVoiceRecognitionNotifier; import com.android.systemui.car.volume.VolumeUI; import com.android.systemui.globalactions.GlobalActionsComponent; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.dagger.KeyguardModule; Loading @@ -39,7 +40,6 @@ import com.android.systemui.statusbar.tv.TvStatusBar; import com.android.systemui.theme.ThemeOverlayController; import com.android.systemui.toast.ToastUI; import com.android.systemui.util.leak.GarbageMonitor; import com.android.systemui.volume.VolumeUI; import com.android.systemui.window.OverlayWindowModule; import com.android.systemui.window.SystemUIOverlayWindowManager; Loading @@ -65,7 +65,7 @@ public abstract class CarSystemUIBinder { @ClassKey(Divider.class) public abstract SystemUI bindDivider(Divider sysui); /** */ /** Inject Car Navigation Bar. */ @Binds @IntoMap @ClassKey(CarNavigationBar.class) Loading
packages/CarSystemUI/src/com/android/systemui/car/volume/VolumeUI.java 0 → 100644 +125 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.car.volume; import android.car.Car; import android.car.media.CarAudioManager; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Handler; import android.util.Log; import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.car.CarServiceProvider; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.volume.VolumeDialogComponent; import java.io.FileDescriptor; import java.io.PrintWriter; import javax.inject.Inject; import javax.inject.Singleton; import dagger.Lazy; /** The entry point for controlling the volume ui in cars. */ @Singleton public class VolumeUI extends SystemUI { private static final String TAG = "VolumeUI"; private final Resources mResources; private final Handler mMainHandler; private final CarServiceProvider mCarServiceProvider; private final Lazy<VolumeDialogComponent> mVolumeDialogComponentLazy; private final CarAudioManager.CarVolumeCallback mVolumeChangeCallback = new CarAudioManager.CarVolumeCallback() { @Override public void onGroupVolumeChanged(int zoneId, int groupId, int flags) { if (mVolumeDialogComponent == null) { mMainHandler.post(() -> { mVolumeDialogComponent = mVolumeDialogComponentLazy.get(); mVolumeDialogComponent.register(); }); mCarAudioManager.unregisterCarVolumeCallback(mVolumeChangeCallback); } } @Override public void onMasterMuteChanged(int zoneId, int flags) { // ignored } }; private boolean mEnabled; private CarAudioManager mCarAudioManager; private VolumeDialogComponent mVolumeDialogComponent; @Inject public VolumeUI( Context context, @Main Resources resources, @Main Handler mainHandler, CarServiceProvider carServiceProvider, Lazy<VolumeDialogComponent> volumeDialogComponentLazy ) { super(context); mResources = resources; mMainHandler = mainHandler; mCarServiceProvider = carServiceProvider; mVolumeDialogComponentLazy = volumeDialogComponentLazy; } @Override public void start() { boolean enableVolumeUi = mResources.getBoolean(R.bool.enable_volume_ui); mEnabled = enableVolumeUi; if (!mEnabled) return; mCarServiceProvider.addListener(car -> { if (mCarAudioManager != null) { return; } mCarAudioManager = (CarAudioManager) car.getCarManager(Car.AUDIO_SERVICE); Log.d(TAG, "Registering mVolumeChangeCallback."); // This volume call back is never unregistered because CarStatusBar is // never destroyed. mCarAudioManager.registerCarVolumeCallback(mVolumeChangeCallback); }); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (!mEnabled) return; if (mVolumeDialogComponent != null) { mVolumeDialogComponent.onConfigurationChanged(newConfig); } } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.print("mEnabled="); pw.println(mEnabled); if (!mEnabled) return; if (mVolumeDialogComponent != null) { mVolumeDialogComponent.dump(fd, pw, args); } } }
packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ public class CarVolumeDialogComponent extends VolumeDialogComponent { @Override protected VolumeDialog createDefault() { mCarVolumeDialog = new CarVolumeDialogImpl(mContext); mCarVolumeDialog.show(Events.SHOW_REASON_VOLUME_CHANGED); return mCarVolumeDialog; } }
packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java +14 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,20 @@ public class CarVolumeDialogImpl implements VolumeDialog { cleanupAudioManager(); } /** * Reveals volume dialog. */ public void show(int reason) { mHandler.obtainMessage(H.SHOW, reason).sendToTarget(); } /** * Hides volume dialog. */ public void dismiss(int reason) { mHandler.obtainMessage(H.DISMISS, reason).sendToTarget(); } private void initDialog() { loadAudioUsageItems(); mCarVolumeLineItems.clear(); Loading