• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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.policy;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.telephony.SubscriptionInfo;
22 
23 import com.android.settingslib.net.DataUsageController;
24 import com.android.settingslib.wifi.AccessPoint;
25 import com.android.systemui.DemoMode;
26 import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
27 
28 import java.util.List;
29 
30 public interface NetworkController extends CallbackController<SignalCallback>, DemoMode {
31 
hasMobileDataFeature()32     boolean hasMobileDataFeature();
addCallback(SignalCallback cb)33     void addCallback(SignalCallback cb);
removeCallback(SignalCallback cb)34     void removeCallback(SignalCallback cb);
setWifiEnabled(boolean enabled)35     void setWifiEnabled(boolean enabled);
getAccessPointController()36     AccessPointController getAccessPointController();
getMobileDataController()37     DataUsageController getMobileDataController();
getDataSaverController()38     DataSaverController getDataSaverController();
getMobileDataNetworkName()39     String getMobileDataNetworkName();
isMobileDataNetworkInService()40     boolean isMobileDataNetworkInService();
getNumberSubscriptions()41     int getNumberSubscriptions();
42 
hasVoiceCallingFeature()43     boolean hasVoiceCallingFeature();
44 
addEmergencyListener(EmergencyListener listener)45     void addEmergencyListener(EmergencyListener listener);
removeEmergencyListener(EmergencyListener listener)46     void removeEmergencyListener(EmergencyListener listener);
hasEmergencyCryptKeeperText()47     boolean hasEmergencyCryptKeeperText();
48 
isRadioOn()49     boolean isRadioOn();
50 
51     public interface SignalCallback {
setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, boolean activityIn, boolean activityOut, String description, boolean isTransient, String statusLabel)52         default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
53                 boolean activityIn, boolean activityOut, String description, boolean isTransient,
54                 String statusLabel) {}
55 
56         /**
57          * Callback for listeners to be able to update the state of any UI tracking connectivity
58          *  @param statusIcon the icon that should be shown in the status bar
59          * @param qsIcon the icon to show in Quick Settings
60          * @param statusType the resId of the data type icon (e.g. LTE) to show in the status bar
61          * @param qsType similar to above, the resId of the data type icon to show in Quick Settings
62          * @param activityIn indicates whether there is inbound activity
63          * @param activityOut indicates outbound activity
64          * @param typeContentDescription the contentDescription of the data type
65          * @param typeContentDescriptionHtml the (possibly HTML-styled) contentDescription of the
66          *                                   data type. Suitable for display
67          * @param description description of the network (usually just the network name)
68          * @param isWide //TODO: unused?
69          * @param subId subscription ID for which to update the UI
70          * @param roaming indicates roaming
71          */
setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, int qsType, boolean activityIn, boolean activityOut, CharSequence typeContentDescription, CharSequence typeContentDescriptionHtml, CharSequence description, boolean isWide, int subId, boolean roaming)72         default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
73                 int qsType, boolean activityIn, boolean activityOut,
74                 CharSequence typeContentDescription,
75                 CharSequence typeContentDescriptionHtml, CharSequence description,
76                 boolean isWide, int subId, boolean roaming) {
77         }
78 
setSubs(List<SubscriptionInfo> subs)79         default void setSubs(List<SubscriptionInfo> subs) {}
80 
setNoSims(boolean show, boolean simDetected)81         default void setNoSims(boolean show, boolean simDetected) {}
82 
setEthernetIndicators(IconState icon)83         default void setEthernetIndicators(IconState icon) {}
84 
setIsAirplaneMode(IconState icon)85         default void setIsAirplaneMode(IconState icon) {}
86 
setMobileDataEnabled(boolean enabled)87         default void setMobileDataEnabled(boolean enabled) {}
88     }
89 
90     public interface EmergencyListener {
setEmergencyCallsOnly(boolean emergencyOnly)91         void setEmergencyCallsOnly(boolean emergencyOnly);
92     }
93 
94     public static class IconState {
95         public final boolean visible;
96         public final int icon;
97         public final String contentDescription;
98 
IconState(boolean visible, int icon, String contentDescription)99         public IconState(boolean visible, int icon, String contentDescription) {
100             this.visible = visible;
101             this.icon = icon;
102             this.contentDescription = contentDescription;
103         }
104 
IconState(boolean visible, int icon, int contentDescription, Context context)105         public IconState(boolean visible, int icon, int contentDescription,
106                 Context context) {
107             this(visible, icon, context.getString(contentDescription));
108         }
109     }
110 
111     /**
112      * Tracks changes in access points.  Allows listening for changes, scanning for new APs,
113      * and connecting to new ones.
114      */
115     public interface AccessPointController {
addAccessPointCallback(AccessPointCallback callback)116         void addAccessPointCallback(AccessPointCallback callback);
removeAccessPointCallback(AccessPointCallback callback)117         void removeAccessPointCallback(AccessPointCallback callback);
scanForAccessPoints()118         void scanForAccessPoints();
getIcon(AccessPoint ap)119         int getIcon(AccessPoint ap);
connect(AccessPoint ap)120         boolean connect(AccessPoint ap);
canConfigWifi()121         boolean canConfigWifi();
122 
123         public interface AccessPointCallback {
onAccessPointsChanged(List<AccessPoint> accessPoints)124             void onAccessPointsChanged(List<AccessPoint> accessPoints);
onSettingsActivityTriggered(Intent settingsIntent)125             void onSettingsActivityTriggered(Intent settingsIntent);
126         }
127     }
128 }
129