Merge changes I61c32c74,I505c9b04,I5c19e6a8,I24e86a75 into sc-qpr1-dev
* changes: [Provider Model] Support 2+ lines instead of marque for Mobile data and Wi-Fi [Provider Model] Fix WiFi SSID disappear issue [Provider Model] Enforce DISALLOW_CONFIG_WIFI in Internet Panel [Provider Model] Correct Wi-Fi toggle title color in Dark Theme
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
style="@style/Widget.SliceView.Panel"
|
style="@style/Widget.SliceView.Panel"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@@ -101,8 +101,8 @@
|
|||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
android:layout_marginEnd="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:paddingStart="22dp"
|
android:paddingStart="22dp"
|
||||||
android:paddingEnd="22dp">
|
android:paddingEnd="22dp">
|
||||||
|
|
||||||
@@ -130,24 +130,24 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mobile_title"
|
android:id="@+id/mobile_title"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
|
android:layout_marginEnd="7dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mobile_summary"
|
android:id="@+id/mobile_summary"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
|
android:layout_marginEnd="34dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
@@ -179,8 +179,8 @@
|
|||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
android:layout_marginEnd="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:paddingStart="22dp"
|
android:paddingStart="22dp"
|
||||||
android:paddingEnd="22dp">
|
android:paddingEnd="22dp">
|
||||||
|
|
||||||
@@ -191,6 +191,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/wifi_toggle_title"
|
||||||
android:text="@string/turn_on_wifi"
|
android:text="@string/turn_on_wifi"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -229,10 +230,10 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
android:layout_marginEnd="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:paddingStart="22dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="22dp">
|
android:paddingEnd="24dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -247,12 +248,13 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_weight="3"
|
|
||||||
android:id="@+id/wifi_connected_list"
|
android:id="@+id/wifi_connected_list"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="72dp"
|
android:layout_height="72dp"
|
||||||
|
android:layout_marginEnd="30dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:gravity="start|center_vertical">
|
android:gravity="start|center_vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_connected_title"
|
android:id="@+id/wifi_connected_title"
|
||||||
@@ -260,9 +262,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
@@ -272,9 +273,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
@@ -283,14 +283,14 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginEnd="5dp"
|
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/wifi_settings_icon"
|
android:id="@+id/wifi_settings_icon"
|
||||||
android:src="@drawable/ic_settings_24dp"
|
android:src="@drawable/ic_settings_24dp"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="end|center_vertical"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginStart="16dp">
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/arrow_forward"
|
android:id="@+id/arrow_forward"
|
||||||
android:src="@drawable/ic_arrow_forward"
|
android:src="@drawable/ic_arrow_forward"
|
||||||
@@ -337,7 +337,7 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginStart="16dp">
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin">
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/see_all_networks"
|
android:text="@string/see_all_networks"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
|
|||||||
@@ -31,15 +31,14 @@
|
|||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingStart="22dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="22dp">
|
android:paddingEnd="40dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginStart="16dp">
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/wifi_icon"
|
android:id="@+id/wifi_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -48,52 +47,47 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_weight="3"
|
|
||||||
android:id="@+id/wifi_network_layout"
|
android:id="@+id/wifi_network_layout"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="72dp">
|
android:layout_height="72dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:layout_marginStart="@dimen/internet_dialog_network_layout_margin">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_title"
|
android:id="@+id/wifi_title"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="20dp"
|
||||||
android:layout_gravity="center_vertical|start"
|
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"
|
||||||
|
android:layout_marginEnd="18dp"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_summary"
|
android:id="@+id/wifi_summary"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="20dp"
|
||||||
android:layout_gravity="center_vertical|start"
|
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"
|
||||||
|
android:layout_marginEnd="18dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginEnd="@dimen/settingslib_switchbar_padding_right"
|
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center">
|
android:layout_gravity="end|center_vertical">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/wifi_locked_icon"
|
android:id="@+id/wifi_locked_icon"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -95,4 +95,7 @@
|
|||||||
<dimen name="controls_top_margin">24dp</dimen>
|
<dimen name="controls_top_margin">24dp</dimen>
|
||||||
|
|
||||||
<dimen name="global_actions_grid_item_layout_height">80dp</dimen>
|
<dimen name="global_actions_grid_item_layout_height">80dp</dimen>
|
||||||
|
|
||||||
|
<!-- Internet panel related dimensions -->
|
||||||
|
<dimen name="internet_dialog_list_max_width">624dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1594,15 +1594,16 @@
|
|||||||
<!-- Internet panel related dimensions -->
|
<!-- Internet panel related dimensions -->
|
||||||
<dimen name="internet_dialog_list_margin">12dp</dimen>
|
<dimen name="internet_dialog_list_margin">12dp</dimen>
|
||||||
<dimen name="internet_dialog_list_max_height">646dp</dimen>
|
<dimen name="internet_dialog_list_max_height">646dp</dimen>
|
||||||
<dimen name="internet_dialog_list_max_width">412dp</dimen>
|
<dimen name="internet_dialog_list_max_width">@dimen/match_parent</dimen>
|
||||||
|
|
||||||
<!-- Signal icon in internet dialog -->
|
<!-- Signal icon in internet dialog -->
|
||||||
<dimen name="signal_strength_icon_size">24dp</dimen>
|
<dimen name="signal_strength_icon_size">24dp</dimen>
|
||||||
|
|
||||||
<!-- Internet dialog related dimensions -->
|
<!-- Internet dialog related dimensions -->
|
||||||
<dimen name="internet_dialog_corner_radius">24dp</dimen>
|
<dimen name="internet_dialog_corner_radius">24dp</dimen>
|
||||||
|
<!-- End margin of network layout -->
|
||||||
<!-- Size of internet dialog -->
|
<dimen name="internet_dialog_network_layout_margin">16dp</dimen>
|
||||||
|
<!-- Size of switch bar in internet dialog -->
|
||||||
<dimen name="settingslib_switchbar_margin">16dp</dimen>
|
<dimen name="settingslib_switchbar_margin">16dp</dimen>
|
||||||
<!-- Minimum width of switch -->
|
<!-- Minimum width of switch -->
|
||||||
<dimen name="settingslib_min_switch_width">52dp</dimen>
|
<dimen name="settingslib_min_switch_width">52dp</dimen>
|
||||||
|
|||||||
@@ -122,8 +122,9 @@ public class InternetTile extends QSTileImpl<SignalState> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleClick(@Nullable View view) {
|
protected void handleClick(@Nullable View view) {
|
||||||
boolean canConfigMobileData = mAccessPointController.canConfigMobileData();
|
mHandler.post(() -> mInternetDialogFactory.create(true,
|
||||||
mHandler.post(() -> mInternetDialogFactory.create(true, canConfigMobileData));
|
mAccessPointController.canConfigMobileData(),
|
||||||
|
mAccessPointController.canConfigWifi()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.content.Intent;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -34,6 +33,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
@@ -43,7 +43,6 @@ import com.android.wifitrackerlib.WifiEntry;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for showing Wi-Fi networks.
|
* Adapter for showing Wi-Fi networks.
|
||||||
@@ -54,9 +53,10 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
private static final String ACTION_WIFI_DIALOG = "com.android.settings.WIFI_DIALOG";
|
private static final String ACTION_WIFI_DIALOG = "com.android.settings.WIFI_DIALOG";
|
||||||
private static final String EXTRA_CHOSEN_WIFI_ENTRY_KEY = "key_chosen_wifientry_key";
|
private static final String EXTRA_CHOSEN_WIFI_ENTRY_KEY = "key_chosen_wifientry_key";
|
||||||
private static final String EXTRA_CONNECT_FOR_CALLER = "connect_for_caller";
|
private static final String EXTRA_CONNECT_FOR_CALLER = "connect_for_caller";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
|
||||||
|
|
||||||
private final InternetDialogController mInternetDialogController;
|
private final InternetDialogController mInternetDialogController;
|
||||||
|
private List<WifiEntry> mWifiEntries;
|
||||||
|
private int mWifiEntriesCount;
|
||||||
|
|
||||||
protected View mHolderView;
|
protected View mHolderView;
|
||||||
protected Context mContext;
|
protected Context mContext;
|
||||||
@@ -76,54 +76,31 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull InternetViewHolder viewHolder, int position) {
|
public void onBindViewHolder(@NonNull InternetViewHolder viewHolder, int position) {
|
||||||
List<WifiEntry> wifiList = getWifiEntryList();
|
if (mWifiEntries == null || position >= mWifiEntriesCount) {
|
||||||
if (wifiList != null && wifiList.size() != 0) {
|
return;
|
||||||
int count = getItemCount();
|
|
||||||
if (wifiList.size() > count) {
|
|
||||||
wifiList = getWifiEntryList().subList(0, count - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position < wifiList.size()) {
|
|
||||||
viewHolder.onBind(wifiList.get(position));
|
|
||||||
}
|
|
||||||
} else if (DEBUG) {
|
|
||||||
Log.d(TAG, "onBindViewHolder, Wi-Fi entry list = null");
|
|
||||||
}
|
}
|
||||||
}
|
viewHolder.onBind(mWifiEntries.get(position));
|
||||||
|
|
||||||
private List<WifiEntry> getWifiEntryList() {
|
|
||||||
if (mInternetDialogController.getWifiEntryList() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mInternetDialogController.getWifiEntryList().stream()
|
|
||||||
.filter(wifiEntry -> (!wifiEntry.isDefaultNetwork()
|
|
||||||
|| !wifiEntry.hasInternetAccess()))
|
|
||||||
.limit(getItemCount())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The total number of networks (mobile network and entries of Wi-Fi) should be four in
|
* Updates the Wi-Fi networks.
|
||||||
* {@link InternetDialog}.
|
|
||||||
*
|
*
|
||||||
* Airplane mode is ON (mobile network is gone):
|
* @param wifiEntries the updated Wi-Fi entries.
|
||||||
* Return four Wi-Fi's entries if no internet Wi-Fi.
|
* @param wifiEntriesCount the total number of Wi-Fi entries.
|
||||||
* Return three Wi-Fi's entries if one internet Wi-Fi.
|
*/
|
||||||
* Airplane mode is OFF (mobile network is visible):
|
public void setWifiEntries(@Nullable List<WifiEntry> wifiEntries, int wifiEntriesCount) {
|
||||||
* Return three Wi-Fi's entries if no internet Wi-Fi.
|
mWifiEntries = wifiEntries;
|
||||||
* Return two Wi-Fi's entries if one internet Wi-Fi.
|
mWifiEntriesCount = wifiEntriesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total number of Wi-Fi networks.
|
||||||
*
|
*
|
||||||
* @return The total number of networks.
|
* @return The total number of Wi-Fi entries.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
final boolean hasInternetWifi = mInternetDialogController.getInternetWifiEntry() != null;
|
return mWifiEntriesCount;
|
||||||
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
|
||||||
return hasInternetWifi ? 3 : 4;
|
|
||||||
} else {
|
|
||||||
return hasInternetWifi ? 2 : 3;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,18 +175,18 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
mWifiNetworkLayout.setVisibility(View.VISIBLE);
|
mWifiNetworkLayout.setVisibility(View.VISIBLE);
|
||||||
mWifiTitleText.setText(title);
|
mWifiTitleText.setText(title);
|
||||||
if (TextUtils.isEmpty(summary)) {
|
if (TextUtils.isEmpty(summary)) {
|
||||||
mWifiTitleText.setGravity(Gravity.CENTER);
|
|
||||||
mWifiSummaryText.setVisibility(View.GONE);
|
mWifiSummaryText.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
mWifiTitleText.setGravity(Gravity.BOTTOM);
|
|
||||||
mWifiSummaryText.setGravity(Gravity.TOP);
|
|
||||||
mWifiSummaryText.setVisibility(View.VISIBLE);
|
mWifiSummaryText.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
mWifiSummaryText.setText(summary);
|
mWifiSummaryText.setText(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable getWifiDrawable(@NonNull WifiEntry wifiEntry) throws Throwable {
|
Drawable getWifiDrawable(@NonNull WifiEntry wifiEntry) throws Throwable {
|
||||||
|
if (wifiEntry.getLevel() == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final Drawable drawable = mWifiIconInjector.getIcon(wifiEntry.shouldShowXLevelIcon(),
|
final Drawable drawable = mWifiIconInjector.getIcon(wifiEntry.shouldShowXLevelIcon(),
|
||||||
wifiEntry.getLevel());
|
wifiEntry.getLevel());
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ import static com.android.systemui.Prefs.Key.QS_HAS_TURNED_OFF_MOBILE_DATA;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Network;
|
import android.net.Network;
|
||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.wifi.ScanResult;
|
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -51,11 +49,12 @@ import android.widget.Button;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Space;
|
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.annotation.WorkerThread;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected View mDialogView;
|
protected View mDialogView;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected WifiEntry mConnectedWifiEntry;
|
protected boolean mCanConfigWifi;
|
||||||
|
|
||||||
private InternetDialogFactory mInternetDialogFactory;
|
private InternetDialogFactory mInternetDialogFactory;
|
||||||
private SubscriptionManager mSubscriptionManager;
|
private SubscriptionManager mSubscriptionManager;
|
||||||
@@ -105,12 +104,14 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private TextView mInternetDialogSubTitle;
|
private TextView mInternetDialogSubTitle;
|
||||||
private View mDivider;
|
private View mDivider;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
private LinearLayout mInternetDialogLayout;
|
||||||
private LinearLayout mInternetListLayout;
|
private LinearLayout mInternetListLayout;
|
||||||
private LinearLayout mConnectedWifListLayout;
|
private LinearLayout mConnectedWifListLayout;
|
||||||
private LinearLayout mConnectedWifList;
|
private LinearLayout mConnectedWifList;
|
||||||
private LinearLayout mMobileNetworkLayout;
|
private LinearLayout mMobileNetworkLayout;
|
||||||
private LinearLayout mMobileNetworkList;
|
private LinearLayout mMobileNetworkList;
|
||||||
private LinearLayout mTurnWifiOnLayout;
|
private LinearLayout mTurnWifiOnLayout;
|
||||||
|
private TextView mWifiToggleTitleText;
|
||||||
private LinearLayout mSeeAllLayout;
|
private LinearLayout mSeeAllLayout;
|
||||||
private RecyclerView mWifiRecyclerView;
|
private RecyclerView mWifiRecyclerView;
|
||||||
private ImageView mConnectedWifiIcon;
|
private ImageView mConnectedWifiIcon;
|
||||||
@@ -125,10 +126,14 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private Button mDoneButton;
|
private Button mDoneButton;
|
||||||
private Drawable mBackgroundOn;
|
private Drawable mBackgroundOn;
|
||||||
private int mListMaxHeight;
|
private int mListMaxHeight;
|
||||||
private int mListMaxWidth;
|
private int mLayoutWidth;
|
||||||
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
private boolean mCanConfigMobileData;
|
private boolean mCanConfigMobileData;
|
||||||
|
|
||||||
|
// Wi-Fi entries
|
||||||
|
protected WifiEntry mConnectedWifiEntry;
|
||||||
|
protected int mWifiEntriesCount;
|
||||||
|
|
||||||
// Wi-Fi scanning progress bar
|
// Wi-Fi scanning progress bar
|
||||||
protected boolean mIsProgressBarVisible;
|
protected boolean mIsProgressBarVisible;
|
||||||
protected boolean mIsSearchingHidden;
|
protected boolean mIsSearchingHidden;
|
||||||
@@ -142,16 +147,17 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
|
|
||||||
private final ViewTreeObserver.OnGlobalLayoutListener mInternetListLayoutListener = () -> {
|
private final ViewTreeObserver.OnGlobalLayoutListener mInternetListLayoutListener = () -> {
|
||||||
// Set max height for list
|
// Set max height for list
|
||||||
if (mInternetListLayout.getHeight() > mListMaxHeight) {
|
if (mInternetDialogLayout.getHeight() > mListMaxHeight) {
|
||||||
ViewGroup.LayoutParams params = mInternetListLayout.getLayoutParams();
|
ViewGroup.LayoutParams params = mInternetDialogLayout.getLayoutParams();
|
||||||
params.height = mListMaxHeight;
|
params.height = mListMaxHeight;
|
||||||
mInternetListLayout.setLayoutParams(params);
|
mInternetDialogLayout.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public InternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
public InternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
||||||
InternetDialogController internetDialogController, boolean canConfigMobileData,
|
InternetDialogController internetDialogController, boolean canConfigMobileData,
|
||||||
boolean aboveStatusBar, UiEventLogger uiEventLogger, @Main Handler handler) {
|
boolean canConfigWifi, boolean aboveStatusBar, UiEventLogger uiEventLogger,
|
||||||
|
@Main Handler handler) {
|
||||||
super(context, R.style.Theme_SystemUI_Dialog_Internet);
|
super(context, R.style.Theme_SystemUI_Dialog_Internet);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Init InternetDialog");
|
Log.d(TAG, "Init InternetDialog");
|
||||||
@@ -165,6 +171,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mTelephonyManager = mInternetDialogController.getTelephonyManager();
|
mTelephonyManager = mInternetDialogController.getTelephonyManager();
|
||||||
mWifiManager = mInternetDialogController.getWifiManager();
|
mWifiManager = mInternetDialogController.getWifiManager();
|
||||||
mCanConfigMobileData = canConfigMobileData;
|
mCanConfigMobileData = canConfigMobileData;
|
||||||
|
mCanConfigWifi = canConfigWifi;
|
||||||
|
|
||||||
mLayoutManager = new LinearLayoutManager(mContext) {
|
mLayoutManager = new LinearLayoutManager(mContext) {
|
||||||
@Override
|
@Override
|
||||||
@@ -174,7 +181,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
};
|
};
|
||||||
mListMaxHeight = context.getResources().getDimensionPixelSize(
|
mListMaxHeight = context.getResources().getDimensionPixelSize(
|
||||||
R.dimen.internet_dialog_list_max_height);
|
R.dimen.internet_dialog_list_max_height);
|
||||||
mListMaxWidth = context.getResources().getDimensionPixelSize(
|
mLayoutWidth = context.getResources().getDimensionPixelSize(
|
||||||
R.dimen.internet_dialog_list_max_width);
|
R.dimen.internet_dialog_list_max_width);
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mAdapter = new InternetAdapter(mInternetDialogController);
|
mAdapter = new InternetAdapter(mInternetDialogController);
|
||||||
@@ -202,11 +209,14 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
layoutParams.setFitInsetsIgnoringVisibility(true);
|
layoutParams.setFitInsetsIgnoringVisibility(true);
|
||||||
window.setAttributes(layoutParams);
|
window.setAttributes(layoutParams);
|
||||||
window.setContentView(mDialogView);
|
window.setContentView(mDialogView);
|
||||||
window.setLayout(mListMaxWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
|
//Only fix the width for large screen or tablet.
|
||||||
|
window.setLayout(mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.internet_dialog_list_max_width), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
window.setWindowAnimations(R.style.Animation_InternetDialog);
|
window.setWindowAnimations(R.style.Animation_InternetDialog);
|
||||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
window.addFlags(FLAG_LAYOUT_NO_LIMITS);
|
window.addFlags(FLAG_LAYOUT_NO_LIMITS);
|
||||||
|
|
||||||
|
mInternetDialogLayout = mDialogView.requireViewById(R.id.internet_connectivity_dialog);
|
||||||
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
||||||
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
||||||
mDivider = mDialogView.requireViewById(R.id.divider);
|
mDivider = mDialogView.requireViewById(R.id.divider);
|
||||||
@@ -215,6 +225,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout);
|
mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout);
|
||||||
mMobileNetworkList = mDialogView.requireViewById(R.id.mobile_network_list);
|
mMobileNetworkList = mDialogView.requireViewById(R.id.mobile_network_list);
|
||||||
mTurnWifiOnLayout = mDialogView.requireViewById(R.id.turn_on_wifi_layout);
|
mTurnWifiOnLayout = mDialogView.requireViewById(R.id.turn_on_wifi_layout);
|
||||||
|
mWifiToggleTitleText = mDialogView.requireViewById(R.id.wifi_toggle_title);
|
||||||
mConnectedWifListLayout = mDialogView.requireViewById(R.id.wifi_connected_layout);
|
mConnectedWifListLayout = mDialogView.requireViewById(R.id.wifi_connected_layout);
|
||||||
mConnectedWifList = mDialogView.requireViewById(R.id.wifi_connected_list);
|
mConnectedWifList = mDialogView.requireViewById(R.id.wifi_connected_list);
|
||||||
mConnectedWifiIcon = mDialogView.requireViewById(R.id.wifi_connected_icon);
|
mConnectedWifiIcon = mDialogView.requireViewById(R.id.wifi_connected_icon);
|
||||||
@@ -230,7 +241,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mMobileDataToggle = mDialogView.requireViewById(R.id.mobile_toggle);
|
mMobileDataToggle = mDialogView.requireViewById(R.id.mobile_toggle);
|
||||||
mWiFiToggle = mDialogView.requireViewById(R.id.wifi_toggle);
|
mWiFiToggle = mDialogView.requireViewById(R.id.wifi_toggle);
|
||||||
mBackgroundOn = mContext.getDrawable(R.drawable.settingslib_switch_bar_bg_on);
|
mBackgroundOn = mContext.getDrawable(R.drawable.settingslib_switch_bar_bg_on);
|
||||||
mInternetListLayout.getViewTreeObserver().addOnGlobalLayoutListener(
|
mInternetDialogLayout.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||||
mInternetListLayoutListener);
|
mInternetListLayoutListener);
|
||||||
mInternetDialogTitle.setText(getDialogTitleText());
|
mInternetDialogTitle.setText(getDialogTitleText());
|
||||||
mInternetDialogTitle.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
mInternetDialogTitle.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||||
@@ -247,7 +258,19 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onStart");
|
Log.d(TAG, "onStart");
|
||||||
}
|
}
|
||||||
mInternetDialogController.onStart(this);
|
mInternetDialogController.onStart(this, mCanConfigWifi);
|
||||||
|
if (!mCanConfigWifi) {
|
||||||
|
hideWifiViews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void hideWifiViews() {
|
||||||
|
setProgressBarVisible(false);
|
||||||
|
mTurnWifiOnLayout.setVisibility(View.GONE);
|
||||||
|
mConnectedWifListLayout.setVisibility(View.GONE);
|
||||||
|
mWifiRecyclerView.setVisibility(View.GONE);
|
||||||
|
mSeeAllLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,23 +309,22 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
} else {
|
} else {
|
||||||
mInternetDialogSubTitle.setText(getSubtitleText());
|
mInternetDialogSubTitle.setText(getSubtitleText());
|
||||||
}
|
}
|
||||||
showProgressBar();
|
|
||||||
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular());
|
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular());
|
||||||
|
|
||||||
|
if (!mCanConfigWifi) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
showProgressBar();
|
||||||
final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked();
|
final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked();
|
||||||
final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
|
final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
|
||||||
updateWifiToggle(isWifiEnabled, isDeviceLocked);
|
updateWifiToggle(isWifiEnabled, isDeviceLocked);
|
||||||
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
|
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
|
||||||
|
|
||||||
List<WifiEntry> wifiEntryList = mInternetDialogController.getWifiEntryList();
|
final int visibility = (isDeviceLocked || !isWifiEnabled || mWifiEntriesCount <= 0)
|
||||||
final int wifiListVisibility =
|
? View.GONE : View.VISIBLE;
|
||||||
(isDeviceLocked || wifiEntryList == null || wifiEntryList.size() <= 0)
|
mWifiRecyclerView.setVisibility(visibility);
|
||||||
? View.GONE : View.VISIBLE;
|
mSeeAllLayout.setVisibility(visibility);
|
||||||
mWifiRecyclerView.setVisibility(wifiListVisibility);
|
|
||||||
if (wifiListVisibility == View.VISIBLE) {
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
mSeeAllLayout.setVisibility(wifiListVisibility);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnClickListener() {
|
private void setOnClickListener() {
|
||||||
@@ -368,6 +390,12 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
|
|
||||||
private void updateWifiToggle(boolean isWifiEnabled, boolean isDeviceLocked) {
|
private void updateWifiToggle(boolean isWifiEnabled, boolean isDeviceLocked) {
|
||||||
mWiFiToggle.setChecked(isWifiEnabled);
|
mWiFiToggle.setChecked(isWifiEnabled);
|
||||||
|
if (isDeviceLocked && mInternetDialogController.isNightMode()) {
|
||||||
|
int titleColor = mConnectedWifiEntry != null ? mContext.getColor(
|
||||||
|
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||||
|
mContext, android.R.attr.textColorPrimary);
|
||||||
|
mWifiToggleTitleText.setTextColor(titleColor);
|
||||||
|
}
|
||||||
mTurnWifiOnLayout.setBackground(
|
mTurnWifiOnLayout.setBackground(
|
||||||
(isDeviceLocked && mConnectedWifiEntry != null) ? mBackgroundOn : null);
|
(isDeviceLocked && mConnectedWifiEntry != null) ? mBackgroundOn : null);
|
||||||
}
|
}
|
||||||
@@ -379,8 +407,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
||||||
mConnectedWifiTitleText.setText(mInternetDialogController.getInternetWifiTitle());
|
mConnectedWifiTitleText.setText(mConnectedWifiEntry.getTitle());
|
||||||
mConnectedWifiSummaryText.setText(mInternetDialogController.getInternetWifiSummary());
|
mConnectedWifiSummaryText.setText(mConnectedWifiEntry.getSummary(false));
|
||||||
mConnectedWifiIcon.setImageDrawable(
|
mConnectedWifiIcon.setImageDrawable(
|
||||||
mInternetDialogController.getInternetWifiDrawable(mConnectedWifiEntry));
|
mInternetDialogController.getInternetWifiDrawable(mConnectedWifiEntry));
|
||||||
if (mInternetDialogController.isNightMode()) {
|
if (mInternetDialogController.isNightMode()) {
|
||||||
@@ -430,8 +458,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setProgressBarVisible(true);
|
setProgressBarVisible(true);
|
||||||
List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
|
if (mConnectedWifiEntry != null || mWifiEntriesCount > 0) {
|
||||||
if (wifiScanResults != null && wifiScanResults.size() > 0) {
|
|
||||||
mHandler.postDelayed(mHideProgressBarRunnable, PROGRESS_DELAY_MS);
|
mHandler.postDelayed(mHideProgressBarRunnable, PROGRESS_DELAY_MS);
|
||||||
} else if (!mIsSearchingHidden) {
|
} else if (!mIsSearchingHidden) {
|
||||||
mHandler.postDelayed(mHideSearchingRunnable, PROGRESS_DELAY_MS);
|
mHandler.postDelayed(mHideSearchingRunnable, PROGRESS_DELAY_MS);
|
||||||
@@ -516,8 +543,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@WorkerThread
|
||||||
public void onDataConnectionStateChanged(int state, int networkType) {
|
public void onDataConnectionStateChanged(int state, int networkType) {
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
mHandler.post(() -> updateDialog());
|
mHandler.post(() -> updateDialog());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,10 +559,16 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccessPointsChanged(List<WifiEntry> wifiEntryList, WifiEntry connectedEntry) {
|
@WorkerThread
|
||||||
|
public void onAccessPointsChanged(@Nullable List<WifiEntry> wifiEntries,
|
||||||
|
@Nullable WifiEntry connectedEntry) {
|
||||||
mConnectedWifiEntry = connectedEntry;
|
mConnectedWifiEntry = connectedEntry;
|
||||||
mAdapter.notifyDataSetChanged();
|
mWifiEntriesCount = wifiEntries == null ? 0 : wifiEntries.size();
|
||||||
mHandler.post(() -> updateDialog());
|
mAdapter.setWifiEntries(wifiEntries, mWifiEntriesCount);
|
||||||
|
mHandler.post(() -> {
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
updateDialog();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -548,24 +581,6 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWifiStateReceived(Context context, Intent intent) {
|
|
||||||
if (intent == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (action.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
|
|
||||||
mInternetDialogController.scanWifiAccessPoints();
|
|
||||||
showProgressBar();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
|
||||||
mHandler.post(() -> updateDialog());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum InternetDialogEvent implements UiEventLogger.UiEventEnum {
|
public enum InternetDialogEvent implements UiEventLogger.UiEventEnum {
|
||||||
@UiEvent(doc = "The Internet dialog became visible on the screen.")
|
@UiEvent(doc = "The Internet dialog became visible on the screen.")
|
||||||
INTERNET_DIALOG_SHOW(843);
|
INTERNET_DIALOG_SHOW(843);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.Network;
|
import android.net.Network;
|
||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkRequest;
|
import android.net.NetworkRequest;
|
||||||
import android.net.wifi.ScanResult;
|
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -53,6 +52,7 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
@@ -108,6 +108,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
R.string.all_network_unavailable;
|
R.string.all_network_unavailable;
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
|
static final int MAX_WIFI_ENTRY_COUNT = 4;
|
||||||
|
|
||||||
private WifiManager mWifiManager;
|
private WifiManager mWifiManager;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private SubscriptionManager mSubscriptionManager;
|
private SubscriptionManager mSubscriptionManager;
|
||||||
@@ -122,7 +124,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
private AccessPointController mAccessPointController;
|
private AccessPointController mAccessPointController;
|
||||||
private IntentFilter mConnectionStateFilter;
|
private IntentFilter mConnectionStateFilter;
|
||||||
private InternetDialogCallback mCallback;
|
private InternetDialogCallback mCallback;
|
||||||
private List<WifiEntry> mWifiEntry;
|
private WifiEntry mConnectedEntry;
|
||||||
|
private int mWifiEntriesCount;
|
||||||
private UiEventLogger mUiEventLogger;
|
private UiEventLogger mUiEventLogger;
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
@@ -132,16 +135,15 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected ActivityStarter mActivityStarter;
|
protected ActivityStarter mActivityStarter;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected WifiEntry mConnectedEntry;
|
|
||||||
@VisibleForTesting
|
|
||||||
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected InternetTelephonyCallback mInternetTelephonyCallback;
|
protected InternetTelephonyCallback mInternetTelephonyCallback;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
KeyguardStateController mKeyguardStateController;
|
protected boolean mCanConfigWifi;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected KeyguardStateController mKeyguardStateController;
|
||||||
|
|
||||||
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
||||||
new KeyguardUpdateMonitorCallback() {
|
new KeyguardUpdateMonitorCallback() {
|
||||||
@@ -183,8 +185,6 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||||
mKeyguardStateController = keyguardStateController;
|
mKeyguardStateController = keyguardStateController;
|
||||||
mConnectionStateFilter = new IntentFilter();
|
mConnectionStateFilter = new IntentFilter();
|
||||||
mConnectionStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
|
||||||
mConnectionStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
|
||||||
mConnectionStateFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
|
mConnectionStateFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mActivityStarter = starter;
|
mActivityStarter = starter;
|
||||||
@@ -193,7 +193,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mWifiIconInjector = new WifiUtils.InternetIconInjector(mContext);
|
mWifiIconInjector = new WifiUtils.InternetIconInjector(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onStart(@NonNull InternetDialogCallback callback) {
|
void onStart(@NonNull InternetDialogCallback callback, boolean canConfigWifi) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onStart");
|
Log.d(TAG, "onStart");
|
||||||
}
|
}
|
||||||
@@ -217,6 +217,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mConnectivityManager.registerNetworkCallback(new NetworkRequest.Builder()
|
mConnectivityManager.registerNetworkCallback(new NetworkRequest.Builder()
|
||||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
.build(), new DataConnectivityListener(), mHandler);
|
.build(), new DataConnectivityListener(), mHandler);
|
||||||
|
mCanConfigWifi = canConfigWifi;
|
||||||
scanWifiAccessPoints();
|
scanWifiAccessPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +271,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mWifiManager.isWifiEnabled()) {
|
if (mCanConfigWifi && !mWifiManager.isWifiEnabled()) {
|
||||||
// When the airplane mode is off and Wi-Fi is disabled.
|
// When the airplane mode is off and Wi-Fi is disabled.
|
||||||
// Sub-Title: Wi-Fi is off
|
// Sub-Title: Wi-Fi is off
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -288,12 +289,11 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_UNLOCK_TO_VIEW_NETWORKS);
|
return mContext.getText(SUBTITLE_TEXT_UNLOCK_TO_VIEW_NETWORKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
if (mConnectedEntry != null || mWifiEntriesCount > 0) {
|
||||||
if (wifiList != null && wifiList.size() != 0) {
|
return mCanConfigWifi ? mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT) : null;
|
||||||
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isProgressBarVisible) {
|
if (mCanConfigWifi && isProgressBarVisible) {
|
||||||
// When the Wi-Fi scan result callback is received
|
// When the Wi-Fi scan result callback is received
|
||||||
// Sub-Title: Searching for networks...
|
// Sub-Title: Searching for networks...
|
||||||
return mContext.getText(SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS);
|
return mContext.getText(SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS);
|
||||||
@@ -317,7 +317,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE);
|
return mContext.getText(SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isMobileDataEnabled()) {
|
if (mCanConfigWifi && !isMobileDataEnabled()) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Mobile data off");
|
Log.d(TAG, "Mobile data off");
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE);
|
return mContext.getText(SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mContext.getText(SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE);
|
if (mCanConfigWifi) {
|
||||||
|
return mContext.getText(SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable getInternetWifiDrawable(@NonNull WifiEntry wifiEntry) {
|
Drawable getInternetWifiDrawable(@NonNull WifiEntry wifiEntry) {
|
||||||
@@ -549,26 +552,6 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getInternetWifiTitle() {
|
|
||||||
if (getInternetWifiEntry() == null) {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "connected entry is null");
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return getInternetWifiEntry().getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getInternetWifiSummary() {
|
|
||||||
if (getInternetWifiEntry() == null) {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "connected entry is null");
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return getInternetWifiEntry().getSummary(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void launchNetworkSetting() {
|
void launchNetworkSetting() {
|
||||||
mCallback.dismissDialog();
|
mCallback.dismissDialog();
|
||||||
mActivityStarter.postStartActivityDismissingKeyguard(getSettingsIntent(), 0);
|
mActivityStarter.postStartActivityDismissingKeyguard(getSettingsIntent(), 0);
|
||||||
@@ -590,18 +573,6 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<WifiEntry> getWifiEntryList() {
|
|
||||||
return mWifiEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
WifiEntry getInternetWifiEntry() {
|
|
||||||
if (mConnectedEntry == null || !mConnectedEntry.isDefaultNetwork()
|
|
||||||
|| !mConnectedEntry.hasInternetAccess()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return mConnectedEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
WifiManager getWifiManager() {
|
WifiManager getWifiManager() {
|
||||||
return mWifiManager;
|
return mWifiManager;
|
||||||
}
|
}
|
||||||
@@ -779,20 +750,33 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanWifiAccessPoints() {
|
private void scanWifiAccessPoints() {
|
||||||
mAccessPointController.scanForAccessPoints();
|
if (mCanConfigWifi) {
|
||||||
|
mAccessPointController.scanForAccessPoints();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@WorkerThread
|
||||||
public void onAccessPointsChanged(List<WifiEntry> accessPoints) {
|
public void onAccessPointsChanged(List<WifiEntry> accessPoints) {
|
||||||
if (accessPoints == null) {
|
if (!mCanConfigWifi) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accessPoints == null || accessPoints.size() == 0) {
|
||||||
|
mConnectedEntry = null;
|
||||||
|
mWifiEntriesCount = 0;
|
||||||
|
if (mCallback != null) {
|
||||||
|
mCallback.onAccessPointsChanged(null /* wifiEntries */, null /* connectedEntry */);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasConnectedWifi = false;
|
boolean hasConnectedWifi = false;
|
||||||
mWifiEntry = accessPoints;
|
final int accessPointSize = accessPoints.size();
|
||||||
for (WifiEntry wifiEntry : accessPoints) {
|
for (int i = 0; i < accessPointSize; i++) {
|
||||||
if (wifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED) {
|
WifiEntry wifiEntry = accessPoints.get(i);
|
||||||
|
if (wifiEntry.isDefaultNetwork() && wifiEntry.hasInternetAccess()) {
|
||||||
mConnectedEntry = wifiEntry;
|
mConnectedEntry = wifiEntry;
|
||||||
hasConnectedWifi = true;
|
hasConnectedWifi = true;
|
||||||
break;
|
break;
|
||||||
@@ -802,7 +786,23 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mConnectedEntry = null;
|
mConnectedEntry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCallback.onAccessPointsChanged(mWifiEntry, getInternetWifiEntry());
|
int count = MAX_WIFI_ENTRY_COUNT;
|
||||||
|
if (hasCarrier()) {
|
||||||
|
count -= 1;
|
||||||
|
}
|
||||||
|
if (hasConnectedWifi) {
|
||||||
|
count -= 1;
|
||||||
|
}
|
||||||
|
final List<WifiEntry> wifiEntries = accessPoints.stream()
|
||||||
|
.filter(wifiEntry -> (!wifiEntry.isDefaultNetwork()
|
||||||
|
|| !wifiEntry.hasInternetAccess()))
|
||||||
|
.limit(count)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
mWifiEntriesCount = wifiEntries == null ? 0 : wifiEntries.size();
|
||||||
|
|
||||||
|
if (mCallback != null) {
|
||||||
|
mCallback.onAccessPointsChanged(wifiEntries, mConnectedEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -855,8 +855,17 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
|
|
||||||
private class DataConnectivityListener extends ConnectivityManager.NetworkCallback {
|
private class DataConnectivityListener extends ConnectivityManager.NetworkCallback {
|
||||||
@Override
|
@Override
|
||||||
|
@WorkerThread
|
||||||
public void onCapabilitiesChanged(@NonNull Network network,
|
public void onCapabilitiesChanged(@NonNull Network network,
|
||||||
@NonNull NetworkCapabilities networkCapabilities) {
|
@NonNull NetworkCapabilities networkCapabilities) {
|
||||||
|
if (mCanConfigWifi) {
|
||||||
|
for (int transport : networkCapabilities.getTransportTypes()) {
|
||||||
|
if (transport == NetworkCapabilities.TRANSPORT_WIFI) {
|
||||||
|
scanWifiAccessPoints();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
final Network activeNetwork = mConnectivityManager.getActiveNetwork();
|
final Network activeNetwork = mConnectivityManager.getActiveNetwork();
|
||||||
if (activeNetwork != null && activeNetwork.equals(network)) {
|
if (activeNetwork != null && activeNetwork.equals(network)) {
|
||||||
// update UI
|
// update UI
|
||||||
@@ -869,11 +878,6 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)
|
|
||||||
|| action.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
|
|
||||||
mCallback.onWifiStateReceived(context, intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
|
if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED");
|
Log.d(TAG, "ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED");
|
||||||
@@ -929,8 +933,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
|
|
||||||
void dismissDialog();
|
void dismissDialog();
|
||||||
|
|
||||||
void onAccessPointsChanged(List<WifiEntry> wifiEntryList, WifiEntry connectedEntry);
|
void onAccessPointsChanged(@Nullable List<WifiEntry> wifiEntries,
|
||||||
|
@Nullable WifiEntry connectedEntry);
|
||||||
void onWifiStateReceived(Context context, Intent intent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,17 +31,17 @@ private val DEBUG = Log.isLoggable(TAG, Log.DEBUG)
|
|||||||
*/
|
*/
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
class InternetDialogFactory @Inject constructor(
|
class InternetDialogFactory @Inject constructor(
|
||||||
@Main private val handler: Handler,
|
@Main private val handler: Handler,
|
||||||
private val internetDialogController: InternetDialogController,
|
private val internetDialogController: InternetDialogController,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val uiEventLogger: UiEventLogger
|
private val uiEventLogger: UiEventLogger
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
var internetDialog: InternetDialog? = null
|
var internetDialog: InternetDialog? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a [InternetDialog]. */
|
/** Creates a [InternetDialog]. */
|
||||||
fun create(aboveStatusBar: Boolean, canConfigMobileData: Boolean) {
|
fun create(aboveStatusBar: Boolean, canConfigMobileData: Boolean, canConfigWifi: Boolean) {
|
||||||
if (internetDialog != null) {
|
if (internetDialog != null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "InternetDialog is showing, do not create it twice.")
|
Log.d(TAG, "InternetDialog is showing, do not create it twice.")
|
||||||
@@ -49,7 +49,7 @@ class InternetDialogFactory @Inject constructor(
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
internetDialog = InternetDialog(context, this, internetDialogController,
|
internetDialog = InternetDialog(context, this, internetDialogController,
|
||||||
canConfigMobileData, aboveStatusBar, uiEventLogger, handler)
|
canConfigMobileData, canConfigWifi, aboveStatusBar, uiEventLogger, handler)
|
||||||
internetDialog?.show()
|
internetDialog?.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -801,8 +801,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
|||||||
mReceiverHandler.post(this::handleConfigurationChanged);
|
mReceiverHandler.post(this::handleConfigurationChanged);
|
||||||
break;
|
break;
|
||||||
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
||||||
boolean canConfigMobileData = mAccessPoints.canConfigMobileData();
|
mMainHandler.post(() -> mInternetDialogFactory.create(true,
|
||||||
mMainHandler.post(() -> mInternetDialogFactory.create(true, canConfigMobileData));
|
mAccessPoints.canConfigMobileData(), mAccessPoints.canConfigWifi()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
|
int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package com.android.systemui.qs.tiles.dialog;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -24,6 +27,7 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@@ -35,6 +39,8 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mInternetWifiEntry;
|
private WifiEntry mInternetWifiEntry;
|
||||||
@Mock
|
@Mock
|
||||||
|
private List<WifiEntry> mWifiEntries;
|
||||||
|
@Mock
|
||||||
private WifiEntry mWifiEntry;
|
private WifiEntry mWifiEntry;
|
||||||
@Mock
|
@Mock
|
||||||
private InternetDialogController mInternetDialogController;
|
private InternetDialogController mInternetDialogController;
|
||||||
@@ -56,43 +62,17 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
||||||
mViewHolder = mInternetAdapter.onCreateViewHolder(new LinearLayout(mContext), 0);
|
mViewHolder = mInternetAdapter.onCreateViewHolder(new LinearLayout(mContext), 0);
|
||||||
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(mInternetWifiEntry);
|
mInternetAdapter.setWifiEntries(Arrays.asList(mWifiEntry), 1 /* wifiEntriesCount */);
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
|
||||||
mViewHolder.mWifiIconInjector = mWifiIconInjector;
|
mViewHolder.mWifiIconInjector = mWifiIconInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOnWifiOnNoInternetWifi_returnFour() {
|
public void getItemCount_returnWifiEntriesCount() {
|
||||||
// The preconditions WiFi ON is already in setUp()
|
for (int i = 0; i < InternetDialogController.MAX_WIFI_ENTRY_COUNT; i++) {
|
||||||
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(null);
|
mInternetAdapter.setWifiEntries(mWifiEntries, i /* wifiEntriesCount */);
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(4);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getItemCount_withApmOnWifiOnHasInternetWifi_returnThree() {
|
|
||||||
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getItemCount_withApmOffWifiOnNoInternetWifi_returnThree() {
|
|
||||||
// The preconditions WiFi ON is already in setUp()
|
|
||||||
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(null);
|
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getItemCount_withApmOffWifiOnHasInternetWifi_returnTwo() {
|
|
||||||
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -118,7 +98,17 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_bindDefaultWifiNetwork_getIconWithInternet() {
|
public void onBindViewHolder_wifiLevelUnreachable_shouldNotGetWifiIcon() {
|
||||||
|
reset(mWifiIconInjector);
|
||||||
|
when(mWifiEntry.getLevel()).thenReturn(WifiEntry.WIFI_LEVEL_UNREACHABLE);
|
||||||
|
|
||||||
|
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
||||||
|
|
||||||
|
verify(mWifiIconInjector, never()).getIcon(anyBoolean(), anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBindViewHolder_shouldNotShowXLevelIcon_getIconWithInternet() {
|
||||||
when(mWifiEntry.shouldShowXLevelIcon()).thenReturn(false);
|
when(mWifiEntry.shouldShowXLevelIcon()).thenReturn(false);
|
||||||
|
|
||||||
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
||||||
@@ -127,7 +117,7 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_bindNoDefaultWifiNetwork_getIconWithNoInternet() {
|
public void onBindViewHolder_shouldShowXLevelIcon_getIconWithNoInternet() {
|
||||||
when(mWifiEntry.shouldShowXLevelIcon()).thenReturn(true);
|
when(mWifiEntry.shouldShowXLevelIcon()).thenReturn(true);
|
||||||
|
|
||||||
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -17,7 +18,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.ScanResult;
|
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
@@ -84,14 +84,26 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mConnectedEntry;
|
private WifiEntry mConnectedEntry;
|
||||||
@Mock
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry1;
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry2;
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry3;
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry4;
|
||||||
|
@Mock
|
||||||
private ServiceState mServiceState;
|
private ServiceState mServiceState;
|
||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiUtils.InternetIconInjector mWifiIconInjector;
|
private WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
@Mock
|
||||||
|
InternetDialogController.InternetDialogCallback mInternetDialogCallback;
|
||||||
|
|
||||||
private MockInternetDialogController mInternetDialogController;
|
private MockInternetDialogController mInternetDialogController;
|
||||||
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
||||||
|
private List<WifiEntry> mAccessPoints = new ArrayList<>();
|
||||||
|
private List<WifiEntry> mWifiEntries = new ArrayList<>();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -100,6 +112,13 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
|
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
|
||||||
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
when(mConnectedEntry.hasInternetAccess()).thenReturn(true);
|
when(mConnectedEntry.hasInternetAccess()).thenReturn(true);
|
||||||
|
when(mWifiEntry1.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_DISCONNECTED);
|
||||||
|
when(mWifiEntry2.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_DISCONNECTED);
|
||||||
|
when(mWifiEntry3.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_DISCONNECTED);
|
||||||
|
when(mWifiEntry4.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_DISCONNECTED);
|
||||||
|
mAccessPoints.add(mConnectedEntry);
|
||||||
|
mAccessPoints.add(mWifiEntry1);
|
||||||
|
when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID});
|
||||||
|
|
||||||
mInternetDialogController = new MockInternetDialogController(mContext,
|
mInternetDialogController = new MockInternetDialogController(mContext,
|
||||||
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
||||||
@@ -108,10 +127,9 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController);
|
mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController);
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||||
mInternetDialogController.mOnSubscriptionsChangedListener);
|
mInternetDialogController.mOnSubscriptionsChangedListener);
|
||||||
mInternetDialogController.onStart(
|
mInternetDialogController.onStart(mInternetDialogCallback, true);
|
||||||
mock(InternetDialogController.InternetDialogCallback.class));
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
mInternetDialogController.mActivityStarter = mActivityStarter;
|
mInternetDialogController.mActivityStarter = mActivityStarter;
|
||||||
mInternetDialogController.mConnectedEntry = mConnectedEntry;
|
|
||||||
mInternetDialogController.mWifiIconInjector = mWifiIconInjector;
|
mInternetDialogController.mWifiIconInjector = mWifiIconInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,32 +161,46 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(false),
|
assertThat(mInternetDialogController.getSubtitleText(false))
|
||||||
getResourcesString("wifi_is_off")));
|
.isEqualTo(getResourcesString("wifi_is_off"));
|
||||||
|
|
||||||
|
// if the Wi-Fi disallow config, then don't return Wi-Fi related string.
|
||||||
|
mInternetDialogController.mCanConfigWifi = false;
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getSubtitleText(false))
|
||||||
|
.isNotEqualTo(getResourcesString("wifi_is_off"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleText_withNoWifiEntry_returnSearchWifi() {
|
public void getSubtitleText_withNoWifiEntry_returnSearchWifi() {
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
doReturn(0).when(wifiScanResults).size();
|
|
||||||
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(true),
|
assertThat(mInternetDialogController.getSubtitleText(true))
|
||||||
getResourcesString("wifi_empty_list_wifi_on")));
|
.isEqualTo(getResourcesString("wifi_empty_list_wifi_on"));
|
||||||
|
|
||||||
|
// if the Wi-Fi disallow config, then don't return Wi-Fi related string.
|
||||||
|
mInternetDialogController.mCanConfigWifi = false;
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getSubtitleText(true))
|
||||||
|
.isNotEqualTo(getResourcesString("wifi_empty_list_wifi_on"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleText_withWifiEntry_returnTapToConnect() {
|
public void getSubtitleText_withWifiEntry_returnTapToConnect() {
|
||||||
|
// The preconditions WiFi Entries is already in setUp()
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
|
||||||
doReturn(1).when(wifiScanResults).size();
|
|
||||||
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(false),
|
assertThat(mInternetDialogController.getSubtitleText(false))
|
||||||
getResourcesString("tap_a_network_to_connect")));
|
.isEqualTo(getResourcesString("tap_a_network_to_connect"));
|
||||||
|
|
||||||
|
// if the Wi-Fi disallow config, then don't return Wi-Fi related string.
|
||||||
|
mInternetDialogController.mCanConfigWifi = false;
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getSubtitleText(false))
|
||||||
|
.isNotEqualTo(getResourcesString("tap_a_network_to_connect"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -185,11 +217,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
public void getSubtitleText_withNoService_returnNoNetworksAvailable() {
|
public void getSubtitleText_withNoService_returnNoNetworksAvailable() {
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = new ArrayList<>();
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
doReturn(wifiScanResults).when(mWifiManager).getScanResults();
|
|
||||||
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
|
||||||
when(mSubscriptionManager.getActiveSubscriptionIdList())
|
|
||||||
.thenReturn(new int[] {SUB_ID});
|
|
||||||
|
|
||||||
doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getState();
|
doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getState();
|
||||||
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
|
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
|
||||||
@@ -203,83 +231,26 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
public void getSubtitleText_withMobileDataDisabled_returnNoOtherAvailable() {
|
public void getSubtitleText_withMobileDataDisabled_returnNoOtherAvailable() {
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = new ArrayList<>();
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
doReturn(wifiScanResults).when(mWifiManager).getScanResults();
|
|
||||||
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
|
||||||
when(mSubscriptionManager.getActiveSubscriptionIdList())
|
|
||||||
.thenReturn(new int[] {SUB_ID});
|
|
||||||
|
|
||||||
doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getState();
|
doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getState();
|
||||||
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
|
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
|
||||||
|
|
||||||
when(mTelephonyManager.isDataEnabled()).thenReturn(false);
|
when(mTelephonyManager.isDataEnabled()).thenReturn(false);
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(false),
|
assertThat(mInternetDialogController.getSubtitleText(false))
|
||||||
getResourcesString("non_carrier_network_unavailable")));
|
.isEqualTo(getResourcesString("non_carrier_network_unavailable"));
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
// if the Wi-Fi disallow config, then don't return Wi-Fi related string.
|
||||||
public void getInternetWifiEntry_connectedEntryIsNull_returnNull() {
|
mInternetDialogController.mCanConfigWifi = false;
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiEntry()).isNull();
|
assertThat(mInternetDialogController.getSubtitleText(false))
|
||||||
}
|
.isNotEqualTo(getResourcesString("non_carrier_network_unavailable"));
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiEntry_connectedWifiIsNotDefaultNetwork_returnNull() {
|
|
||||||
when(mConnectedEntry.isDefaultNetwork()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiEntry()).isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiEntry_connectedWifiHasNotInternetAccess_returnNull() {
|
|
||||||
when(mConnectedEntry.hasInternetAccess()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiEntry()).isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiEntry_connectedEntryIsInternetWifi_returnConnectedEntry() {
|
|
||||||
// The preconditions have been set in setUp().
|
|
||||||
// - The connected Wi-Fi entry have both default network and internet access conditions.
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiEntry()).isEqualTo(mConnectedEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiTitle_withNoConnectedWifiEntry_returnEmpty() {
|
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiTitle()).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiTitle_withInternetWifi_returnTitle() {
|
|
||||||
// The preconditions have been set in setUp().
|
|
||||||
// - The connected Wi-Fi entry have both default network and internet access conditions.
|
|
||||||
when(mConnectedEntry.getTitle()).thenReturn(CONNECTED_TITLE);
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiTitle()).isEqualTo(CONNECTED_TITLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiSummary_withNoConnectedWifiEntry_returnEmpty() {
|
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiSummary()).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInternetWifiSummary_withInternetWifi_returnSummary() {
|
|
||||||
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getInternetWifiSummary()).isEqualTo(CONNECTED_SUMMARY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWifiDetailsSettingsIntent_withNoConnectedEntry_returnNull() {
|
public void getWifiDetailsSettingsIntent_withNoConnectedEntry_returnNull() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNull();
|
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNull();
|
||||||
}
|
}
|
||||||
@@ -311,7 +282,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() {
|
public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
|
|
||||||
mInternetDialogController.launchWifiNetworkDetailsSetting();
|
mInternetDialogController.launchWifiNetworkDetailsSetting();
|
||||||
|
|
||||||
@@ -342,6 +313,143 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
assertThat(mInternetDialogController.isDeviceLocked()).isTrue();
|
assertThat(mInternetDialogController.isDeviceLocked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_canNotConfigWifi_doNothing() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.mCanConfigWifi = false;
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
|
|
||||||
|
verify(mInternetDialogCallback, never()).onAccessPointsChanged(any(), any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_nullAccessPoints_callbackBothNull() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(null /* accessPoints */);
|
||||||
|
|
||||||
|
verify(mInternetDialogCallback)
|
||||||
|
.onAccessPointsChanged(null /* wifiEntries */, null /* connectedEntry */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_oneConnectedEntry_callbackConnectedEntryOnly() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(true);
|
||||||
|
mAccessPoints.clear();
|
||||||
|
mAccessPoints.add(mConnectedEntry);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.clear();
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_noConnectedEntryAndOneOther_callbackWifiEntriesOnly() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(true);
|
||||||
|
mAccessPoints.clear();
|
||||||
|
mAccessPoints.add(mWifiEntry1);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.clear();
|
||||||
|
mWifiEntries.add(mWifiEntry1);
|
||||||
|
verify(mInternetDialogCallback)
|
||||||
|
.onAccessPointsChanged(mWifiEntries, null /* connectedEntry */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_oneConnectedEntryAndOneOther_callbackCorrectly() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(true);
|
||||||
|
mAccessPoints.clear();
|
||||||
|
mAccessPoints.add(mConnectedEntry);
|
||||||
|
mAccessPoints.add(mWifiEntry1);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.clear();
|
||||||
|
mWifiEntries.add(mWifiEntry1);
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_oneConnectedEntryAndTwoOthers_callbackCorrectly() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(true);
|
||||||
|
mAccessPoints.clear();
|
||||||
|
mAccessPoints.add(mConnectedEntry);
|
||||||
|
mAccessPoints.add(mWifiEntry1);
|
||||||
|
mAccessPoints.add(mWifiEntry2);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.clear();
|
||||||
|
mWifiEntries.add(mWifiEntry1);
|
||||||
|
mWifiEntries.add(mWifiEntry2);
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_oneConnectedEntryAndThreeOthers_callbackCutMore() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(true);
|
||||||
|
mAccessPoints.clear();
|
||||||
|
mAccessPoints.add(mConnectedEntry);
|
||||||
|
mAccessPoints.add(mWifiEntry1);
|
||||||
|
mAccessPoints.add(mWifiEntry2);
|
||||||
|
mAccessPoints.add(mWifiEntry3);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.clear();
|
||||||
|
mWifiEntries.add(mWifiEntry1);
|
||||||
|
mWifiEntries.add(mWifiEntry2);
|
||||||
|
mWifiEntries.add(mWifiEntry3);
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
|
||||||
|
// Turn off airplane mode to has carrier network, then Wi-Fi entries will cut last one.
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.remove(mWifiEntry3);
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAccessPointsChanged_oneConnectedEntryAndFourOthers_callbackCutMore() {
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(true);
|
||||||
|
mAccessPoints.clear();
|
||||||
|
mAccessPoints.add(mConnectedEntry);
|
||||||
|
mAccessPoints.add(mWifiEntry1);
|
||||||
|
mAccessPoints.add(mWifiEntry2);
|
||||||
|
mAccessPoints.add(mWifiEntry3);
|
||||||
|
mAccessPoints.add(mWifiEntry4);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.clear();
|
||||||
|
mWifiEntries.add(mWifiEntry1);
|
||||||
|
mWifiEntries.add(mWifiEntry2);
|
||||||
|
mWifiEntries.add(mWifiEntry3);
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
|
||||||
|
// Turn off airplane mode to has carrier network, then Wi-Fi entries will cut last one.
|
||||||
|
reset(mInternetDialogCallback);
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
|
|
||||||
|
mInternetDialogController.onAccessPointsChanged(mAccessPoints);
|
||||||
|
|
||||||
|
mWifiEntries.remove(mWifiEntry3);
|
||||||
|
verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry);
|
||||||
|
}
|
||||||
|
|
||||||
private String getResourcesString(String name) {
|
private String getResourcesString(String name) {
|
||||||
return mContext.getResources().getString(getResourcesId(name));
|
return mContext.getResources().getString(getResourcesId(name));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.net.wifi.ScanResult;
|
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
@@ -20,7 +19,6 @@ import android.testing.AndroidTestingRunner;
|
|||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
@@ -39,8 +37,6 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -62,13 +58,16 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mInternetWifiEntry;
|
private WifiEntry mInternetWifiEntry;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mWifiEntry;
|
private List<WifiEntry> mWifiEntries;
|
||||||
@Mock
|
@Mock
|
||||||
private InternetAdapter mInternetAdapter;
|
private InternetAdapter mInternetAdapter;
|
||||||
@Mock
|
@Mock
|
||||||
private InternetDialogController mInternetDialogController;
|
private InternetDialogController mInternetDialogController;
|
||||||
|
|
||||||
private InternetDialog mInternetDialog;
|
private InternetDialog mInternetDialog;
|
||||||
|
private View mDialogView;
|
||||||
|
private View mSubTitle;
|
||||||
|
private LinearLayout mMobileDataToggle;
|
||||||
private LinearLayout mWifiToggle;
|
private LinearLayout mWifiToggle;
|
||||||
private LinearLayout mConnectedWifi;
|
private LinearLayout mConnectedWifi;
|
||||||
private RecyclerView mWifiList;
|
private RecyclerView mWifiList;
|
||||||
@@ -83,26 +82,26 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
when(mInternetWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mInternetWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
when(mInternetWifiEntry.isDefaultNetwork()).thenReturn(true);
|
when(mInternetWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
when(mInternetWifiEntry.hasInternetAccess()).thenReturn(true);
|
when(mInternetWifiEntry.hasInternetAccess()).thenReturn(true);
|
||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntries.size()).thenReturn(1);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
|
||||||
|
|
||||||
when(mInternetDialogController.getMobileNetworkTitle()).thenReturn(MOBILE_NETWORK_TITLE);
|
when(mInternetDialogController.getMobileNetworkTitle()).thenReturn(MOBILE_NETWORK_TITLE);
|
||||||
when(mInternetDialogController.getMobileNetworkSummary())
|
when(mInternetDialogController.getMobileNetworkSummary())
|
||||||
.thenReturn(MOBILE_NETWORK_SUMMARY);
|
.thenReturn(MOBILE_NETWORK_SUMMARY);
|
||||||
when(mInternetDialogController.getWifiManager()).thenReturn(mWifiManager);
|
when(mInternetDialogController.getWifiManager()).thenReturn(mWifiManager);
|
||||||
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(mInternetWifiEntry);
|
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
|
||||||
|
|
||||||
mInternetDialog = new InternetDialog(mContext, mock(InternetDialogFactory.class),
|
mInternetDialog = new InternetDialog(mContext, mock(InternetDialogFactory.class),
|
||||||
mInternetDialogController, true, true, mock(UiEventLogger.class), mHandler);
|
mInternetDialogController, true, true, true, mock(UiEventLogger.class), mHandler);
|
||||||
mInternetDialog.mAdapter = mInternetAdapter;
|
mInternetDialog.mAdapter = mInternetAdapter;
|
||||||
mInternetDialog.mConnectedWifiEntry = mInternetWifiEntry;
|
mInternetDialog.onAccessPointsChanged(mWifiEntries, mInternetWifiEntry);
|
||||||
mInternetDialog.show();
|
mInternetDialog.show();
|
||||||
|
|
||||||
mWifiToggle = mInternetDialog.mDialogView.requireViewById(R.id.turn_on_wifi_layout);
|
mDialogView = mInternetDialog.mDialogView;
|
||||||
mConnectedWifi = mInternetDialog.mDialogView.requireViewById(R.id.wifi_connected_layout);
|
mSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
||||||
mWifiList = mInternetDialog.mDialogView.requireViewById(R.id.wifi_list_layout);
|
mMobileDataToggle = mDialogView.requireViewById(R.id.mobile_network_layout);
|
||||||
mSeeAll = mInternetDialog.mDialogView.requireViewById(R.id.see_all_layout);
|
mWifiToggle = mDialogView.requireViewById(R.id.turn_on_wifi_layout);
|
||||||
|
mConnectedWifi = mDialogView.requireViewById(R.id.wifi_connected_layout);
|
||||||
|
mWifiList = mDialogView.requireViewById(R.id.wifi_list_layout);
|
||||||
|
mSeeAll = mDialogView.requireViewById(R.id.see_all_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -110,34 +109,42 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
mInternetDialog.dismissDialog();
|
mInternetDialog.dismissDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hideWifiViews_WifiViewsGone() {
|
||||||
|
mInternetDialog.hideWifiViews();
|
||||||
|
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isFalse();
|
||||||
|
assertThat(mWifiToggle.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withApmOn_internetDialogSubTitleGone() {
|
public void updateDialog_withApmOn_internetDialogSubTitleGone() {
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final TextView view = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.internet_dialog_subtitle);
|
|
||||||
|
|
||||||
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mSubTitle.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withApmOff_internetDialogSubTitleVisible() {
|
public void updateDialog_withApmOff_internetDialogSubTitleVisible() {
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final TextView view = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.internet_dialog_subtitle);
|
|
||||||
|
|
||||||
assertThat(view.getVisibility()).isEqualTo(View.VISIBLE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mSubTitle.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withApmOn_mobileDataLayoutGone() {
|
public void updateDialog_withApmOn_mobileDataLayoutGone() {
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.mobile_network_layout);
|
|
||||||
|
|
||||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.GONE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mMobileDataToggle.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -152,7 +159,8 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_wifiOnAndNoConnectedWifi_hideConnectedWifi() {
|
public void updateDialog_wifiOnAndNoConnectedWifi_hideConnectedWifi() {
|
||||||
mInternetDialog.mConnectedWifiEntry = null;
|
// The precondition WiFi ON is already in setUp()
|
||||||
|
mInternetDialog.onAccessPointsChanged(mWifiEntries, null /* connectedEntry*/);
|
||||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||||
|
|
||||||
mInternetDialog.updateDialog();
|
mInternetDialog.updateDialog();
|
||||||
@@ -162,7 +170,8 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_wifiOnAndNoWifiList_hideWifiListAndSeeAll() {
|
public void updateDialog_wifiOnAndNoWifiList_hideWifiListAndSeeAll() {
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(null);
|
// The precondition WiFi ON is already in setUp()
|
||||||
|
mInternetDialog.onAccessPointsChanged(null /* wifiEntries */, mInternetWifiEntry);
|
||||||
|
|
||||||
mInternetDialog.updateDialog();
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
@@ -245,9 +254,6 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
||||||
Mockito.reset(mHandler);
|
Mockito.reset(mHandler);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
|
||||||
when(wifiScanResults.size()).thenReturn(1);
|
|
||||||
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
|
||||||
|
|
||||||
mInternetDialog.showProgressBar();
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
@@ -264,12 +270,10 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void showProgressBar_wifiEnabledWithoutWifiScanResults_showProgressBarThenHideSearch() {
|
public void showProgressBar_wifiEnabledWithoutWifiEntries_showProgressBarThenHideSearch() {
|
||||||
Mockito.reset(mHandler);
|
Mockito.reset(mHandler);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
mInternetDialog.onAccessPointsChanged(null /* wifiEntries */, null /* connectedEntry*/);
|
||||||
when(wifiScanResults.size()).thenReturn(0);
|
|
||||||
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
|
||||||
|
|
||||||
mInternetDialog.showProgressBar();
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user