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