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