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 
     40     boolean hasVoiceCallingFeature();
     41 
     42     void addEmergencyListener(EmergencyListener listener);
     43     void removeEmergencyListener(EmergencyListener listener);
     44     boolean hasEmergencyCryptKeeperText();
     45     boolean isRadioOn();
     46 
     47     public interface SignalCallback {
     48         default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
     49                 boolean activityIn, boolean activityOut, String description, boolean isTransient) {}
     50 
     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) {}
     54         default void setSubs(List<SubscriptionInfo> subs) {}
     55         default void setNoSims(boolean show) {}
     56 
     57         default void setEthernetIndicators(IconState icon) {}
     58 
     59         default void setIsAirplaneMode(IconState icon) {}
     60 
     61         default void setMobileDataEnabled(boolean enabled) {}
     62     }
     63 
     64     public interface EmergencyListener {
     65         void setEmergencyCallsOnly(boolean emergencyOnly);
     66     }
     67 
     68     public static class IconState {
     69         public final boolean visible;
     70 
     71         public final int icon;
     72 
     73         /**
     74          * Optional iconOverlay resource id.
     75          *
     76          * <p>Set to -1 if not present.
     77          */
     78         public final int iconOverlay;
     79 
     80         public final String contentDescription;
     81 
     82         public IconState(boolean visible, int icon, int iconOverlay, String contentDescription) {
     83             this.visible = visible;
     84             this.icon = icon;
     85             this.iconOverlay = iconOverlay;
     86             this.contentDescription = contentDescription;
     87         }
     88 
     89         public IconState(boolean visible, int icon, String contentDescription) {
     90             this(visible, icon, -1 /* iconOverlay */, contentDescription);
     91         }
     92 
     93         public IconState(boolean visible, int icon, int contentDescription,
     94                 Context context) {
     95             this(visible, icon, context.getString(contentDescription));
     96         }
     97     }
     98 
     99     /**
    100      * Tracks changes in access points.  Allows listening for changes, scanning for new APs,
    101      * and connecting to new ones.
    102      */
    103     public interface AccessPointController {
    104         void addAccessPointCallback(AccessPointCallback callback);
    105         void removeAccessPointCallback(AccessPointCallback callback);
    106         void scanForAccessPoints();
    107         int getIcon(AccessPoint ap);
    108         boolean connect(AccessPoint ap);
    109         boolean canConfigWifi();
    110 
    111         public interface AccessPointCallback {
    112             void onAccessPointsChanged(List<AccessPoint> accessPoints);
    113             void onSettingsActivityTriggered(Intent settingsIntent);
    114         }
    115     }
    116 }
    117