1 /* 2 * Copyright (C) 2022 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.statusbar.connectivity 18 19 import com.android.systemui.flags.FeatureFlags 20 import com.android.systemui.flags.Flags.SIGNAL_CALLBACK_DEPRECATION 21 import com.android.systemui.qs.tileimpl.QSTileImpl 22 import com.android.systemui.qs.tiles.AirplaneModeTile 23 import com.android.systemui.qs.tiles.BluetoothTile 24 import com.android.systemui.qs.tiles.CastTile 25 import com.android.systemui.qs.tiles.DataSaverTile 26 import com.android.systemui.qs.tiles.HotspotTile 27 import com.android.systemui.qs.tiles.InternetTile 28 import com.android.systemui.qs.tiles.InternetTileNewImpl 29 import com.android.systemui.qs.tiles.NfcTile 30 import dagger.Binds 31 import dagger.Module 32 import dagger.Provides 33 import dagger.multibindings.IntoMap 34 import dagger.multibindings.StringKey 35 36 @Module 37 interface ConnectivityModule { 38 39 /** Inject BluetoothTile into tileMap in QSModule */ 40 @Binds 41 @IntoMap 42 @StringKey(BluetoothTile.TILE_SPEC) 43 fun bindBluetoothTile(bluetoothTile: BluetoothTile): QSTileImpl<*> 44 45 /** Inject CastTile into tileMap in QSModule */ 46 @Binds 47 @IntoMap 48 @StringKey(CastTile.TILE_SPEC) 49 fun bindCastTile(castTile: CastTile): QSTileImpl<*> 50 51 /** Inject HotspotTile into tileMap in QSModule */ 52 @Binds 53 @IntoMap 54 @StringKey(HotspotTile.TILE_SPEC) 55 fun bindHotspotTile(hotspotTile: HotspotTile): QSTileImpl<*> 56 57 /** Inject AirplaneModeTile into tileMap in QSModule */ 58 @Binds 59 @IntoMap 60 @StringKey(AirplaneModeTile.TILE_SPEC) 61 fun bindAirplaneModeTile(airplaneModeTile: AirplaneModeTile): QSTileImpl<*> 62 63 /** Inject DataSaverTile into tileMap in QSModule */ 64 @Binds 65 @IntoMap 66 @StringKey(DataSaverTile.TILE_SPEC) 67 fun bindDataSaverTile(dataSaverTile: DataSaverTile): QSTileImpl<*> 68 69 /** Inject NfcTile into tileMap in QSModule */ 70 @Binds @IntoMap @StringKey(NfcTile.TILE_SPEC) fun bindNfcTile(nfcTile: NfcTile): QSTileImpl<*> 71 72 companion object { 73 /** Inject InternetTile or InternetTileNewImpl into tileMap in QSModule */ 74 @Provides 75 @IntoMap 76 @StringKey(InternetTile.TILE_SPEC) 77 fun bindInternetTile( 78 internetTile: InternetTile, 79 newInternetTile: InternetTileNewImpl, 80 featureFlags: FeatureFlags, 81 ): QSTileImpl<*> = 82 if (featureFlags.isEnabled(SIGNAL_CALLBACK_DEPRECATION)) { 83 newInternetTile 84 } else { 85 internetTile 86 } 87 } 88 } 89