blob: 71db618d607635a543a2b3d993ba03b683e49fbb [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();
47 boolean isRadioOn();
Jason Monk46dbfb42016-02-25 14:59:20 -050048
Jason Monk07b75fe2015-05-14 16:47:03 -040049 public interface SignalCallback {
Adrian Roos316bf542016-08-23 17:53:07 +020050 default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
Amin Shaikhe74dbdd2018-03-09 16:05:30 -050051 boolean activityIn, boolean activityOut, String description, boolean isTransient,
52 String statusLabel) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040053
Jason Monk7e6c83c2017-04-26 14:35:24 -040054 default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
55 int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
56 String description, boolean isWide, int subId, boolean roaming) {}
Adrian Roos316bf542016-08-23 17:53:07 +020057 default void setSubs(List<SubscriptionInfo> subs) {}
Jason Monk1ff77662017-09-29 11:17:05 -040058 default void setNoSims(boolean show, boolean simDetected) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040059
Adrian Roos316bf542016-08-23 17:53:07 +020060 default void setEthernetIndicators(IconState icon) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040061
Adrian Roos316bf542016-08-23 17:53:07 +020062 default void setIsAirplaneMode(IconState icon) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040063
Adrian Roos316bf542016-08-23 17:53:07 +020064 default void setMobileDataEnabled(boolean enabled) {}
Jason Monk07b75fe2015-05-14 16:47:03 -040065 }
66
Jason Monk46dbfb42016-02-25 14:59:20 -050067 public interface EmergencyListener {
68 void setEmergencyCallsOnly(boolean emergencyOnly);
69 }
70
Jason Monk07b75fe2015-05-14 16:47:03 -040071 public static class IconState {
72 public final boolean visible;
73 public final int icon;
74 public final String contentDescription;
75
Sundeep Ghuman9d10a3c2017-06-16 00:05:16 +000076 public IconState(boolean visible, int icon, String contentDescription) {
Jason Monk07b75fe2015-05-14 16:47:03 -040077 this.visible = visible;
78 this.icon = icon;
79 this.contentDescription = contentDescription;
80 }
81
82 public IconState(boolean visible, int icon, int contentDescription,
83 Context context) {
84 this(visible, icon, context.getString(contentDescription));
85 }
Winson Chungd63c59782012-09-05 17:34:41 -070086 }
John Spurlock7f8f22a2014-07-02 18:54:17 -040087
Jason Monkd2263cd2014-11-10 14:22:56 -050088 /**
89 * Tracks changes in access points. Allows listening for changes, scanning for new APs,
90 * and connecting to new ones.
91 */
92 public interface AccessPointController {
93 void addAccessPointCallback(AccessPointCallback callback);
94 void removeAccessPointCallback(AccessPointCallback callback);
95 void scanForAccessPoints();
Jason Monkd52356a2015-01-28 10:40:41 -050096 int getIcon(AccessPoint ap);
Jason Monkd2263cd2014-11-10 14:22:56 -050097 boolean connect(AccessPoint ap);
98 boolean canConfigWifi();
John Spurlock7f8f22a2014-07-02 18:54:17 -040099
Jason Monkd2263cd2014-11-10 14:22:56 -0500100 public interface AccessPointCallback {
Jason Monkd52356a2015-01-28 10:40:41 -0500101 void onAccessPointsChanged(List<AccessPoint> accessPoints);
Jason Monk17f3c3f2015-01-14 10:13:22 -0500102 void onSettingsActivityTriggered(Intent settingsIntent);
Jason Monkd2263cd2014-11-10 14:22:56 -0500103 }
John Spurlock7f8f22a2014-07-02 18:54:17 -0400104 }
Joe Onoratofd52b182010-11-10 18:00:52 -0800105}