Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | package com.android.systemui.statusbar.policy; |
| 17 | |
| 18 | import android.content.Context; |
| 19 | import android.net.NetworkCapabilities; |
| 20 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 21 | import com.android.systemui.statusbar.policy.NetworkController.IconState; |
Jason Monk | e06b065 | 2016-03-02 16:35:27 -0500 | [diff] [blame] | 22 | import com.android.systemui.statusbar.policy.NetworkController.SignalCallback; |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 23 | |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 24 | import java.util.BitSet; |
| 25 | |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 26 | |
| 27 | public class EthernetSignalController extends |
| 28 | SignalController<SignalController.State, SignalController.IconGroup> { |
| 29 | |
| 30 | public EthernetSignalController(Context context, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 31 | CallbackHandler callbackHandler, NetworkControllerImpl networkController) { |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 32 | super("EthernetSignalController", context, NetworkCapabilities.TRANSPORT_ETHERNET, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 33 | callbackHandler, networkController); |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 34 | mCurrentState.iconGroup = mLastState.iconGroup = new IconGroup( |
| 35 | "Ethernet Icons", |
| 36 | EthernetIcons.ETHERNET_ICONS, |
| 37 | null, |
| 38 | AccessibilityContentDescriptions.ETHERNET_CONNECTION_VALUES, |
| 39 | 0, 0, 0, 0, |
| 40 | AccessibilityContentDescriptions.ETHERNET_CONNECTION_VALUES[0]); |
| 41 | } |
| 42 | |
| 43 | @Override |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 44 | public void updateConnectivity(BitSet connectedTransports, BitSet validatedTransports) { |
| 45 | mCurrentState.connected = connectedTransports.get(mTransportType); |
| 46 | super.updateConnectivity(connectedTransports, validatedTransports); |
| 47 | } |
| 48 | |
| 49 | @Override |
Jason Monk | e06b065 | 2016-03-02 16:35:27 -0500 | [diff] [blame] | 50 | public void notifyListeners(SignalCallback callback) { |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 51 | boolean ethernetVisible = mCurrentState.connected; |
Evan Laird | 83c87e5 | 2019-09-24 19:14:05 -0400 | [diff] [blame] | 52 | String contentDescription = getStringIfExists(getContentDescription()).toString(); |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 53 | |
| 54 | // TODO: wire up data transfer using WifiSignalPoller. |
Jason Monk | e06b065 | 2016-03-02 16:35:27 -0500 | [diff] [blame] | 55 | callback.setEthernetIndicators(new IconState(ethernetVisible, getCurrentIconId(), |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 56 | contentDescription)); |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public SignalController.State cleanState() { |
| 61 | return new SignalController.State(); |
| 62 | } |
Lorenzo Colitti | d46bb58 | 2015-04-27 20:32:01 +0900 | [diff] [blame] | 63 | } |