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