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();
39 
hasVoiceCallingFeature()40     boolean hasVoiceCallingFeature();
41 
addEmergencyListener(EmergencyListener listener)42     void addEmergencyListener(EmergencyListener listener);
removeEmergencyListener(EmergencyListener listener)43     void removeEmergencyListener(EmergencyListener listener);
hasEmergencyCryptKeeperText()44     boolean hasEmergencyCryptKeeperText();
isRadioOn()45     boolean isRadioOn();
46 
47     public interface SignalCallback {
setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, boolean activityIn, boolean activityOut, String description, boolean isTransient)48         default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
49                 boolean activityIn, boolean activityOut, String description, boolean isTransient) {}
50 
setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, int qsType, boolean activityIn, boolean activityOut, String typeContentDescription, String description, boolean isWide, int subId, boolean roaming)51         default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
52                 int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
53                 String description, boolean isWide, int subId, boolean roaming) {}
setSubs(List<SubscriptionInfo> subs)54         default void setSubs(List<SubscriptionInfo> subs) {}
setNoSims(boolean show)55         default void setNoSims(boolean show) {}
56 
setEthernetIndicators(IconState icon)57         default void setEthernetIndicators(IconState icon) {}
58 
setIsAirplaneMode(IconState icon)59         default void setIsAirplaneMode(IconState icon) {}
60 
setMobileDataEnabled(boolean enabled)61         default void setMobileDataEnabled(boolean enabled) {}
62     }
63 
64     public interface EmergencyListener {
setEmergencyCallsOnly(boolean emergencyOnly)65         void setEmergencyCallsOnly(boolean emergencyOnly);
66     }
67 
68     public static class IconState {
69         public final boolean visible;
70 
71         public final int icon;
72 
73         /**
74          * Optional iconOverlay resource id.
75          *
76          * <p>Set to -1 if not present.
77          */
78         public final int iconOverlay;
79 
80         public final String contentDescription;
81 
IconState(boolean visible, int icon, int iconOverlay, String contentDescription)82         public IconState(boolean visible, int icon, int iconOverlay, String contentDescription) {
83             this.visible = visible;
84             this.icon = icon;
85             this.iconOverlay = iconOverlay;
86             this.contentDescription = contentDescription;
87         }
88 
IconState(boolean visible, int icon, String contentDescription)89         public IconState(boolean visible, int icon, String contentDescription) {
90             this(visible, icon, -1 /* iconOverlay */, contentDescription);
91         }
92 
IconState(boolean visible, int icon, int contentDescription, Context context)93         public IconState(boolean visible, int icon, int contentDescription,
94                 Context context) {
95             this(visible, icon, context.getString(contentDescription));
96         }
97     }
98 
99     /**
100      * Tracks changes in access points.  Allows listening for changes, scanning for new APs,
101      * and connecting to new ones.
102      */
103     public interface AccessPointController {
addAccessPointCallback(AccessPointCallback callback)104         void addAccessPointCallback(AccessPointCallback callback);
removeAccessPointCallback(AccessPointCallback callback)105         void removeAccessPointCallback(AccessPointCallback callback);
scanForAccessPoints()106         void scanForAccessPoints();
getIcon(AccessPoint ap)107         int getIcon(AccessPoint ap);
connect(AccessPoint ap)108         boolean connect(AccessPoint ap);
canConfigWifi()109         boolean canConfigWifi();
110 
111         public interface AccessPointCallback {
onAccessPointsChanged(List<AccessPoint> accessPoints)112             void onAccessPointsChanged(List<AccessPoint> accessPoints);
onSettingsActivityTriggered(Intent settingsIntent)113             void onSettingsActivityTriggered(Intent settingsIntent);
114         }
115     }
116 }
117