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
17package com.android.systemui.statusbar.policy;
18
19import android.content.Context;
20import android.content.Intent;
21import android.telephony.SubscriptionInfo;
22
23import com.android.settingslib.wifi.AccessPoint;
24
25import java.util.List;
26
27public 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    MobileDataController getMobileDataController();
36
37    public interface SignalCallback {
38        void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
39                boolean activityIn, boolean activityOut, String description);
40
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);
44        void setSubs(List<SubscriptionInfo> subs);
45        void setNoSims(boolean show);
46
47        void setEthernetIndicators(IconState icon);
48
49        void setIsAirplaneMode(IconState icon);
50
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
59        public IconState(boolean visible, int icon, String contentDescription) {
60            this.visible = visible;
61            this.icon = icon;
62            this.contentDescription = contentDescription;
63        }
64
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 {
76        void addAccessPointCallback(AccessPointCallback callback);
77        void removeAccessPointCallback(AccessPointCallback callback);
78        void scanForAccessPoints();
79        int getIcon(AccessPoint ap);
80        boolean connect(AccessPoint ap);
81        boolean canConfigWifi();
82
83        public interface AccessPointCallback {
84            void onAccessPointsChanged(List<AccessPoint> accessPoints);
85            void onSettingsActivityTriggered(Intent settingsIntent);
86        }
87    }
88
89    /**
90     * Tracks mobile data support and usage.
91     */
92    public interface MobileDataController {
93        boolean isMobileDataSupported();
94        boolean isMobileDataEnabled();
95        void setMobileDataEnabled(boolean enabled);
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