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