1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.volume.dagger; 18 19 import android.content.BroadcastReceiver; 20 import android.content.Context; 21 import android.media.AudioManager; 22 import android.os.Looper; 23 24 import com.android.internal.jank.InteractionJankMonitor; 25 import com.android.systemui.CoreStartable; 26 import com.android.systemui.dump.DumpManager; 27 import com.android.systemui.media.dialog.MediaOutputDialogManager; 28 import com.android.systemui.plugins.VolumeDialog; 29 import com.android.systemui.plugins.VolumeDialogController; 30 import com.android.systemui.statusbar.VibratorHelper; 31 import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; 32 import com.android.systemui.statusbar.policy.ConfigurationController; 33 import com.android.systemui.statusbar.policy.DevicePostureController; 34 import com.android.systemui.statusbar.policy.DeviceProvisionedController; 35 import com.android.systemui.util.settings.SecureSettings; 36 import com.android.systemui.util.time.SystemClock; 37 import com.android.systemui.volume.CsdWarningDialog; 38 import com.android.systemui.volume.VolumeComponent; 39 import com.android.systemui.volume.VolumeDialogComponent; 40 import com.android.systemui.volume.VolumeDialogImpl; 41 import com.android.systemui.volume.VolumePanelDialogReceiver; 42 import com.android.systemui.volume.VolumeUI; 43 import com.android.systemui.volume.domain.interactor.VolumeDialogInteractor; 44 import com.android.systemui.volume.domain.interactor.VolumePanelNavigationInteractor; 45 import com.android.systemui.volume.panel.dagger.VolumePanelComponent; 46 import com.android.systemui.volume.panel.dagger.factory.VolumePanelComponentFactory; 47 import com.android.systemui.volume.panel.shared.flag.VolumePanelFlag; 48 import com.android.systemui.volume.ui.navigation.VolumeNavigator; 49 50 import dagger.Binds; 51 import dagger.Lazy; 52 import dagger.Module; 53 import dagger.Provides; 54 import dagger.multibindings.ClassKey; 55 import dagger.multibindings.IntoMap; 56 import dagger.multibindings.IntoSet; 57 58 /** Dagger Module for code in the volume package. */ 59 @Module( 60 includes = { 61 AudioModule.class, 62 AncModule.class, 63 CaptioningModule.class, 64 MediaDevicesModule.class, 65 SpatializerModule.class, 66 }, 67 subcomponents = { 68 VolumePanelComponent.class 69 } 70 ) 71 public interface VolumeModule { 72 73 /** 74 * Binds [VolumePanelDialogReceiver] 75 */ 76 @Binds 77 @IntoMap 78 @ClassKey(VolumePanelDialogReceiver.class) bindVolumePanelDialogReceiver(VolumePanelDialogReceiver receiver)79 BroadcastReceiver bindVolumePanelDialogReceiver(VolumePanelDialogReceiver receiver); 80 81 /** Starts VolumeUI. */ 82 @Binds 83 @IntoMap 84 @ClassKey(VolumeUI.class) bindVolumeUIStartable(VolumeUI impl)85 CoreStartable bindVolumeUIStartable(VolumeUI impl); 86 87 /** Listen to config changes for VolumeUI. */ 88 @Binds 89 @IntoSet bindVolumeUIConfigChanges(VolumeUI impl)90 ConfigurationController.ConfigurationListener bindVolumeUIConfigChanges(VolumeUI impl); 91 92 /** */ 93 @Binds provideVolumeComponent(VolumeDialogComponent volumeDialogComponent)94 VolumeComponent provideVolumeComponent(VolumeDialogComponent volumeDialogComponent); 95 96 /** */ 97 @Binds bindVolumePanelComponentFactory(VolumePanelComponent.Factory impl)98 VolumePanelComponentFactory bindVolumePanelComponentFactory(VolumePanelComponent.Factory impl); 99 100 /** */ 101 @Provides provideVolumeDialog( Context context, VolumeDialogController volumeDialogController, AccessibilityManagerWrapper accessibilityManagerWrapper, DeviceProvisionedController deviceProvisionedController, ConfigurationController configurationController, MediaOutputDialogManager mediaOutputDialogManager, InteractionJankMonitor interactionJankMonitor, VolumePanelNavigationInteractor volumePanelNavigationInteractor, VolumeNavigator volumeNavigator, CsdWarningDialog.Factory csdFactory, DevicePostureController devicePostureController, VolumePanelFlag volumePanelFlag, DumpManager dumpManager, Lazy<SecureSettings> secureSettings, VibratorHelper vibratorHelper, SystemClock systemClock, VolumeDialogInteractor interactor)102 static VolumeDialog provideVolumeDialog( 103 Context context, 104 VolumeDialogController volumeDialogController, 105 AccessibilityManagerWrapper accessibilityManagerWrapper, 106 DeviceProvisionedController deviceProvisionedController, 107 ConfigurationController configurationController, 108 MediaOutputDialogManager mediaOutputDialogManager, 109 InteractionJankMonitor interactionJankMonitor, 110 VolumePanelNavigationInteractor volumePanelNavigationInteractor, 111 VolumeNavigator volumeNavigator, 112 CsdWarningDialog.Factory csdFactory, 113 DevicePostureController devicePostureController, 114 VolumePanelFlag volumePanelFlag, 115 DumpManager dumpManager, 116 Lazy<SecureSettings> secureSettings, 117 VibratorHelper vibratorHelper, 118 SystemClock systemClock, 119 VolumeDialogInteractor interactor) { 120 VolumeDialogImpl impl = new VolumeDialogImpl( 121 context, 122 volumeDialogController, 123 accessibilityManagerWrapper, 124 deviceProvisionedController, 125 configurationController, 126 mediaOutputDialogManager, 127 interactionJankMonitor, 128 volumePanelNavigationInteractor, 129 volumeNavigator, 130 true, /* should listen for jank */ 131 csdFactory, 132 devicePostureController, 133 Looper.getMainLooper(), 134 volumePanelFlag, 135 dumpManager, 136 secureSettings, 137 vibratorHelper, 138 systemClock, 139 interactor); 140 impl.setStreamImportant(AudioManager.STREAM_SYSTEM, false); 141 impl.setAutomute(true); 142 impl.setSilentMode(false); 143 return impl; 144 } 145 } 146