Merge "[Provider Model] Show airplane off button and carrier network if airplane mode is on" into sc-v2-dev
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/internet_dialog_title"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
@@ -154,12 +155,18 @@
|
||||
<TextView
|
||||
android:id="@+id/mobile_summary"
|
||||
style="@style/InternetDialog.NetworkSummary"/>
|
||||
<TextView
|
||||
android:id="@+id/airplane_mode_summary"
|
||||
android:text="@string/airplane_mode"
|
||||
android:visibility="gone"
|
||||
style="@style/InternetDialog.NetworkSummary"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/mobile_toggle_divider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="?android:attr/textColorSecondary"/>
|
||||
@@ -370,27 +377,60 @@
|
||||
android:clickable="true"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/done_layout"
|
||||
android:layout_width="67dp"
|
||||
android:id="@+id/button_layout"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="34dp"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
<Button
|
||||
android:text="@string/inline_done_button"
|
||||
style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="center"
|
||||
android:textAppearance="@style/TextAppearance.InternetDialog"
|
||||
android:textSize="14sp"
|
||||
android:background="@drawable/internet_dialog_footer_background"
|
||||
android:clickable="false"/>
|
||||
android:clickable="false"
|
||||
android:focusable="false">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/apm_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:orientation="vertical">
|
||||
<Button
|
||||
android:text="@string/turn_off_airplane_mode"
|
||||
android:ellipsize="end"
|
||||
style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:textAppearance="@style/TextAppearance.InternetDialog"
|
||||
android:textSize="14sp"
|
||||
android:background="@drawable/internet_dialog_footer_background"
|
||||
android:clickable="false"/>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/done_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:orientation="vertical">
|
||||
<Button
|
||||
android:text="@string/inline_done_button"
|
||||
android:ellipsize="end"
|
||||
style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
||||
android:layout_width="67dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:textAppearance="@style/TextAppearance.InternetDialog"
|
||||
android:textSize="14sp"
|
||||
android:background="@drawable/internet_dialog_footer_background"
|
||||
android:clickable="false"/>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
@@ -2336,6 +2336,8 @@
|
||||
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
|
||||
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi scanning is on. [CHAR LIMIT=NONE] -->
|
||||
<string name="wifi_scan_notify_message">To improve device experience, apps and services can still scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. You can change this in Wi\u2011Fi scanning settings. <annotation id="link">Change</annotation></string>
|
||||
<!-- Provider Model: Description of the airplane mode button. [CHAR LIMIT=60] -->
|
||||
<string name="turn_off_airplane_mode">Turn off airplane mode</string>
|
||||
|
||||
<!-- Title for User Switch dialog. [CHAR LIMIT=20] -->
|
||||
<string name="qs_user_switch_dialog_title">Select user</string>
|
||||
|
||||
@@ -120,10 +120,12 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
private ImageView mSignalIcon;
|
||||
private TextView mMobileTitleText;
|
||||
private TextView mMobileSummaryText;
|
||||
private TextView mAirplaneModeSummaryText;
|
||||
private Switch mMobileDataToggle;
|
||||
private View mMobileToggleDivider;
|
||||
private Switch mWiFiToggle;
|
||||
private FrameLayout mDoneLayout;
|
||||
private FrameLayout mAirplaneModeLayout;
|
||||
private Drawable mBackgroundOn;
|
||||
private Drawable mBackgroundOff = null;
|
||||
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
@@ -210,9 +212,11 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mWifiRecyclerView = mDialogView.requireViewById(R.id.wifi_list_layout);
|
||||
mSeeAllLayout = mDialogView.requireViewById(R.id.see_all_layout);
|
||||
mDoneLayout = mDialogView.requireViewById(R.id.done_layout);
|
||||
mAirplaneModeLayout = mDialogView.requireViewById(R.id.apm_layout);
|
||||
mSignalIcon = mDialogView.requireViewById(R.id.signal_icon);
|
||||
mMobileTitleText = mDialogView.requireViewById(R.id.mobile_title);
|
||||
mMobileSummaryText = mDialogView.requireViewById(R.id.mobile_summary);
|
||||
mAirplaneModeSummaryText = mDialogView.requireViewById(R.id.airplane_mode_summary);
|
||||
mMobileToggleDivider = mDialogView.requireViewById(R.id.mobile_toggle_divider);
|
||||
mMobileDataToggle = mDialogView.requireViewById(R.id.mobile_toggle);
|
||||
mWiFiToggle = mDialogView.requireViewById(R.id.wifi_toggle);
|
||||
@@ -230,6 +234,8 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
|
||||
setOnClickListener();
|
||||
mTurnWifiOnLayout.setBackground(null);
|
||||
mAirplaneModeLayout.setVisibility(
|
||||
mInternetDialogController.isAirplaneModeEnabled() ? View.VISIBLE : View.GONE);
|
||||
mWifiRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
mWifiRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
@@ -269,6 +275,7 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mSeeAllLayout.setOnClickListener(null);
|
||||
mWiFiToggle.setOnCheckedChangeListener(null);
|
||||
mDoneLayout.setOnClickListener(null);
|
||||
mAirplaneModeLayout.setOnClickListener(null);
|
||||
mInternetDialogController.onStop();
|
||||
mInternetDialogFactory.destroyDialog();
|
||||
}
|
||||
@@ -294,13 +301,17 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
}
|
||||
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
||||
mInternetDialogSubTitle.setVisibility(View.GONE);
|
||||
mAirplaneModeLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mInternetDialogTitle.setText(getDialogTitleText());
|
||||
mInternetDialogSubTitle.setVisibility(View.VISIBLE);
|
||||
mInternetDialogSubTitle.setText(getSubtitleText());
|
||||
mAirplaneModeLayout.setVisibility(View.GONE);
|
||||
}
|
||||
updateEthernet();
|
||||
if (shouldUpdateMobileNetwork) {
|
||||
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular()
|
||||
|| mInternetDialogController.isCarrierNetworkActive());
|
||||
setMobileDataLayout(mInternetDialogController.activeNetworkIsCellular(),
|
||||
mInternetDialogController.isCarrierNetworkActive());
|
||||
}
|
||||
|
||||
if (!mCanConfigWifi) {
|
||||
@@ -343,6 +354,9 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mWifiManager.setWifiEnabled(isChecked);
|
||||
});
|
||||
mDoneLayout.setOnClickListener(v -> dismiss());
|
||||
mAirplaneModeLayout.setOnClickListener(v -> {
|
||||
mInternetDialogController.setAirplaneModeDisabled();
|
||||
});
|
||||
}
|
||||
|
||||
@MainThread
|
||||
@@ -351,42 +365,60 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mInternetDialogController.hasEthernet() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void setMobileDataLayout(boolean isCarrierNetworkConnected) {
|
||||
if (mInternetDialogController.isAirplaneModeEnabled()
|
||||
|| !mInternetDialogController.hasCarrier()) {
|
||||
private void setMobileDataLayout(boolean activeNetworkIsCellular,
|
||||
boolean isCarrierNetworkActive) {
|
||||
boolean isNetworkConnected = activeNetworkIsCellular || isCarrierNetworkActive;
|
||||
// 1. Mobile network should be gone if airplane mode ON or the list of active
|
||||
// subscriptionId is null.
|
||||
// 2. Carrier network should be gone if airplane mode ON and Wi-Fi is OFF.
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "setMobileDataLayout, isCarrierNetworkActive = " + isCarrierNetworkActive);
|
||||
}
|
||||
|
||||
if (!mInternetDialogController.hasActiveSubId()
|
||||
&& (!mWifiManager.isWifiEnabled() || !isCarrierNetworkActive)) {
|
||||
mMobileNetworkLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
mMobileDataToggle.setChecked(mInternetDialogController.isMobileDataEnabled());
|
||||
mMobileNetworkLayout.setVisibility(View.VISIBLE);
|
||||
mMobileDataToggle.setChecked(mInternetDialogController.isMobileDataEnabled());
|
||||
mMobileTitleText.setText(getMobileNetworkTitle());
|
||||
if (!TextUtils.isEmpty(getMobileNetworkSummary())) {
|
||||
String summary = getMobileNetworkSummary();
|
||||
if (!TextUtils.isEmpty(summary)) {
|
||||
mMobileSummaryText.setText(
|
||||
Html.fromHtml(getMobileNetworkSummary(), Html.FROM_HTML_MODE_LEGACY));
|
||||
Html.fromHtml(summary, Html.FROM_HTML_MODE_LEGACY));
|
||||
mMobileSummaryText.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mMobileSummaryText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mBackgroundExecutor.execute(() -> {
|
||||
Drawable drawable = getSignalStrengthDrawable();
|
||||
mHandler.post(() -> {
|
||||
mSignalIcon.setImageDrawable(drawable);
|
||||
});
|
||||
});
|
||||
mMobileTitleText.setTextAppearance(isCarrierNetworkConnected
|
||||
mMobileTitleText.setTextAppearance(isNetworkConnected
|
||||
? R.style.TextAppearance_InternetDialog_Active
|
||||
: R.style.TextAppearance_InternetDialog);
|
||||
mMobileSummaryText.setTextAppearance(isCarrierNetworkConnected
|
||||
int secondaryRes = isNetworkConnected
|
||||
? R.style.TextAppearance_InternetDialog_Secondary_Active
|
||||
: R.style.TextAppearance_InternetDialog_Secondary);
|
||||
: R.style.TextAppearance_InternetDialog_Secondary;
|
||||
mMobileSummaryText.setTextAppearance(secondaryRes);
|
||||
// Set airplane mode to the summary for carrier network
|
||||
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
||||
mAirplaneModeSummaryText.setVisibility(View.VISIBLE);
|
||||
mAirplaneModeSummaryText.setText(mContext.getText(R.string.airplane_mode));
|
||||
mAirplaneModeSummaryText.setTextAppearance(secondaryRes);
|
||||
} else {
|
||||
mAirplaneModeSummaryText.setVisibility(View.GONE);
|
||||
}
|
||||
mMobileNetworkLayout.setBackground(
|
||||
isCarrierNetworkConnected ? mBackgroundOn : mBackgroundOff);
|
||||
isNetworkConnected ? mBackgroundOn : mBackgroundOff);
|
||||
|
||||
TypedArray array = mContext.obtainStyledAttributes(
|
||||
R.style.InternetDialog_Divider_Active, new int[]{android.R.attr.background});
|
||||
int dividerColor = Utils.getColorAttrDefaultColor(mContext,
|
||||
android.R.attr.textColorSecondary);
|
||||
mMobileToggleDivider.setBackgroundColor(isCarrierNetworkConnected
|
||||
mMobileToggleDivider.setBackgroundColor(isNetworkConnected
|
||||
? array.getColor(0, dividerColor) : dividerColor);
|
||||
array.recycle();
|
||||
|
||||
@@ -620,10 +652,13 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
@WorkerThread
|
||||
public void onAccessPointsChanged(@Nullable List<WifiEntry> wifiEntries,
|
||||
@Nullable WifiEntry connectedEntry) {
|
||||
// Should update the carrier network layout when it is connected under airplane mode ON.
|
||||
boolean shouldUpdateCarrierNetwork = mMobileNetworkLayout.getVisibility() == View.VISIBLE
|
||||
&& mInternetDialogController.isAirplaneModeEnabled();
|
||||
mHandler.post(() -> {
|
||||
mConnectedWifiEntry = connectedEntry;
|
||||
mWifiEntriesCount = wifiEntries == null ? 0 : wifiEntries.size();
|
||||
updateDialog(false /* shouldUpdateMobileNetwork */);
|
||||
updateDialog(shouldUpdateCarrierNetwork /* shouldUpdateMobileNetwork */);
|
||||
mAdapter.setWifiEntries(wifiEntries, mWifiEntriesCount);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
});
|
||||
|
||||
@@ -281,6 +281,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
return mGlobalSettings.getInt(Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
|
||||
}
|
||||
|
||||
void setAirplaneModeDisabled() {
|
||||
mConnectivityManager.setAirplaneMode(false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultDataSubscriptionId() {
|
||||
return mSubscriptionManager.getDefaultDataSubscriptionId();
|
||||
@@ -352,7 +356,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "No Wi-Fi item.");
|
||||
}
|
||||
if (!hasCarrier() || (!isVoiceStateInService() && !isDataStateInService())) {
|
||||
if (!hasActiveSubId() || (!isVoiceStateInService() && !isDataStateInService())) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "No carrier or service is out of service.");
|
||||
}
|
||||
@@ -403,15 +407,16 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
return drawable;
|
||||
}
|
||||
|
||||
if (isDataStateInService() || isVoiceStateInService()) {
|
||||
boolean isCarrierNetworkActive = isCarrierNetworkActive();
|
||||
if (isDataStateInService() || isVoiceStateInService() || isCarrierNetworkActive) {
|
||||
AtomicReference<Drawable> shared = new AtomicReference<>();
|
||||
shared.set(getSignalStrengthDrawableWithLevel());
|
||||
shared.set(getSignalStrengthDrawableWithLevel(isCarrierNetworkActive));
|
||||
drawable = shared.get();
|
||||
}
|
||||
|
||||
int tintColor = Utils.getColorAttrDefaultColor(mContext,
|
||||
android.R.attr.textColorTertiary);
|
||||
if (activeNetworkIsCellular() || isCarrierNetworkActive()) {
|
||||
if (activeNetworkIsCellular() || isCarrierNetworkActive) {
|
||||
tintColor = mContext.getColor(R.color.connected_network_primary_color);
|
||||
}
|
||||
drawable.setTint(tintColor);
|
||||
@@ -426,12 +431,15 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
*
|
||||
* @return The Drawable which is a signal bar icon with level.
|
||||
*/
|
||||
Drawable getSignalStrengthDrawableWithLevel() {
|
||||
Drawable getSignalStrengthDrawableWithLevel(boolean isCarrierNetworkActive) {
|
||||
final SignalStrength strength = mTelephonyManager.getSignalStrength();
|
||||
int level = (strength == null) ? 0 : strength.getLevel();
|
||||
int numLevels = SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
|
||||
if (mSubscriptionManager != null && shouldInflateSignalStrength(mDefaultDataSubId)) {
|
||||
level += 1;
|
||||
if ((mSubscriptionManager != null && shouldInflateSignalStrength(mDefaultDataSubId))
|
||||
|| isCarrierNetworkActive) {
|
||||
level = isCarrierNetworkActive
|
||||
? SignalStrength.NUM_SIGNAL_STRENGTH_BINS
|
||||
: (level + 1);
|
||||
numLevels += 1;
|
||||
}
|
||||
return getSignalStrengthIcon(mContext, level, numLevels, NO_CELL_DATA_TYPE_ICON,
|
||||
@@ -586,15 +594,18 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
if (!isMobileDataEnabled()) {
|
||||
return context.getString(R.string.mobile_data_off_summary);
|
||||
}
|
||||
if (!isDataStateInService()) {
|
||||
return context.getString(R.string.mobile_data_no_connection);
|
||||
}
|
||||
|
||||
String summary = networkTypeDescription;
|
||||
// Set network description for the carrier network when connecting to the carrier network
|
||||
// under the airplane mode ON.
|
||||
if (activeNetworkIsCellular() || isCarrierNetworkActive()) {
|
||||
summary = context.getString(R.string.preference_summary_default_combination,
|
||||
context.getString(R.string.mobile_data_connection_active),
|
||||
networkTypeDescription);
|
||||
} else if (!isDataStateInService()) {
|
||||
summary = context.getString(R.string.mobile_data_no_connection);
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
@@ -678,7 +689,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
/**
|
||||
* @return whether there is the carrier item in the slice.
|
||||
*/
|
||||
boolean hasCarrier() {
|
||||
boolean hasActiveSubId() {
|
||||
if (mSubscriptionManager == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "SubscriptionManager is null, can not check carrier.");
|
||||
@@ -888,7 +899,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
if (mHasEthernet) {
|
||||
count -= 1;
|
||||
}
|
||||
if (hasCarrier()) {
|
||||
if (hasActiveSubId()) {
|
||||
count -= 1;
|
||||
}
|
||||
if (hasConnectedWifi) {
|
||||
|
||||
@@ -80,6 +80,7 @@ public class InternetDialogTest extends SysuiTestCase {
|
||||
private RecyclerView mWifiList;
|
||||
private LinearLayout mSeeAll;
|
||||
private LinearLayout mWifiScanNotify;
|
||||
private TextView mAirplaneModeSummaryText;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -114,6 +115,7 @@ public class InternetDialogTest extends SysuiTestCase {
|
||||
mWifiList = mDialogView.requireViewById(R.id.wifi_list_layout);
|
||||
mSeeAll = mDialogView.requireViewById(R.id.see_all_layout);
|
||||
mWifiScanNotify = mDialogView.requireViewById(R.id.wifi_scan_notify_layout);
|
||||
mAirplaneModeSummaryText = mDialogView.requireViewById(R.id.airplane_mode_summary);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -191,7 +193,41 @@ public class InternetDialogTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_withApmOn_mobileDataLayoutGone() {
|
||||
public void updateDialog_apmOffAndNotCarrierNetwork_mobileDataLayoutGone() {
|
||||
// Mobile network should be gone if the list of active subscriptionId is null.
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(false);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||
when(mInternetDialogController.hasActiveSubId()).thenReturn(false);
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mMobileDataToggle.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_apmOnWithCarrierNetworkAndWifiStatus_mobileDataLayout() {
|
||||
// Carrier network should be gone if airplane mode ON and Wi-Fi is off.
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mMobileDataToggle.getVisibility()).isEqualTo(View.GONE);
|
||||
|
||||
// Carrier network should be visible if airplane mode ON and Wi-Fi is ON.
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mMobileDataToggle.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_apmOnAndNoCarrierNetwork_mobileDataLayoutGone() {
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(false);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
@@ -199,6 +235,51 @@ public class InternetDialogTest extends SysuiTestCase {
|
||||
assertThat(mMobileDataToggle.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_apmOnAndWifiOnHasCarrierNetwork_showAirplaneSummary() {
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
mInternetDialog.mConnectedWifiEntry = null;
|
||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mMobileDataToggle.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(mAirplaneModeSummaryText.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_apmOffAndWifiOnHasCarrierNetwork_notShowApmSummary() {
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||
mInternetDialog.mConnectedWifiEntry = null;
|
||||
doReturn(false).when(mInternetDialogController).activeNetworkIsCellular();
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mAirplaneModeSummaryText.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_apmOffAndHasCarrierNetwork_notShowApmSummary() {
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mAirplaneModeSummaryText.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_apmOnAndNoCarrierNetwork_notShowApmSummary() {
|
||||
when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(false);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
|
||||
mInternetDialog.updateDialog(true);
|
||||
|
||||
assertThat(mAirplaneModeSummaryText.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDialog_wifiOnAndHasInternetWifi_showConnectedWifi() {
|
||||
// The preconditions WiFi ON and Internet WiFi are already in setUp()
|
||||
|
||||
Reference in New Issue
Block a user