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