blob: 95a97729936b6a2b2a89db65f725a7526db37d94 [file] [log] [blame]
Joe Onoratofd52b182010-11-10 18:00:52 -08001/*
John Spurlockaf8d6c42014-05-07 17:49:08 -04002 * Copyright (C) 2014 The Android Open Source Project
Joe Onoratofd52b182010-11-10 18:00:52 -08003 *
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
17package com.android.systemui.statusbar.policy;
18
Jason Monk07b75fe2015-05-14 16:47:03 -040019import android.content.Context;
Jason Monk17f3c3f2015-01-14 10:13:22 -050020import android.content.Intent;
Jason Monk07b75fe2015-05-14 16:47:03 -040021import android.telephony.SubscriptionInfo;
Sundeep Ghumand57f3242017-01-13 15:31:48 -080022
Jason Monkf668d7c2016-01-14 10:38:41 -050023import com.android.settingslib.net.DataUsageController;
Jason Monkd52356a2015-01-28 10:40:41 -050024import com.android.settingslib.wifi.AccessPoint;
Jason Monk9c7844c2017-01-18 15:21:53 -050025import com.android.systemui.DemoMode;
Jason Monk88529052016-11-04 13:29:58 -040026import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
Jason Monkd52356a2015-01-28 10:40:41 -050027
28import java.util.List;
29
Jason Monk9c7844c2017-01-18 15:21:53 -050030public interface NetworkController extends CallbackController<SignalCallback>, DemoMode {
Joe Onoratofd52b182010-11-10 18:00:52 -080031
John Spurlockaf8d6c42014-05-07 17:49:08 -040032 boolean hasMobileDataFeature();
Jason Monk88529052016-11-04 13:29:58 -040033 void addCallback(SignalCallback cb);
34 void removeCallback(SignalCallback cb);
John Spurlockaf8d6c42014-05-07 17:49:08 -040035 void setWifiEnabled(boolean enabled);
Jason Monkd2263cd2014-11-10 14:22:56 -050036 AccessPointController getAccessPointController();
Jason Monkf668d7c2016-01-14 10:38:41 -050037 DataUsageController getMobileDataController();
Jason Monk9a4ce132016-01-21 15:27:17 -050038 DataSaverController getDataSaverController();
Amin Shaikh329c8282018-03-09 14:50:59 -050039 String getMobileDataNetworkName();
Fabian Kozynskif1c32a02019-03-22 15:09:30 -040040 int getNumberSubscriptions();
Christian Robertson2e347422011-08-11 14:01:04 -070041
Jason Monk46dbfb42016-02-25 14:59:20 -050042 boolean hasVoiceCallingFeature();
43
44 void addEmergencyListener(EmergencyListener listener);
45 void removeEmergencyListener(EmergencyListener listener);
Jason Monk9c7844c2017-01-18 15:21:53 -050046 boolean hasEmergencyCryptKeeperText();
Evan Laird83c87e52019-09-24 19:14:05 -040047
Jason Monk9c7844c2017-01-18 15:21:53 -050048 boolean isRadioOn();
Jason Monk46dbfb42016-02-25 14:59:20 -050049
Jason Monk07b75fe2015-05-14 16:47:03 -040050 public interface SignalCallback {
Adrian Roos316bf542016-08-23 17:53:07 +020051 default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
Amin Shaikhe74dbdd2018-03-09 16:05:30 -050052 boolean activityIn, boolean activityOut, String description, boolean isTransient,
53 String statusLabel) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040054
Evan Laird83c87e52019-09-24 19:14:05 -040055 /**
56 * Callback for listeners to be able to update the state of any UI tracking connectivity
57 * @param statusIcon the icon that should be shown in the status bar
58 * @param qsIcon the icon to show in Quick Settings
59 * @param statusType the resId of the data type icon (e.g. LTE) to show in the status bar
60 * @param qsType similar to above, the resId of the data type icon to show in Quick Settings
61 * @param activityIn indicates whether there is inbound activity
62 * @param activityOut indicates outbound activity
63 * @param typeContentDescription the contentDescription of the data type
64 * @param typeContentDescriptionHtml the (possibly HTML-styled) contentDescription of the
65 * data type. Suitable for display
66 * @param description description of the network (usually just the network name)
67 * @param isWide //TODO: unused?
68 * @param subId subscription ID for which to update the UI
69 * @param roaming indicates roaming
70 */
Jason Monk7e6c83c2017-04-26 14:35:24 -040071 default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
Evan Laird83c87e52019-09-24 19:14:05 -040072 int qsType, boolean activityIn, boolean activityOut,
73 CharSequence typeContentDescription,
74 CharSequence typeContentDescriptionHtml, CharSequence description,
75 boolean isWide, int subId, boolean roaming) {
76 }
77
Adrian Roos316bf542016-08-23 17:53:07 +020078 default void setSubs(List<SubscriptionInfo> subs) {}
Evan Laird83c87e52019-09-24 19:14:05 -040079
Jason Monk1ff77662017-09-29 11:17:05 -040080 default void setNoSims(boolean show, boolean simDetected) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040081
Adrian Roos316bf542016-08-23 17:53:07 +020082 default void setEthernetIndicators(IconState icon) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040083
Adrian Roos316bf542016-08-23 17:53:07 +020084 default void setIsAirplaneMode(IconState icon) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040085
Adrian Roos316bf542016-08-23 17:53:07 +020086 default void setMobileDataEnabled(boolean enabled) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040087 }
88
Jason Monk46dbfb42016-02-25 14:59:20 -050089 public interface EmergencyListener {
90 void setEmergencyCallsOnly(boolean emergencyOnly);
91 }
92
Jason Monk07b75fe2015-05-14 16:47:03 -040093 public static class IconState {
94 public final boolean visible;
95 public final int icon;
96 public final String contentDescription;
97
Sundeep Ghuman9d10a3c2017-06-16 00:05:16 +000098 public IconState(boolean visible, int icon, String contentDescription) {
Jason Monk07b75fe2015-05-14 16:47:03 -040099 this.visible = visible;
100 this.icon = icon;
101 this.contentDescription = contentDescription;
102 }
103
104 public IconState(boolean visible, int icon, int contentDescription,
105 Context context) {
106 this(visible, icon, context.getString(contentDescription));
107 }
Winson Chungd63c59782012-09-05 17:34:41 -0700108 }
John Spurlock7f8f22a2014-07-02 18:54:17 -0400109
Jason Monkd2263cd2014-11-10 14:22:56 -0500110 /**
111 * Tracks changes in access points. Allows listening for changes, scanning for new APs,
112 * and connecting to new ones.
113 */
114 public interface AccessPointController {
115 void addAccessPointCallback(AccessPointCallback callback);
116 void removeAccessPointCallback(AccessPointCallback callback);
117 void scanForAccessPoints();
Jason Monkd52356a2015-01-28 10:40:41 -0500118 int getIcon(AccessPoint ap);
Jason Monkd2263cd2014-11-10 14:22:56 -0500119 boolean connect(AccessPoint ap);
120 boolean canConfigWifi();
John Spurlock7f8f22a2014-07-02 18:54:17 -0400121
Jason Monkd2263cd2014-11-10 14:22:56 -0500122 public interface AccessPointCallback {
Jason Monkd52356a2015-01-28 10:40:41 -0500123 void onAccessPointsChanged(List<AccessPoint> accessPoints);
Jason Monk17f3c3f2015-01-14 10:13:22 -0500124 void onSettingsActivityTriggered(Intent settingsIntent);
Jason Monkd2263cd2014-11-10 14:22:56 -0500125 }
John Spurlock7f8f22a2014-07-02 18:54:17 -0400126 }
Joe Onoratofd52b182010-11-10 18:00:52 -0800127}