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(); getNumberSubscriptions()40 int getNumberSubscriptions(); 41 hasVoiceCallingFeature()42 boolean hasVoiceCallingFeature(); 43 addEmergencyListener(EmergencyListener listener)44 void addEmergencyListener(EmergencyListener listener); removeEmergencyListener(EmergencyListener listener)45 void removeEmergencyListener(EmergencyListener listener); hasEmergencyCryptKeeperText()46 boolean hasEmergencyCryptKeeperText(); 47 isRadioOn()48 boolean isRadioOn(); 49 50 public interface SignalCallback { setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, boolean activityIn, boolean activityOut, String description, boolean isTransient, String statusLabel)51 default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, 52 boolean activityIn, boolean activityOut, String description, boolean isTransient, 53 String statusLabel) {} 54 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 */ 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)71 default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, 72 int qsType, boolean activityIn, boolean activityOut, 73 CharSequence typeContentDescription, 74 CharSequence typeContentDescriptionHtml, CharSequence description, 75 boolean isWide, int subId, boolean roaming) { 76 } 77 setSubs(List<SubscriptionInfo> subs)78 default void setSubs(List<SubscriptionInfo> subs) {} 79 setNoSims(boolean show, boolean simDetected)80 default void setNoSims(boolean show, boolean simDetected) {} 81 setEthernetIndicators(IconState icon)82 default void setEthernetIndicators(IconState icon) {} 83 setIsAirplaneMode(IconState icon)84 default void setIsAirplaneMode(IconState icon) {} 85 setMobileDataEnabled(boolean enabled)86 default void setMobileDataEnabled(boolean enabled) {} 87 } 88 89 public interface EmergencyListener { setEmergencyCallsOnly(boolean emergencyOnly)90 void setEmergencyCallsOnly(boolean emergencyOnly); 91 } 92 93 public static class IconState { 94 public final boolean visible; 95 public final int icon; 96 public final String contentDescription; 97 IconState(boolean visible, int icon, String contentDescription)98 public IconState(boolean visible, int icon, String contentDescription) { 99 this.visible = visible; 100 this.icon = icon; 101 this.contentDescription = contentDescription; 102 } 103 IconState(boolean visible, int icon, int contentDescription, Context context)104 public IconState(boolean visible, int icon, int contentDescription, 105 Context context) { 106 this(visible, icon, context.getString(contentDescription)); 107 } 108 } 109 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 { addAccessPointCallback(AccessPointCallback callback)115 void addAccessPointCallback(AccessPointCallback callback); removeAccessPointCallback(AccessPointCallback callback)116 void removeAccessPointCallback(AccessPointCallback callback); scanForAccessPoints()117 void scanForAccessPoints(); getIcon(AccessPoint ap)118 int getIcon(AccessPoint ap); connect(AccessPoint ap)119 boolean connect(AccessPoint ap); canConfigWifi()120 boolean canConfigWifi(); 121 122 public interface AccessPointCallback { onAccessPointsChanged(List<AccessPoint> accessPoints)123 void onAccessPointsChanged(List<AccessPoint> accessPoints); onSettingsActivityTriggered(Intent settingsIntent)124 void onSettingsActivityTriggered(Intent settingsIntent); 125 } 126 } 127 } 128