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.Intent; 20 21 public interface NetworkController { 22 23 boolean hasMobileDataFeature(); 24 void addNetworkSignalChangedCallback(NetworkSignalChangedCallback cb); 25 void removeNetworkSignalChangedCallback(NetworkSignalChangedCallback cb); 26 void setWifiEnabled(boolean enabled); 27 void onUserSwitched(int newUserId); 28 AccessPointController getAccessPointController(); 29 MobileDataController getMobileDataController(); 30 31 public interface NetworkSignalChangedCallback { 32 void onWifiSignalChanged(boolean enabled, boolean connected, int wifiSignalIconId, 33 boolean activityIn, boolean activityOut, 34 String wifiSignalContentDescriptionId, String description); 35 void onMobileDataSignalChanged(boolean enabled, int mobileSignalIconId, 36 String mobileSignalContentDescriptionId, int dataTypeIconId, 37 boolean activityIn, boolean activityOut, 38 String dataTypeContentDescriptionId, String description, 39 boolean isDataTypeIconWide); 40 void onNoSimVisibleChanged(boolean visible); 41 void onAirplaneModeChanged(boolean enabled); 42 void onMobileDataEnabled(boolean enabled); 43 } 44 45 /** 46 * Tracks changes in access points. Allows listening for changes, scanning for new APs, 47 * and connecting to new ones. 48 */ 49 public interface AccessPointController { 50 void addAccessPointCallback(AccessPointCallback callback); 51 void removeAccessPointCallback(AccessPointCallback callback); 52 void scanForAccessPoints(); 53 boolean connect(AccessPoint ap); 54 boolean canConfigWifi(); 55 56 public interface AccessPointCallback { 57 void onAccessPointsChanged(AccessPoint[] accessPoints); 58 void onSettingsActivityTriggered(Intent settingsIntent); 59 } 60 61 public static class AccessPoint { 62 public static final int NO_NETWORK = -1; // see WifiManager 63 64 public int networkId; 65 public int iconId; 66 public String ssid; 67 public boolean isConnected; 68 public boolean isConfigured; 69 public boolean hasSecurity; 70 public int level; // 0 - 5 71 } 72 } 73 74 /** 75 * Tracks mobile data support and usage. 76 */ 77 public interface MobileDataController { 78 boolean isMobileDataSupported(); 79 boolean isMobileDataEnabled(); 80 void setMobileDataEnabled(boolean enabled); 81 DataUsageInfo getDataUsageInfo(); 82 83 public static class DataUsageInfo { 84 public String carrier; 85 public String period; 86 public long limitLevel; 87 public long warningLevel; 88 public long usageLevel; 89 } 90 } 91 } 92