Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 1 | /* |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 2 | * Copyright (C) 2014 The Android Open Source Project |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 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 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 19 | import android.content.Context; |
Jason Monk | 17f3c3f | 2015-01-14 10:13:22 -0500 | [diff] [blame] | 20 | import android.content.Intent; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 21 | import android.telephony.SubscriptionInfo; |
Sundeep Ghuman | d57f324 | 2017-01-13 15:31:48 -0800 | [diff] [blame] | 22 | |
Jason Monk | f668d7c | 2016-01-14 10:38:41 -0500 | [diff] [blame] | 23 | import com.android.settingslib.net.DataUsageController; |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 24 | import com.android.settingslib.wifi.AccessPoint; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 25 | import com.android.systemui.DemoMode; |
Jason Monk | 8852905 | 2016-11-04 13:29:58 -0400 | [diff] [blame] | 26 | import com.android.systemui.statusbar.policy.NetworkController.SignalCallback; |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 27 | |
| 28 | import java.util.List; |
| 29 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 30 | public interface NetworkController extends CallbackController<SignalCallback>, DemoMode { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 31 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 32 | boolean hasMobileDataFeature(); |
Jason Monk | 8852905 | 2016-11-04 13:29:58 -0400 | [diff] [blame] | 33 | void addCallback(SignalCallback cb); |
| 34 | void removeCallback(SignalCallback cb); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 35 | void setWifiEnabled(boolean enabled); |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 36 | AccessPointController getAccessPointController(); |
Jason Monk | f668d7c | 2016-01-14 10:38:41 -0500 | [diff] [blame] | 37 | DataUsageController getMobileDataController(); |
Jason Monk | 9a4ce13 | 2016-01-21 15:27:17 -0500 | [diff] [blame] | 38 | DataSaverController getDataSaverController(); |
Amin Shaikh | 329c828 | 2018-03-09 14:50:59 -0500 | [diff] [blame] | 39 | String getMobileDataNetworkName(); |
Fabian Kozynski | f1c32a0 | 2019-03-22 15:09:30 -0400 | [diff] [blame] | 40 | int getNumberSubscriptions(); |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 41 | |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 42 | boolean hasVoiceCallingFeature(); |
| 43 | |
| 44 | void addEmergencyListener(EmergencyListener listener); |
| 45 | void removeEmergencyListener(EmergencyListener listener); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 46 | boolean hasEmergencyCryptKeeperText(); |
Evan Laird | 83c87e5 | 2019-09-24 19:14:05 -0400 | [diff] [blame] | 47 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 48 | boolean isRadioOn(); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 49 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 50 | public interface SignalCallback { |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 51 | default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, |
Amin Shaikh | e74dbdd | 2018-03-09 16:05:30 -0500 | [diff] [blame] | 52 | boolean activityIn, boolean activityOut, String description, boolean isTransient, |
| 53 | String statusLabel) {} |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 54 | |
Evan Laird | 83c87e5 | 2019-09-24 19:14:05 -0400 | [diff] [blame] | 55 | /** |
| 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 Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 71 | default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, |
Evan Laird | 83c87e5 | 2019-09-24 19:14:05 -0400 | [diff] [blame] | 72 | int qsType, boolean activityIn, boolean activityOut, |
| 73 | CharSequence typeContentDescription, |
| 74 | CharSequence typeContentDescriptionHtml, CharSequence description, |
| 75 | boolean isWide, int subId, boolean roaming) { |
| 76 | } |
| 77 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 78 | default void setSubs(List<SubscriptionInfo> subs) {} |
Evan Laird | 83c87e5 | 2019-09-24 19:14:05 -0400 | [diff] [blame] | 79 | |
Jason Monk | 1ff7766 | 2017-09-29 11:17:05 -0400 | [diff] [blame] | 80 | default void setNoSims(boolean show, boolean simDetected) {} |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 81 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 82 | default void setEthernetIndicators(IconState icon) {} |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 83 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 84 | default void setIsAirplaneMode(IconState icon) {} |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 85 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 86 | default void setMobileDataEnabled(boolean enabled) {} |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 87 | } |
| 88 | |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 89 | public interface EmergencyListener { |
| 90 | void setEmergencyCallsOnly(boolean emergencyOnly); |
| 91 | } |
| 92 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 93 | public static class IconState { |
| 94 | public final boolean visible; |
| 95 | public final int icon; |
| 96 | public final String contentDescription; |
| 97 | |
Sundeep Ghuman | 9d10a3c | 2017-06-16 00:05:16 +0000 | [diff] [blame] | 98 | public IconState(boolean visible, int icon, String contentDescription) { |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 99 | 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 Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 108 | } |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 109 | |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 110 | /** |
| 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 Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 118 | int getIcon(AccessPoint ap); |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 119 | boolean connect(AccessPoint ap); |
| 120 | boolean canConfigWifi(); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 121 | |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 122 | public interface AccessPointCallback { |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 123 | void onAccessPointsChanged(List<AccessPoint> accessPoints); |
Jason Monk | 17f3c3f | 2015-01-14 10:13:22 -0500 | [diff] [blame] | 124 | void onSettingsActivityTriggered(Intent settingsIntent); |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 125 | } |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 126 | } |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 127 | } |