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(); 39 hasVoiceCallingFeature()40 boolean hasVoiceCallingFeature(); 41 addEmergencyListener(EmergencyListener listener)42 void addEmergencyListener(EmergencyListener listener); removeEmergencyListener(EmergencyListener listener)43 void removeEmergencyListener(EmergencyListener listener); hasEmergencyCryptKeeperText()44 boolean hasEmergencyCryptKeeperText(); isRadioOn()45 boolean isRadioOn(); 46 47 public interface SignalCallback { setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, boolean activityIn, boolean activityOut, String description, boolean isTransient)48 default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon, 49 boolean activityIn, boolean activityOut, String description, boolean isTransient) {} 50 setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType, int qsType, boolean activityIn, boolean activityOut, String typeContentDescription, String description, boolean isWide, int subId, boolean roaming)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) {} setSubs(List<SubscriptionInfo> subs)54 default void setSubs(List<SubscriptionInfo> subs) {} setNoSims(boolean show, boolean simDetected)55 default void setNoSims(boolean show, boolean simDetected) {} 56 setEthernetIndicators(IconState icon)57 default void setEthernetIndicators(IconState icon) {} 58 setIsAirplaneMode(IconState icon)59 default void setIsAirplaneMode(IconState icon) {} 60 setMobileDataEnabled(boolean enabled)61 default void setMobileDataEnabled(boolean enabled) {} 62 } 63 64 public interface EmergencyListener { setEmergencyCallsOnly(boolean emergencyOnly)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 IconState(boolean visible, int icon, String contentDescription)73 public IconState(boolean visible, int icon, String contentDescription) { 74 this.visible = visible; 75 this.icon = icon; 76 this.contentDescription = contentDescription; 77 } 78 IconState(boolean visible, int icon, int contentDescription, Context context)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 { addAccessPointCallback(AccessPointCallback callback)90 void addAccessPointCallback(AccessPointCallback callback); removeAccessPointCallback(AccessPointCallback callback)91 void removeAccessPointCallback(AccessPointCallback callback); scanForAccessPoints()92 void scanForAccessPoints(); getIcon(AccessPoint ap)93 int getIcon(AccessPoint ap); connect(AccessPoint ap)94 boolean connect(AccessPoint ap); canConfigWifi()95 boolean canConfigWifi(); 96 97 public interface AccessPointCallback { onAccessPointsChanged(List<AccessPoint> accessPoints)98 void onAccessPointsChanged(List<AccessPoint> accessPoints); onSettingsActivityTriggered(Intent settingsIntent)99 void onSettingsActivityTriggered(Intent settingsIntent); 100 } 101 } 102 } 103