Merge changes I566dfa75,Id0d372cf,Ifb79e402,Ic80ed7f8,I40ff3ed0 into sc-qpr1-dev
* changes: [Provider Model] Fix the condition about admin user [Provider Model] 1.Only admin can config mobile data 2.Do not connect to mobile data when device is locked [Provider Model] Fix the toggle's size and dialog's width [Provider Model] Correct the connected Wi-Fi UI [Provider Model] Should not show Wi-Fi entries under lockscreen
This commit is contained in:
@@ -18,8 +18,6 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item
|
<item
|
||||||
android:top="@dimen/settingslib_switch_thumb_margin"
|
android:top="@dimen/settingslib_switch_thumb_margin"
|
||||||
android:left="@dimen/settingslib_switch_thumb_margin"
|
|
||||||
android:right="@dimen/settingslib_switch_thumb_margin"
|
|
||||||
android:bottom="@dimen/settingslib_switch_thumb_margin">
|
android:bottom="@dimen/settingslib_switch_thumb_margin">
|
||||||
<shape android:shape="oval">
|
<shape android:shape="oval">
|
||||||
<size
|
<size
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item
|
<item
|
||||||
android:top="@dimen/settingslib_switch_thumb_margin"
|
android:top="@dimen/settingslib_switch_thumb_margin"
|
||||||
android:left="@dimen/settingslib_switch_thumb_margin"
|
|
||||||
android:right="@dimen/settingslib_switch_thumb_margin"
|
|
||||||
android:bottom="@dimen/settingslib_switch_thumb_margin">
|
android:bottom="@dimen/settingslib_switch_thumb_margin">
|
||||||
<shape android:shape="oval">
|
<shape android:shape="oval">
|
||||||
<size
|
<size
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
android:shape="rectangle"
|
android:shape="rectangle"
|
||||||
android:width="@dimen/settingslib_switch_track_width"
|
android:width="@dimen/settingslib_switch_track_width"
|
||||||
android:height="@dimen/settingslib_switch_track_height">
|
android:height="@dimen/settingslib_switch_track_height">
|
||||||
|
<padding android:left="@dimen/settingslib_switch_thumb_margin"
|
||||||
|
android:right="@dimen/settingslib_switch_thumb_margin"/>
|
||||||
<solid android:color="@color/settingslib_track_off_color"/>
|
<solid android:color="@color/settingslib_track_off_color"/>
|
||||||
<corners android:radius="@dimen/settingslib_switch_track_radius"/>
|
<corners android:radius="@dimen/settingslib_switch_track_radius"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
android:shape="rectangle"
|
android:shape="rectangle"
|
||||||
android:width="@dimen/settingslib_switch_track_width"
|
android:width="@dimen/settingslib_switch_track_width"
|
||||||
android:height="@dimen/settingslib_switch_track_height">
|
android:height="@dimen/settingslib_switch_track_height">
|
||||||
|
<padding android:left="@dimen/settingslib_switch_thumb_margin"
|
||||||
|
android:right="@dimen/settingslib_switch_thumb_margin"/>
|
||||||
<solid android:color="@color/settingslib_track_on_color"/>
|
<solid android:color="@color/settingslib_track_on_color"/>
|
||||||
<corners android:radius="@dimen/settingslib_switch_track_radius"/>
|
<corners android:radius="@dimen/settingslib_switch_track_radius"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -19,18 +19,18 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
android:id="@+id/internet_connectivity_dialog"
|
android:id="@+id/internet_connectivity_dialog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="@dimen/internet_dialog_list_max_width"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/internet_dialog_list_max_height"
|
||||||
android:background="@drawable/internet_dialog_rounded_top_corner_background"
|
android:background="@drawable/internet_dialog_rounded_top_corner_background"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
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="16dp"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -54,6 +54,12 @@
|
|||||||
android:textSize="14sp"/>
|
android:textSize="14sp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_gravity="center_vertical|center_horizontal"
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
@@ -69,6 +75,7 @@
|
|||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
style="@style/TrimmedHorizontalProgressBar"/>
|
style="@style/TrimmedHorizontalProgressBar"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:id="@+id/scroll_view"
|
android:id="@+id/scroll_view"
|
||||||
@@ -96,7 +103,6 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:paddingStart="22dp"
|
android:paddingStart="22dp"
|
||||||
android:paddingEnd="22dp">
|
android:paddingEnd="22dp">
|
||||||
|
|
||||||
@@ -148,14 +154,15 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="48dp"
|
android:layout_width="@dimen/settingslib_switch_track_width"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_gravity="end|center_vertical">
|
android:layout_gravity="end|center_vertical">
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/mobile_toggle"
|
android:id="@+id/mobile_toggle"
|
||||||
|
android:switchMinWidth="@dimen/settingslib_switch_track_width"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_width="48dp"
|
android:layout_width="@dimen/settingslib_switch_track_width"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/settingslib_switch_track_height"
|
||||||
android:track="@drawable/settingslib_track_selector"
|
android:track="@drawable/settingslib_track_selector"
|
||||||
android:thumb="@drawable/settingslib_thumb_selector"
|
android:thumb="@drawable/settingslib_thumb_selector"
|
||||||
android:theme="@style/MainSwitch.Settingslib"/>
|
android:theme="@style/MainSwitch.Settingslib"/>
|
||||||
@@ -195,15 +202,16 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="48dp"
|
android:layout_width="@dimen/settingslib_switch_track_width"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="10dp">
|
android:layout_marginBottom="10dp">
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/wifi_toggle"
|
android:id="@+id/wifi_toggle"
|
||||||
|
android:switchMinWidth="@dimen/settingslib_switch_track_width"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_width="48dp"
|
android:layout_width="@dimen/settingslib_switch_track_width"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/settingslib_switch_track_height"
|
||||||
android:track="@drawable/settingslib_track_selector"
|
android:track="@drawable/settingslib_track_selector"
|
||||||
android:thumb="@drawable/settingslib_thumb_selector"
|
android:thumb="@drawable/settingslib_thumb_selector"
|
||||||
android:theme="@style/MainSwitch.Settingslib"/>
|
android:theme="@style/MainSwitch.Settingslib"/>
|
||||||
@@ -343,31 +351,23 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Space
|
<FrameLayout
|
||||||
android:id="@+id/space"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="28dp"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginBottom="25dp"
|
android:layout_marginBottom="40dp">
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
<Button
|
<Button
|
||||||
style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
||||||
android:id="@+id/done"
|
android:id="@+id/done"
|
||||||
android:layout_width="60dp"
|
android:layout_width="67dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="36dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end|center_vertical"
|
||||||
android:background="@drawable/internet_dialog_footer_background"
|
android:background="@drawable/internet_dialog_footer_background"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:text="@string/inline_done_button"
|
android:text="@string/inline_done_button"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
</LinearLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1593,7 +1593,8 @@
|
|||||||
|
|
||||||
<!-- 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">614dp</dimen>
|
<dimen name="internet_dialog_list_max_height">646dp</dimen>
|
||||||
|
<dimen name="internet_dialog_list_max_width">412dp</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>
|
||||||
@@ -1604,21 +1605,26 @@
|
|||||||
<!-- Size of internet dialog -->
|
<!-- Size of 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">48dp</dimen>
|
<dimen name="settingslib_min_switch_width">52dp</dimen>
|
||||||
<!-- Size of layout margin left -->
|
<!-- Size of layout margin left -->
|
||||||
<dimen name="settingslib_switchbar_padding_left">20dp</dimen>
|
<dimen name="settingslib_switchbar_padding_left">20dp</dimen>
|
||||||
<!-- Size of layout margin right -->
|
<!-- Size of layout margin right -->
|
||||||
<dimen name="settingslib_switchbar_padding_right">20dp</dimen>
|
<dimen name="settingslib_switchbar_padding_right">20dp</dimen>
|
||||||
<!-- Radius of switch bar -->
|
<!-- Radius of switch bar -->
|
||||||
<dimen name="settingslib_switch_bar_radius">24dp</dimen>
|
<dimen name="settingslib_switch_bar_radius">35dp</dimen>
|
||||||
<!-- Margin of switch thumb -->
|
<!-- Margin of switch thumb -->
|
||||||
<dimen name="settingslib_switch_thumb_margin">4dp</dimen>
|
<dimen name="settingslib_switch_thumb_margin">4dp</dimen>
|
||||||
<!-- Size of switch thumb -->
|
<!-- Size of switch thumb -->
|
||||||
<dimen name="settingslib_switch_thumb_size">16dp</dimen>
|
<dimen name="settingslib_switch_thumb_size">20dp</dimen>
|
||||||
<!-- Width of switch track -->
|
<!-- Width of switch track -->
|
||||||
<dimen name="settingslib_switch_track_width">48dp</dimen>
|
<dimen name="settingslib_switch_track_width">52dp</dimen>
|
||||||
<!-- Height of switch track -->
|
<!-- Height of switch track -->
|
||||||
<dimen name="settingslib_switch_track_height">24dp</dimen>
|
<dimen name="settingslib_switch_track_height">28dp</dimen>
|
||||||
<!-- Radius of switch track -->
|
<!-- Radius of switch track -->
|
||||||
<dimen name="settingslib_switch_track_radius">31dp</dimen>
|
<dimen name="settingslib_switch_track_radius">35dp</dimen>
|
||||||
|
|
||||||
|
<!-- Height percentage of the parent container occupied by the communal view -->
|
||||||
|
<item name="communal_source_height_percentage" format="float" type="dimen">0.80</item>
|
||||||
|
|
||||||
|
<dimen name="drag_and_drop_icon_size">70dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -3021,6 +3021,8 @@
|
|||||||
<string name="pref_title_network_details" msgid="7329759534269363308">"Network details"</string>
|
<string name="pref_title_network_details" msgid="7329759534269363308">"Network details"</string>
|
||||||
<!-- Provider Model: Panel subtitle for tapping a network to connect to internet. [CHAR LIMIT=60] -->
|
<!-- Provider Model: Panel subtitle for tapping a network to connect to internet. [CHAR LIMIT=60] -->
|
||||||
<string name="tap_a_network_to_connect">Tap a network to connect</string>
|
<string name="tap_a_network_to_connect">Tap a network to connect</string>
|
||||||
|
<!-- Provider Model: Panel subtitle for unlocking screen to view networks. [CHAR LIMIT=60] -->
|
||||||
|
<string name="unlock_to_view_networks">Unlock to view networks</string>
|
||||||
<!-- Provider Model: Wi-Fi settings. text displayed when Wi-Fi is on and network list is empty [CHAR LIMIT=50]-->
|
<!-- Provider Model: Wi-Fi settings. text displayed when Wi-Fi is on and network list is empty [CHAR LIMIT=50]-->
|
||||||
<string name="wifi_empty_list_wifi_on">Searching for networks\u2026</string>
|
<string name="wifi_empty_list_wifi_on">Searching for networks\u2026</string>
|
||||||
<!-- Provider Model: Failure notification for connect -->
|
<!-- Provider Model: Failure notification for connect -->
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
}
|
}
|
||||||
|
|
||||||
return mInternetDialogController.getWifiEntryList().stream()
|
return mInternetDialogController.getWifiEntryList().stream()
|
||||||
.filter(wifiEntry -> !wifiEntry.isDefaultNetwork())
|
.filter(wifiEntry -> (!wifiEntry.isDefaultNetwork()
|
||||||
|
|| !wifiEntry.hasInternetAccess()))
|
||||||
.limit(getItemCount())
|
.limit(getItemCount())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -107,21 +108,21 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
* {@link InternetDialog}.
|
* {@link InternetDialog}.
|
||||||
*
|
*
|
||||||
* Airplane mode is ON (mobile network is gone):
|
* Airplane mode is ON (mobile network is gone):
|
||||||
* Return four Wi-Fi's entries if no default Wi-Fi.
|
* Return four Wi-Fi's entries if no internet Wi-Fi.
|
||||||
* Return three Wi-Fi's entries if one default Wi-Fi.
|
* Return three Wi-Fi's entries if one internet Wi-Fi.
|
||||||
* Airplane mode is OFF (mobile network is visible):
|
* Airplane mode is OFF (mobile network is visible):
|
||||||
* Return three Wi-Fi's entries if no default Wi-Fi.
|
* Return three Wi-Fi's entries if no internet Wi-Fi.
|
||||||
* Return two Wi-Fi's entries if one default Wi-Fi.
|
* Return two Wi-Fi's entries if one internet Wi-Fi.
|
||||||
*
|
*
|
||||||
* @return The total number of networks.
|
* @return The total number of networks.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
final boolean hasDefaultWifi = mInternetDialogController.getDefaultWifiEntry() != null;
|
final boolean hasInternetWifi = mInternetDialogController.getInternetWifiEntry() != null;
|
||||||
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
||||||
return hasDefaultWifi ? 3 : 4;
|
return hasInternetWifi ? 3 : 4;
|
||||||
} else {
|
} else {
|
||||||
return hasDefaultWifi ? 2 : 3;
|
return hasInternetWifi ? 2 : 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private LinearLayout mMobileNetworkList;
|
private LinearLayout mMobileNetworkList;
|
||||||
private LinearLayout mTurnWifiOnLayout;
|
private LinearLayout mTurnWifiOnLayout;
|
||||||
private LinearLayout mSeeAllLayout;
|
private LinearLayout mSeeAllLayout;
|
||||||
private Space mSpace;
|
|
||||||
private RecyclerView mWifiRecyclerView;
|
private RecyclerView mWifiRecyclerView;
|
||||||
private ImageView mConnectedWifiIcon;
|
private ImageView mConnectedWifiIcon;
|
||||||
private ImageView mWifiSettingsIcon;
|
private ImageView mWifiSettingsIcon;
|
||||||
@@ -126,6 +125,7 @@ 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 mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
private boolean mCanConfigMobileData;
|
private boolean mCanConfigMobileData;
|
||||||
|
|
||||||
@@ -174,6 +174,8 @@ 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(
|
||||||
|
R.dimen.internet_dialog_list_max_width);
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mAdapter = new InternetAdapter(mInternetDialogController);
|
mAdapter = new InternetAdapter(mInternetDialogController);
|
||||||
if (!aboveStatusBar) {
|
if (!aboveStatusBar) {
|
||||||
@@ -200,7 +202,7 @@ 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(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
window.setLayout(mListMaxWidth, 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);
|
||||||
@@ -221,7 +223,6 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mWifiSettingsIcon = mDialogView.requireViewById(R.id.wifi_settings_icon);
|
mWifiSettingsIcon = mDialogView.requireViewById(R.id.wifi_settings_icon);
|
||||||
mWifiRecyclerView = mDialogView.requireViewById(R.id.wifi_list_layout);
|
mWifiRecyclerView = mDialogView.requireViewById(R.id.wifi_list_layout);
|
||||||
mSeeAllLayout = mDialogView.requireViewById(R.id.see_all_layout);
|
mSeeAllLayout = mDialogView.requireViewById(R.id.see_all_layout);
|
||||||
mSpace = mDialogView.requireViewById(R.id.space);
|
|
||||||
mDoneButton = mDialogView.requireViewById(R.id.done);
|
mDoneButton = mDialogView.requireViewById(R.id.done);
|
||||||
mSignalIcon = mDialogView.requireViewById(R.id.signal_icon);
|
mSignalIcon = mDialogView.requireViewById(R.id.signal_icon);
|
||||||
mMobileTitleText = mDialogView.requireViewById(R.id.mobile_title);
|
mMobileTitleText = mDialogView.requireViewById(R.id.mobile_title);
|
||||||
@@ -287,19 +288,27 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
showProgressBar();
|
showProgressBar();
|
||||||
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular());
|
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular());
|
||||||
setConnectedWifiLayout();
|
|
||||||
boolean isWifiEnabled = mWifiManager.isWifiEnabled();
|
final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked();
|
||||||
mWiFiToggle.setChecked(isWifiEnabled);
|
final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
|
||||||
int visible = isWifiEnabled ? View.VISIBLE : View.GONE;
|
updateWifiToggle(isWifiEnabled, isDeviceLocked);
|
||||||
mWifiRecyclerView.setVisibility(visible);
|
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
|
||||||
|
|
||||||
|
List<WifiEntry> wifiEntryList = mInternetDialogController.getWifiEntryList();
|
||||||
|
final int wifiListVisibility =
|
||||||
|
(isDeviceLocked || wifiEntryList == null || wifiEntryList.size() <= 0)
|
||||||
|
? View.GONE : View.VISIBLE;
|
||||||
|
mWifiRecyclerView.setVisibility(wifiListVisibility);
|
||||||
|
if (wifiListVisibility == View.VISIBLE) {
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
mSeeAllLayout.setVisibility(visible);
|
}
|
||||||
mSpace.setVisibility(isWifiEnabled ? View.GONE : View.VISIBLE);
|
mSeeAllLayout.setVisibility(wifiListVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnClickListener() {
|
private void setOnClickListener() {
|
||||||
mMobileNetworkLayout.setOnClickListener(v -> {
|
mMobileNetworkLayout.setOnClickListener(v -> {
|
||||||
if (mInternetDialogController.isMobileDataEnabled()) {
|
if (mInternetDialogController.isMobileDataEnabled()
|
||||||
|
&& !mInternetDialogController.isDeviceLocked()) {
|
||||||
if (!mInternetDialogController.activeNetworkIsCellular()) {
|
if (!mInternetDialogController.activeNetworkIsCellular()) {
|
||||||
mInternetDialogController.connectCarrierNetwork();
|
mInternetDialogController.connectCarrierNetwork();
|
||||||
}
|
}
|
||||||
@@ -320,7 +329,6 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
(buttonView, isChecked) -> {
|
(buttonView, isChecked) -> {
|
||||||
buttonView.setChecked(isChecked);
|
buttonView.setChecked(isChecked);
|
||||||
mWifiManager.setWifiEnabled(isChecked);
|
mWifiManager.setWifiEnabled(isChecked);
|
||||||
mSpace.setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
|
||||||
});
|
});
|
||||||
mDoneButton.setOnClickListener(v -> dismiss());
|
mDoneButton.setOnClickListener(v -> dismiss());
|
||||||
}
|
}
|
||||||
@@ -358,17 +366,23 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConnectedWifiLayout() {
|
private void updateWifiToggle(boolean isWifiEnabled, boolean isDeviceLocked) {
|
||||||
if (!mWifiManager.isWifiEnabled() || mConnectedWifiEntry == null) {
|
mWiFiToggle.setChecked(isWifiEnabled);
|
||||||
|
mTurnWifiOnLayout.setBackground(
|
||||||
|
(isDeviceLocked && mConnectedWifiEntry != null) ? mBackgroundOn : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConnectedWifi(boolean isWifiEnabled, boolean isDeviceLocked) {
|
||||||
|
if (!isWifiEnabled || mConnectedWifiEntry == null || isDeviceLocked) {
|
||||||
mConnectedWifListLayout.setBackground(null);
|
mConnectedWifListLayout.setBackground(null);
|
||||||
mConnectedWifListLayout.setVisibility(View.GONE);
|
mConnectedWifListLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
||||||
mConnectedWifiTitleText.setText(getConnectedWifiTitle());
|
mConnectedWifiTitleText.setText(mInternetDialogController.getInternetWifiTitle());
|
||||||
mConnectedWifiSummaryText.setText(getConnectedWifiSummary());
|
mConnectedWifiSummaryText.setText(mInternetDialogController.getInternetWifiSummary());
|
||||||
mConnectedWifiIcon.setImageDrawable(
|
mConnectedWifiIcon.setImageDrawable(
|
||||||
mInternetDialogController.getConnectedWifiDrawable(mConnectedWifiEntry));
|
mInternetDialogController.getInternetWifiDrawable(mConnectedWifiEntry));
|
||||||
if (mInternetDialogController.isNightMode()) {
|
if (mInternetDialogController.isNightMode()) {
|
||||||
mConnectedWifiTitleText.setTextColor(
|
mConnectedWifiTitleText.setTextColor(
|
||||||
mContext.getColor(R.color.connected_network_primary_color));
|
mContext.getColor(R.color.connected_network_primary_color));
|
||||||
@@ -409,16 +423,9 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
return mInternetDialogController.getMobileNetworkSummary();
|
return mInternetDialogController.getMobileNetworkSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getConnectedWifiTitle() {
|
|
||||||
return mInternetDialogController.getDefaultWifiTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getConnectedWifiSummary() {
|
|
||||||
return mInternetDialogController.getDefaultWifiSummary();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void showProgressBar() {
|
protected void showProgressBar() {
|
||||||
if (mWifiManager == null || !mWifiManager.isWifiEnabled()) {
|
if (mWifiManager == null || !mWifiManager.isWifiEnabled()
|
||||||
|
|| mInternetDialogController.isDeviceLocked()) {
|
||||||
setProgressBarVisible(false);
|
setProgressBarVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ import com.android.systemui.R;
|
|||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
import com.android.systemui.statusbar.policy.NetworkController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
||||||
import com.android.systemui.util.settings.GlobalSettings;
|
import com.android.systemui.util.settings.GlobalSettings;
|
||||||
@@ -97,6 +98,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
private static final int SUBTITLE_TEXT_WIFI_IS_OFF = R.string.wifi_is_off;
|
private static final int SUBTITLE_TEXT_WIFI_IS_OFF = R.string.wifi_is_off;
|
||||||
private static final int SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
private static final int SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
||||||
R.string.tap_a_network_to_connect;
|
R.string.tap_a_network_to_connect;
|
||||||
|
private static final int SUBTITLE_TEXT_UNLOCK_TO_VIEW_NETWORKS =
|
||||||
|
R.string.unlock_to_view_networks;
|
||||||
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
||||||
R.string.wifi_empty_list_wifi_on;
|
R.string.wifi_empty_list_wifi_on;
|
||||||
private static final int SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE =
|
private static final int SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE =
|
||||||
@@ -137,6 +140,9 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
KeyguardStateController mKeyguardStateController;
|
||||||
|
|
||||||
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
||||||
new KeyguardUpdateMonitorCallback() {
|
new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
@Override
|
||||||
@@ -161,7 +167,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
||||||
@Main Handler handler, @Main Executor mainExecutor,
|
@Main Handler handler, @Main Executor mainExecutor,
|
||||||
BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
GlobalSettings globalSettings) {
|
GlobalSettings globalSettings, KeyguardStateController keyguardStateController) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Init InternetDialogController");
|
Log.d(TAG, "Init InternetDialogController");
|
||||||
}
|
}
|
||||||
@@ -175,6 +181,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mSubscriptionManager = subscriptionManager;
|
mSubscriptionManager = subscriptionManager;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||||
|
mKeyguardStateController = keyguardStateController;
|
||||||
mConnectionStateFilter = new IntentFilter();
|
mConnectionStateFilter = new IntentFilter();
|
||||||
mConnectionStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
mConnectionStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
mConnectionStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
mConnectionStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
||||||
@@ -272,6 +279,15 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF);
|
return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDeviceLocked()) {
|
||||||
|
// When the device is locked.
|
||||||
|
// Sub-Title: Unlock to view networks
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "The device is locked.");
|
||||||
|
}
|
||||||
|
return mContext.getText(SUBTITLE_TEXT_UNLOCK_TO_VIEW_NETWORKS);
|
||||||
|
}
|
||||||
|
|
||||||
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
||||||
if (wifiList != null && wifiList.size() != 0) {
|
if (wifiList != null && wifiList.size() != 0) {
|
||||||
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
||||||
@@ -318,9 +334,9 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE);
|
return mContext.getText(SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable getConnectedWifiDrawable(@NonNull WifiEntry wifiEntry) {
|
Drawable getInternetWifiDrawable(@NonNull WifiEntry wifiEntry) {
|
||||||
final Drawable drawable =
|
final Drawable drawable =
|
||||||
mWifiIconInjector.getIcon(false /* noInternet*/, wifiEntry.getLevel());
|
mWifiIconInjector.getIcon(wifiEntry.shouldShowXLevelIcon(), wifiEntry.getLevel());
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -533,24 +549,24 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getDefaultWifiTitle() {
|
String getInternetWifiTitle() {
|
||||||
if (getDefaultWifiEntry() == null) {
|
if (getInternetWifiEntry() == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "connected entry is null");
|
Log.d(TAG, "connected entry is null");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getDefaultWifiEntry().getTitle();
|
return getInternetWifiEntry().getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getDefaultWifiSummary() {
|
String getInternetWifiSummary() {
|
||||||
if (getDefaultWifiEntry() == null) {
|
if (getInternetWifiEntry() == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "connected entry is null");
|
Log.d(TAG, "connected entry is null");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getDefaultWifiEntry().getSummary(false);
|
return getInternetWifiEntry().getSummary(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void launchNetworkSetting() {
|
void launchNetworkSetting() {
|
||||||
@@ -578,12 +594,13 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mWifiEntry;
|
return mWifiEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiEntry getDefaultWifiEntry() {
|
WifiEntry getInternetWifiEntry() {
|
||||||
if (mConnectedEntry != null && mConnectedEntry.isDefaultNetwork()) {
|
if (mConnectedEntry == null || !mConnectedEntry.isDefaultNetwork()
|
||||||
return mConnectedEntry;
|
|| !mConnectedEntry.hasInternetAccess()) {
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return mConnectedEntry;
|
||||||
|
}
|
||||||
|
|
||||||
WifiManager getWifiManager() {
|
WifiManager getWifiManager() {
|
||||||
return mWifiManager;
|
return mWifiManager;
|
||||||
@@ -683,6 +700,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
&& serviceState.getState() == serviceState.STATE_IN_SERVICE;
|
&& serviceState.getState() == serviceState.STATE_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeviceLocked() {
|
||||||
|
return !mKeyguardStateController.isUnlocked();
|
||||||
|
}
|
||||||
|
|
||||||
boolean activeNetworkIsCellular() {
|
boolean activeNetworkIsCellular() {
|
||||||
if (mConnectivityManager == null) {
|
if (mConnectivityManager == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -781,7 +802,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mConnectedEntry = null;
|
mConnectedEntry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCallback.onAccessPointsChanged(mWifiEntry, getDefaultWifiEntry());
|
mCallback.onAccessPointsChanged(mWifiEntry, getInternetWifiEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class AccessPointControllerImpl
|
|||||||
|
|
||||||
private final ArrayList<AccessPointCallback> mCallbacks = new ArrayList<AccessPointCallback>();
|
private final ArrayList<AccessPointCallback> mCallbacks = new ArrayList<AccessPointCallback>();
|
||||||
private final UserManager mUserManager;
|
private final UserManager mUserManager;
|
||||||
|
private final UserTracker mUserTracker;
|
||||||
private final Executor mMainExecutor;
|
private final Executor mMainExecutor;
|
||||||
|
|
||||||
private @Nullable WifiPickerTracker mWifiPickerTracker;
|
private @Nullable WifiPickerTracker mWifiPickerTracker;
|
||||||
@@ -85,6 +86,7 @@ public class AccessPointControllerImpl
|
|||||||
WifiPickerTrackerFactory wifiPickerTrackerFactory
|
WifiPickerTrackerFactory wifiPickerTrackerFactory
|
||||||
) {
|
) {
|
||||||
mUserManager = userManager;
|
mUserManager = userManager;
|
||||||
|
mUserTracker = userTracker;
|
||||||
mCurrentUser = userTracker.getUserId();
|
mCurrentUser = userTracker.getUserId();
|
||||||
mMainExecutor = mainExecutor;
|
mMainExecutor = mainExecutor;
|
||||||
mWifiPickerTrackerFactory = wifiPickerTrackerFactory;
|
mWifiPickerTrackerFactory = wifiPickerTrackerFactory;
|
||||||
@@ -121,7 +123,7 @@ public class AccessPointControllerImpl
|
|||||||
|
|
||||||
public boolean canConfigMobileData() {
|
public boolean canConfigMobileData() {
|
||||||
return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
|
return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
|
||||||
UserHandle.of(mCurrentUser));
|
UserHandle.of(mCurrentUser)) && mUserTracker.getUserInfo().isAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUserSwitched(int newUserId) {
|
public void onUserSwitched(int newUserId) {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
private static final String WIFI_TITLE = "Wi-Fi Title";
|
private static final String WIFI_TITLE = "Wi-Fi Title";
|
||||||
private static final String WIFI_SUMMARY = "Wi-Fi Summary";
|
private static final String WIFI_SUMMARY = "Wi-Fi Summary";
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mInternetWifiEntry;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mWifiEntry;
|
private WifiEntry mWifiEntry;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -45,41 +47,49 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
when(mInternetWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
mViewHolder = mInternetAdapter.onCreateViewHolder(new LinearLayout(mContext), 0);
|
when(mInternetWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
|
when(mInternetWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
|
when(mInternetWifiEntry.hasInternetAccess()).thenReturn(true);
|
||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
|
|
||||||
|
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
||||||
|
mViewHolder = mInternetAdapter.onCreateViewHolder(new LinearLayout(mContext), 0);
|
||||||
|
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(mInternetWifiEntry);
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
||||||
mViewHolder.mWifiIconInjector = mWifiIconInjector;
|
mViewHolder.mWifiIconInjector = mWifiIconInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOnWifiOnNoDefaultWifi_returnFour() {
|
public void getItemCount_withApmOnWifiOnNoInternetWifi_returnFour() {
|
||||||
|
// The preconditions WiFi ON is already in setUp()
|
||||||
|
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(null);
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(4);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOnWifiOnHasDefaultWifi_returnThree() {
|
public void getItemCount_withApmOnWifiOnHasInternetWifi_returnThree() {
|
||||||
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
||||||
when(mInternetDialogController.getDefaultWifiEntry()).thenReturn(mWifiEntry);
|
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOffWifiOnNoDefaultWifi_returnThree() {
|
public void getItemCount_withApmOffWifiOnNoInternetWifi_returnThree() {
|
||||||
|
// The preconditions WiFi ON is already in setUp()
|
||||||
|
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(null);
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOffWifiOnHasDefaultWifi_returnTwo() {
|
public void getItemCount_withApmOffWifiOnHasInternetWifi_returnTwo() {
|
||||||
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
||||||
when(mInternetDialogController.getDefaultWifiEntry()).thenReturn(mWifiEntry);
|
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(2);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(2);
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ 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.ScanResult;
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
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;
|
||||||
@@ -33,13 +32,13 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.settingslib.Utils;
|
|
||||||
import com.android.settingslib.wifi.WifiUtils;
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
import com.android.systemui.statusbar.policy.NetworkController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
@@ -79,14 +78,12 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private GlobalSettings mGlobalSettings;
|
private GlobalSettings mGlobalSettings;
|
||||||
@Mock
|
@Mock
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardStateController mKeyguardStateController;
|
||||||
@Mock
|
@Mock
|
||||||
private NetworkController.AccessPointController mAccessPointController;
|
private NetworkController.AccessPointController mAccessPointController;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mConnectedEntry;
|
private WifiEntry mConnectedEntry;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiInfo mWifiInfo;
|
|
||||||
@Mock
|
|
||||||
private ServiceState mServiceState;
|
private ServiceState mServiceState;
|
||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
@@ -99,15 +96,16 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
|
||||||
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
|
||||||
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
|
when(mConnectedEntry.hasInternetAccess()).thenReturn(true);
|
||||||
|
|
||||||
mInternetDialogController = new MockInternetDialogController(mContext,
|
mInternetDialogController = new MockInternetDialogController(mContext,
|
||||||
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
||||||
mSubscriptionManager, mTelephonyManager, mWifiManager,
|
mSubscriptionManager, mTelephonyManager, mWifiManager,
|
||||||
mock(ConnectivityManager.class), mHandler, mExecutor, mBroadcastDispatcher,
|
mock(ConnectivityManager.class), mHandler, mExecutor, mBroadcastDispatcher,
|
||||||
mKeyguardUpdateMonitor, mGlobalSettings);
|
mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController);
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||||
mInternetDialogController.mOnSubscriptionsChangedListener);
|
mInternetDialogController.mOnSubscriptionsChangedListener);
|
||||||
mInternetDialogController.onStart(
|
mInternetDialogController.onStart(
|
||||||
@@ -173,6 +171,16 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
getResourcesString("tap_a_network_to_connect")));
|
getResourcesString("tap_a_network_to_connect")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSubtitleText_deviceLockedWithWifiOn_returnUnlockToViewNetworks() {
|
||||||
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||||
|
|
||||||
|
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(false),
|
||||||
|
getResourcesString("unlock_to_view_networks")));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleText_withNoService_returnNoNetworksAvailable() {
|
public void getSubtitleText_withNoService_returnNoNetworksAvailable() {
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
@@ -211,53 +219,62 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiEntry_connectedEntryIsNull_returnNull() {
|
public void getInternetWifiEntry_connectedEntryIsNull_returnNull() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiEntry()).isNull();
|
assertThat(mInternetDialogController.getInternetWifiEntry()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiEntry_connectedEntryIsNotDefault_returnNull() {
|
public void getInternetWifiEntry_connectedWifiIsNotDefaultNetwork_returnNull() {
|
||||||
when(mConnectedEntry.isDefaultNetwork()).thenReturn(false);
|
when(mConnectedEntry.isDefaultNetwork()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiEntry()).isNull();
|
assertThat(mInternetDialogController.getInternetWifiEntry()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiEntry_connectedEntryIsDefault_returnConnectedEntry() {
|
public void getInternetWifiEntry_connectedWifiHasNotInternetAccess_returnNull() {
|
||||||
// The default conditions have been set in setUp().
|
when(mConnectedEntry.hasInternetAccess()).thenReturn(false);
|
||||||
// - The connected Wi-Fi entry with the default network condition.
|
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiEntry()).isEqualTo(mConnectedEntry);
|
assertThat(mInternetDialogController.getInternetWifiEntry()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiTitle_withNoDefaultEntry_returnEmpty() {
|
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;
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiTitle()).isEmpty();
|
assertThat(mInternetDialogController.getInternetWifiTitle()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiTitle_withDefaultEntry_returnTitle() {
|
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);
|
when(mConnectedEntry.getTitle()).thenReturn(CONNECTED_TITLE);
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiTitle()).isEqualTo(CONNECTED_TITLE);
|
assertThat(mInternetDialogController.getInternetWifiTitle()).isEqualTo(CONNECTED_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiSummary_withNoDefaultEntry_returnEmpty() {
|
public void getInternetWifiSummary_withNoConnectedWifiEntry_returnEmpty() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiSummary()).isEmpty();
|
assertThat(mInternetDialogController.getInternetWifiSummary()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDefaultWifiSummary_withDefaultEntry_returnSummary() {
|
public void getInternetWifiSummary_withInternetWifi_returnSummary() {
|
||||||
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
||||||
|
|
||||||
assertThat(mInternetDialogController.getDefaultWifiSummary()).isEqualTo(CONNECTED_SUMMARY);
|
assertThat(mInternetDialogController.getInternetWifiSummary()).isEqualTo(CONNECTED_SUMMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -282,11 +299,11 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWifiConnectedDrawable_withConnectedEntry_returnIntentIconWithColorAccent() {
|
public void getWifiDrawable_withConnectedEntry_returnIntentIconWithCorrectColor() {
|
||||||
final Drawable drawable = mock(Drawable.class);
|
final Drawable drawable = mock(Drawable.class);
|
||||||
when(mWifiIconInjector.getIcon(anyBoolean(), anyInt())).thenReturn(drawable);
|
when(mWifiIconInjector.getIcon(anyBoolean(), anyInt())).thenReturn(drawable);
|
||||||
|
|
||||||
mInternetDialogController.getConnectedWifiDrawable(mConnectedEntry);
|
mInternetDialogController.getInternetWifiDrawable(mConnectedEntry);
|
||||||
|
|
||||||
verify(mWifiIconInjector).getIcon(eq(false), anyInt());
|
verify(mWifiIconInjector).getIcon(eq(false), anyInt());
|
||||||
verify(drawable).setTint(mContext.getColor(R.color.connected_network_primary_color));
|
verify(drawable).setTint(mContext.getColor(R.color.connected_network_primary_color));
|
||||||
@@ -311,6 +328,20 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
verify(mActivityStarter).postStartActivityDismissingKeyguard(any(Intent.class), anyInt());
|
verify(mActivityStarter).postStartActivityDismissingKeyguard(any(Intent.class), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isDeviceLocked_keyguardIsUnlocked_returnFalse() {
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.isDeviceLocked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isDeviceLocked_keyguardIsLocked_returnTrue() {
|
||||||
|
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.isDeviceLocked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private String getResourcesString(String name) {
|
private String getResourcesString(String name) {
|
||||||
return mContext.getResources().getString(getResourcesId(name));
|
return mContext.getResources().getString(getResourcesId(name));
|
||||||
}
|
}
|
||||||
@@ -331,10 +362,12 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
||||||
@Main Handler handler, @Main Executor mainExecutor,
|
@Main Handler handler, @Main Executor mainExecutor,
|
||||||
BroadcastDispatcher broadcastDispatcher,
|
BroadcastDispatcher broadcastDispatcher,
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings) {
|
KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings,
|
||||||
|
KeyguardStateController keyguardStateController) {
|
||||||
super(context, uiEventLogger, starter, accessPointController, subscriptionManager,
|
super(context, uiEventLogger, starter, accessPointController, subscriptionManager,
|
||||||
telephonyManager, wifiManager, connectivityManager, handler, mainExecutor,
|
telephonyManager, wifiManager, connectivityManager, handler, mainExecutor,
|
||||||
broadcastDispatcher, keyguardUpdateMonitor, globalSettings);
|
broadcastDispatcher, keyguardUpdateMonitor, globalSettings,
|
||||||
|
keyguardStateController);
|
||||||
mGlobalSettings = globalSettings;
|
mGlobalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
@@ -11,12 +12,7 @@ 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.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.net.wifi.ScanResult;
|
import android.net.wifi.ScanResult;
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
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;
|
||||||
@@ -32,7 +28,6 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -53,52 +48,61 @@ import java.util.List;
|
|||||||
@TestableLooper.RunWithLooper(setAsMainLooper = true)
|
@TestableLooper.RunWithLooper(setAsMainLooper = true)
|
||||||
public class InternetDialogTest extends SysuiTestCase {
|
public class InternetDialogTest extends SysuiTestCase {
|
||||||
|
|
||||||
private static final int SUB_ID = 1;
|
|
||||||
private static final String MOBILE_NETWORK_TITLE = "Mobile Title";
|
private static final String MOBILE_NETWORK_TITLE = "Mobile Title";
|
||||||
private static final String MOBILE_NETWORK_SUMMARY = "Mobile Summary";
|
private static final String MOBILE_NETWORK_SUMMARY = "Mobile Summary";
|
||||||
private static final String WIFI_TITLE = "Connected Wi-Fi Title";
|
private static final String WIFI_TITLE = "Connected Wi-Fi Title";
|
||||||
private static final String WIFI_SUMMARY = "Connected Wi-Fi Summary";
|
private static final String WIFI_SUMMARY = "Connected Wi-Fi Summary";
|
||||||
|
|
||||||
private final UiEventLogger mUiEventLogger = mock(UiEventLogger.class);
|
|
||||||
|
|
||||||
private InternetDialogFactory mInternetDialogFactory = mock(InternetDialogFactory.class);
|
|
||||||
private InternetAdapter mInternetAdapter = mock(InternetAdapter.class);
|
|
||||||
private InternetDialogController mInternetDialogController = mock(
|
|
||||||
InternetDialogController.class);
|
|
||||||
private InternetDialogController.InternetDialogCallback mCallback =
|
|
||||||
mock(InternetDialogController.InternetDialogCallback.class);
|
|
||||||
private MockInternetDialog mInternetDialog;
|
|
||||||
private WifiReceiver mWifiReceiver = null;
|
|
||||||
private WifiManager mMockWifiManager = mock(WifiManager.class);
|
|
||||||
private TelephonyManager mTelephonyManager = mock(TelephonyManager.class);
|
|
||||||
@Mock
|
|
||||||
private WifiEntry mWifiEntry = mock(WifiEntry.class);
|
|
||||||
@Mock
|
|
||||||
private WifiInfo mWifiInfo;
|
|
||||||
@Mock
|
@Mock
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
@Mock
|
||||||
|
private TelephonyManager mTelephonyManager;
|
||||||
|
@Mock
|
||||||
|
private WifiManager mWifiManager;
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mInternetWifiEntry;
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry;
|
||||||
|
@Mock
|
||||||
|
private InternetAdapter mInternetAdapter;
|
||||||
|
@Mock
|
||||||
|
private InternetDialogController mInternetDialogController;
|
||||||
|
|
||||||
|
private InternetDialog mInternetDialog;
|
||||||
|
private LinearLayout mWifiToggle;
|
||||||
|
private LinearLayout mConnectedWifi;
|
||||||
|
private RecyclerView mWifiList;
|
||||||
|
private LinearLayout mSeeAll;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mInternetDialog = new MockInternetDialog(mContext, mInternetDialogFactory,
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
|
||||||
mInternetDialogController, true, true, mUiEventLogger, mHandler);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
mInternetDialog.show();
|
when(mInternetWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
when(mInternetWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mInternetWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
when(mMockWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
when(mInternetWifiEntry.hasInternetAccess()).thenReturn(true);
|
||||||
mInternetDialog.setMobileNetworkTitle(MOBILE_NETWORK_TITLE);
|
|
||||||
mInternetDialog.setMobileNetworkSummary(MOBILE_NETWORK_SUMMARY);
|
|
||||||
mInternetDialog.setConnectedWifiTitle(WIFI_TITLE);
|
|
||||||
mInternetDialog.setConnectedWifiSummary(WIFI_SUMMARY);
|
|
||||||
mWifiReceiver = new WifiReceiver();
|
|
||||||
IntentFilter mIntentFilter = new IntentFilter();
|
|
||||||
mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
|
||||||
mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
|
||||||
mContext.registerReceiver(mWifiReceiver, mIntentFilter);
|
|
||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
|
|
||||||
|
when(mInternetDialogController.getMobileNetworkTitle()).thenReturn(MOBILE_NETWORK_TITLE);
|
||||||
|
when(mInternetDialogController.getMobileNetworkSummary())
|
||||||
|
.thenReturn(MOBILE_NETWORK_SUMMARY);
|
||||||
|
when(mInternetDialogController.getWifiManager()).thenReturn(mWifiManager);
|
||||||
|
when(mInternetDialogController.getInternetWifiEntry()).thenReturn(mInternetWifiEntry);
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
||||||
|
|
||||||
|
mInternetDialog = new InternetDialog(mContext, mock(InternetDialogFactory.class),
|
||||||
|
mInternetDialogController, true, true, mock(UiEventLogger.class), mHandler);
|
||||||
|
mInternetDialog.mAdapter = mInternetAdapter;
|
||||||
|
mInternetDialog.mConnectedWifiEntry = mInternetWifiEntry;
|
||||||
|
mInternetDialog.show();
|
||||||
|
|
||||||
|
mWifiToggle = mInternetDialog.mDialogView.requireViewById(R.id.turn_on_wifi_layout);
|
||||||
|
mConnectedWifi = mInternetDialog.mDialogView.requireViewById(R.id.wifi_connected_layout);
|
||||||
|
mWifiList = mInternetDialog.mDialogView.requireViewById(R.id.wifi_list_layout);
|
||||||
|
mSeeAll = mInternetDialog.mDialogView.requireViewById(R.id.see_all_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -137,46 +141,80 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withWifiOnAndHasConnectedWifi_connectedWifiLayoutVisible() {
|
public void updateDialog_wifiOnAndHasInternetWifi_showConnectedWifi() {
|
||||||
|
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
||||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
|
||||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
|
||||||
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
|
||||||
mInternetDialog.mConnectedWifiEntry = mWifiEntry;
|
|
||||||
|
|
||||||
mInternetDialog.updateDialog();
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
R.id.wifi_connected_layout);
|
|
||||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withWifiOnAndNoConnectedWifi_connectedWifiLayoutGone() {
|
public void updateDialog_wifiOnAndNoConnectedWifi_hideConnectedWifi() {
|
||||||
|
mInternetDialog.mConnectedWifiEntry = null;
|
||||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.wifi_connected_layout);
|
|
||||||
|
|
||||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.GONE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_withWifiOff_WifiRecycleViewGone() {
|
public void updateDialog_wifiOnAndNoWifiList_hideWifiListAndSeeAll() {
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(false);
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(null);
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
final RecyclerView view = mInternetDialog.mDialogView.requireViewById(
|
|
||||||
R.id.wifi_list_layout);
|
|
||||||
|
|
||||||
assertThat(view.getVisibility()).isEqualTo(View.GONE);
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onClickSeeMoreButton_clickSeeMore_verifyLaunchNetworkSetting() {
|
public void updateDialog_wifiOnAndHasWifiList_showWifiListAndSeeAll() {
|
||||||
final LinearLayout seeAllLayout = mInternetDialog.mDialogView.requireViewById(
|
// The preconditions WiFi ON and WiFi entries are already in setUp()
|
||||||
R.id.see_all_layout);
|
|
||||||
seeAllLayout.performClick();
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDialog_deviceLockedAndHasInternetWifi_showHighlightWifiToggle() {
|
||||||
|
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiToggle.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mWifiToggle.getBackground()).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDialog_deviceLockedAndHasInternetWifi_hideConnectedWifi() {
|
||||||
|
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDialog_deviceLockedAndHasWifiList_hideWifiListAndSeeAll() {
|
||||||
|
// The preconditions WiFi entries are already in setUp()
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
|
||||||
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onClickSeeMoreButton_clickSeeAll_verifyLaunchNetworkSetting() {
|
||||||
|
mSeeAll.performClick();
|
||||||
|
|
||||||
verify(mInternetDialogController).launchNetworkSetting();
|
verify(mInternetDialogController).launchNetworkSetting();
|
||||||
}
|
}
|
||||||
@@ -184,7 +222,18 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void showProgressBar_wifiDisabled_hideProgressBar() {
|
public void showProgressBar_wifiDisabled_hideProgressBar() {
|
||||||
Mockito.reset(mHandler);
|
Mockito.reset(mHandler);
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(false);
|
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||||
|
|
||||||
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isFalse();
|
||||||
|
verify(mHandler, never()).postDelayed(any(Runnable.class), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showProgressBar_deviceLocked_hideProgressBar() {
|
||||||
|
Mockito.reset(mHandler);
|
||||||
|
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
|
||||||
|
|
||||||
mInternetDialog.showProgressBar();
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
@@ -195,10 +244,10 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
||||||
Mockito.reset(mHandler);
|
Mockito.reset(mHandler);
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
||||||
when(wifiScanResults.size()).thenReturn(1);
|
when(wifiScanResults.size()).thenReturn(1);
|
||||||
when(mMockWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
||||||
|
|
||||||
mInternetDialog.showProgressBar();
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
@@ -217,10 +266,10 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void showProgressBar_wifiEnabledWithoutWifiScanResults_showProgressBarThenHideSearch() {
|
public void showProgressBar_wifiEnabledWithoutWifiScanResults_showProgressBarThenHideSearch() {
|
||||||
Mockito.reset(mHandler);
|
Mockito.reset(mHandler);
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
||||||
when(wifiScanResults.size()).thenReturn(0);
|
when(wifiScanResults.size()).thenReturn(0);
|
||||||
when(mMockWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
||||||
|
|
||||||
mInternetDialog.showProgressBar();
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
@@ -236,78 +285,4 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
||||||
assertThat(mInternetDialog.mIsSearchingHidden).isTrue();
|
assertThat(mInternetDialog.mIsSearchingHidden).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MockInternetDialog extends InternetDialog {
|
|
||||||
|
|
||||||
private String mMobileNetworkTitle;
|
|
||||||
private String mMobileNetworkSummary;
|
|
||||||
private String mConnectedWifiTitle;
|
|
||||||
private String mConnectedWifiSummary;
|
|
||||||
|
|
||||||
MockInternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
|
||||||
InternetDialogController internetDialogController, boolean canConfigMobileData,
|
|
||||||
boolean aboveStatusBar, UiEventLogger uiEventLogger, @Main Handler handler) {
|
|
||||||
super(context, internetDialogFactory, internetDialogController, canConfigMobileData,
|
|
||||||
aboveStatusBar, uiEventLogger, handler);
|
|
||||||
mAdapter = mInternetAdapter;
|
|
||||||
mWifiManager = mMockWifiManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getMobileNetworkTitle() {
|
|
||||||
return mMobileNetworkTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getMobileNetworkSummary() {
|
|
||||||
return mMobileNetworkSummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMobileNetworkTitle(String title) {
|
|
||||||
mMobileNetworkTitle = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMobileNetworkSummary(String summary) {
|
|
||||||
mMobileNetworkSummary = summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getConnectedWifiTitle() {
|
|
||||||
return mConnectedWifiTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String getConnectedWifiSummary() {
|
|
||||||
return mConnectedWifiSummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setConnectedWifiTitle(String title) {
|
|
||||||
mConnectedWifiTitle = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setConnectedWifiSummary(String summary) {
|
|
||||||
mConnectedWifiSummary = summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWifiStateReceived(Context context, Intent intent) {
|
|
||||||
setMobileNetworkTitle(MOBILE_NETWORK_TITLE);
|
|
||||||
setMobileNetworkSummary(MOBILE_NETWORK_SUMMARY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class WifiReceiver extends BroadcastReceiver {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (action.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
|
||||||
mInternetDialog.updateDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user