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 import com.android.settingslib.net.DataUsageController; 23 import com.android.settingslib.wifi.AccessPoint; 24 25 import java.util.List; 26 27 public interface NetworkController { 28 29 boolean hasMobileDataFeature(); 30 void addSignalCallback(SignalCallback cb); 31 void removeSignalCallback(SignalCallback cb); 32 void setWifiEnabled(boolean enabled); 33 void onUserSwitched(int newUserId); 34 AccessPointController getAccessPointController(); 35 DataUsageController getMobileDataController(); 36 DataSaverController getDataSaverController(); 37 38 boolean hasVoiceCallingFeature(); 39 40 void addEmergencyListener(EmergencyListener listener); 41 void removeEmergencyListener(EmergencyListener listener); 42 43 public interface SignalCallback { 44 void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, 45 boolean activityIn, boolean activityOut, String description); 46 47 void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, 48 int qsType, boolean activityIn, boolean activityOut, String typeContentDescription, 49 String description, boolean isWide, int subId); 50 void setSubs(List<SubscriptionInfo> subs); 51 void setNoSims(boolean show); 52 53 void setEthernetIndicators(IconState icon); 54 55 void setIsAirplaneMode(IconState icon); 56 57 void setMobileDataEnabled(boolean enabled); 58 } 59 60 public interface EmergencyListener { 61 void setEmergencyCallsOnly(boolean emergencyOnly); 62 } 63 64 public static class IconState { 65 public final boolean visible; 66 public final int icon; 67 public final String contentDescription; 68 69 public IconState(boolean visible, int icon, String contentDescription) { 70 this.visible = visible; 71 this.icon = icon; 72 this.contentDescription = contentDescription; 73 } 74 75 public IconState(boolean visible, int icon, int contentDescription, 76 Context context) { 77 this(visible, icon, context.getString(contentDescription)); 78 } 79 } 80 81 /** 82 * Tracks changes in access points. Allows listening for changes, scanning for new APs, 83 * and connecting to new ones. 84 */ 85 public interface AccessPointController { 86 void addAccessPointCallback(AccessPointCallback callback); 87 void removeAccessPointCallback(AccessPointCallback callback); 88 void scanForAccessPoints(); 89 int getIcon(AccessPoint ap); 90 boolean connect(AccessPoint ap); 91 boolean canConfigWifi(); 92 93 public interface AccessPointCallback { 94 void onAccessPointsChanged(List<AccessPoint> accessPoints); 95 void onSettingsActivityTriggered(Intent settingsIntent); 96 } 97 } 98 } 99