blob: bd36462ca61282ee9812f0985722e945889f119b [file] [log] [blame]
Lorenzo Colittid46bb582015-04-27 20:32:01 +09001/*
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 */
16package com.android.systemui.statusbar.policy;
17
18import android.content.Context;
19import android.net.NetworkCapabilities;
20
Jason Monk07b75fe2015-05-14 16:47:03 -040021import com.android.systemui.statusbar.policy.NetworkController.IconState;
Lorenzo Colittid46bb582015-04-27 20:32:01 +090022
Jason Monk33f8ae72015-05-08 10:45:15 -040023import java.util.BitSet;
24
Lorenzo Colittid46bb582015-04-27 20:32:01 +090025
26public class EthernetSignalController extends
27 SignalController<SignalController.State, SignalController.IconGroup> {
28
29 public EthernetSignalController(Context context,
Jason Monk07b75fe2015-05-14 16:47:03 -040030 CallbackHandler callbackHandler, NetworkControllerImpl networkController) {
Lorenzo Colittid46bb582015-04-27 20:32:01 +090031 super("EthernetSignalController", context, NetworkCapabilities.TRANSPORT_ETHERNET,
Jason Monk07b75fe2015-05-14 16:47:03 -040032 callbackHandler, networkController);
Lorenzo Colittid46bb582015-04-27 20:32:01 +090033 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 Monk33f8ae72015-05-08 10:45:15 -040043 public void updateConnectivity(BitSet connectedTransports, BitSet validatedTransports) {
44 mCurrentState.connected = connectedTransports.get(mTransportType);
45 super.updateConnectivity(connectedTransports, validatedTransports);
46 }
47
48 @Override
Lorenzo Colittid46bb582015-04-27 20:32:01 +090049 public void notifyListeners() {
50 boolean ethernetVisible = mCurrentState.connected;
51 String contentDescription = getStringIfExists(getContentDescription());
52
53 // TODO: wire up data transfer using WifiSignalPoller.
Jason Monk07b75fe2015-05-14 16:47:03 -040054 mCallbackHandler.setEthernetIndicators(new IconState(ethernetVisible, getCurrentIconId(),
55 contentDescription));
Lorenzo Colittid46bb582015-04-27 20:32:01 +090056 }
57
58 @Override
59 public SignalController.State cleanState() {
60 return new SignalController.State();
61 }
Lorenzo Colittid46bb582015-04-27 20:32:01 +090062}