[Provider Model] Show connected networks in APM/APM networks
- Separate APM and APM network types from other Internet types because they can coexist at the same time. - Show no internet icon in airplane-mode networks. - Show connected non-carrier(Wi-Fi) network in airplane-mode networks. - Show connected Ethernet network when airplane mode on. - Screenshot: https://screenshot.googleplex.com/cr3eWNLMEuJ8zvP https://screenshot.googleplex.com/6DiMqKBBnBoxxhN Bug: 180778141 Bug: 180778839 Bug: 179106406 Test: manual test atest -c ConnectedEthernetNetworkControllerTest \ InternetConnectivityPanelTest \ InternetPreferenceControllerTest \ InternetUpdaterTest Change-Id: I861d5ce879facbb61dfdc5b7be943662d55bdcca
This commit is contained in:
31
res/drawable/ic_no_internet_available.xml
Normal file
31
res/drawable/ic_no_internet_available.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10c0.34,0 0.68,-0.02 1.01,-0.05V20h-1v-0.04c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96H13v-2H9.66c-0.09,-0.66 -0.16,-1.32 -0.16,-2s0.07,-1.35 0.16,-2H21.8C20.87,5.44 16.83,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56C16.43,5.07 17.96,6.35 18.92,8zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82C10.52,6.57 11.17,5.24 12,4.04zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2s0.06,1.34 0.14,2H4.26zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56C7.57,18.93 6.04,17.66 5.08,16zM8.03,8H5.08c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8z"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16,14.75c0,-1.93 1.57,-3.5 3.5,-3.5s3.5,1.57 3.5,3.5c0,1.12 -0.69,1.73 -1.36,2.32c-0.64,0.56 -1.26,1.1 -1.26,2.06h-1.75c0,-1.59 0.82,-2.22 1.54,-2.78c0.57,-0.44 1.08,-0.83 1.08,-1.6c0,-0.96 -0.79,-1.75 -1.75,-1.75s-1.75,0.79 -1.75,1.75H16z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M18.63,20.25h1.75V22h-1.75V20.25z"/>
|
||||
</vector>
|
28
res/drawable/ic_no_internet_unavailable.xml
Normal file
28
res/drawable/ic_no_internet_unavailable.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M2,12C2,6.48 6.47,2 11.99,2C17.52,2 22,6.48 22,12c0,0.34 -0.02,0.67 -0.05,1h-2.02c0.04,-0.33 0.07,-0.66 0.07,-1c0,-0.69 -0.1,-1.36 -0.26,-2h-3.38c0.08,0.66 0.14,1.32 0.14,2c0,0.34 -0.01,0.67 -0.04,1h-2.01c0.03,-0.33 0.05,-0.66 0.05,-1c0,-0.68 -0.07,-1.35 -0.16,-2H9.66c-0.09,0.65 -0.16,1.32 -0.16,2s0.07,1.34 0.16,2H13v2h-2.91c0.43,1.43 1.08,2.76 1.91,3.96V20h1v1.95C12.67,21.98 12.33,22 11.99,22C6.47,22 2,17.52 2,12zM15.97,8h2.95c-0.96,-1.65 -2.49,-2.93 -4.33,-3.56C15.19,5.55 15.65,6.75 15.97,8zM13.91,8C13.48,6.57 12.83,5.24 12,4.04c-0.83,1.2 -1.48,2.53 -1.91,3.96H13.91zM4,12c0,0.69 0.1,1.36 0.26,2h3.38c-0.08,-0.66 -0.14,-1.32 -0.14,-2s0.06,-1.34 0.14,-2H4.26C4.1,10.64 4,11.31 4,12zM8.03,16H5.08c0.96,1.66 2.49,2.93 4.33,3.56C8.81,18.45 8.35,17.25 8.03,16zM5.08,8h2.95c0.32,-1.25 0.78,-2.45 1.38,-3.56C7.57,5.07 6.04,6.34 5.08,8z"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M22,16.41L20.59,15l-2.09,2.09L16.41,15L15,16.41l2.09,2.09L15,20.59L16.41,22l2.09,-2.08L20.59,22L22,20.59l-2.08,-2.09L22,16.41z"/>
|
||||
</vector>
|
@@ -33,7 +33,7 @@ import com.android.settingslib.core.AbstractPreferenceController;
|
||||
* PreferenceController to show the connected ethernet network.
|
||||
*/
|
||||
public class ConnectedEthernetNetworkController extends AbstractPreferenceController
|
||||
implements InternetUpdater.OnInternetTypeChangedListener {
|
||||
implements InternetUpdater.InternetChangeListener {
|
||||
|
||||
public static final String KEY = "connected_ethernet_network";
|
||||
|
||||
|
@@ -19,10 +19,10 @@ package com.android.settings.network;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_CELLULAR;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_ETHERNET;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_NETWORKS_AVAILABLE;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_OFF;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_WIFI;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -53,7 +53,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class InternetPreferenceController extends AbstractPreferenceController implements
|
||||
LifecycleObserver, SummaryUpdater.OnSummaryChangeListener,
|
||||
InternetUpdater.OnInternetTypeChangedListener {
|
||||
InternetUpdater.InternetChangeListener {
|
||||
|
||||
public static final String KEY = "internet_settings";
|
||||
|
||||
@@ -65,8 +65,8 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
@VisibleForTesting
|
||||
static Map<Integer, Integer> sIconMap = new HashMap<>();
|
||||
static {
|
||||
sIconMap.put(INTERNET_APM, R.drawable.ic_airplanemode_active);
|
||||
sIconMap.put(INTERNET_APM_NETWORKS, R.drawable.ic_airplane_safe_networks_24dp);
|
||||
sIconMap.put(INTERNET_OFF, R.drawable.ic_no_internet_unavailable);
|
||||
sIconMap.put(INTERNET_NETWORKS_AVAILABLE, R.drawable.ic_no_internet_available);
|
||||
sIconMap.put(INTERNET_WIFI, R.drawable.ic_wifi_signal_4);
|
||||
sIconMap.put(INTERNET_CELLULAR, R.drawable.ic_network_cell);
|
||||
sIconMap.put(INTERNET_ETHERNET, R.drawable.ic_settings_ethernet);
|
||||
@@ -74,8 +74,8 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
|
||||
private static Map<Integer, Integer> sSummaryMap = new HashMap<>();
|
||||
static {
|
||||
sSummaryMap.put(INTERNET_APM, R.string.condition_airplane_title);
|
||||
sSummaryMap.put(INTERNET_APM_NETWORKS, R.string.airplane_mode_network_available);
|
||||
sSummaryMap.put(INTERNET_OFF, R.string.condition_airplane_title);
|
||||
sSummaryMap.put(INTERNET_NETWORKS_AVAILABLE, R.string.disconnected);
|
||||
sSummaryMap.put(INTERNET_WIFI, 0);
|
||||
sSummaryMap.put(INTERNET_CELLULAR, 0);
|
||||
sSummaryMap.put(INTERNET_ETHERNET, R.string.to_switch_networks_disconnect_ethernet);
|
||||
@@ -114,8 +114,8 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
}
|
||||
}
|
||||
|
||||
if (mustUseWiFiHelperSummary(mSummaryHelper.isWifiConnected(),
|
||||
mSummaryHelper.getSummary())) {
|
||||
if (mInternetType == INTERNET_WIFI) {
|
||||
mPreference.setSummary(mSummaryHelper.getSummary());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,12 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
return;
|
||||
}
|
||||
|
||||
if (mInternetType == INTERNET_NETWORKS_AVAILABLE
|
||||
&& mInternetUpdater.isApmNetworksAvailable()) {
|
||||
mPreference.setSummary(R.string.airplane_mode_network_available);
|
||||
return;
|
||||
}
|
||||
|
||||
final @IdRes int summary = sSummaryMap.get(mInternetType);
|
||||
if (summary != 0) {
|
||||
mPreference.setSummary(summary);
|
||||
@@ -157,6 +163,7 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
*
|
||||
* @param internetType the internet type
|
||||
*/
|
||||
@Override
|
||||
public void onInternetTypeChanged(@InternetUpdater.InternetType int internetType) {
|
||||
final boolean needUpdate = (internetType != mInternetType);
|
||||
mInternetType = internetType;
|
||||
@@ -167,19 +174,21 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when airplane mode state is changed.
|
||||
*/
|
||||
@Override
|
||||
public void onSummaryChanged(String summary) {
|
||||
mustUseWiFiHelperSummary(mSummaryHelper.isWifiConnected(), summary);
|
||||
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
updateState(mPreference);
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean mustUseWiFiHelperSummary(boolean isWifiConnected, String summary) {
|
||||
final boolean needUpdate = (mInternetType == INTERNET_WIFI)
|
||||
|| (mInternetType == INTERNET_APM_NETWORKS && isWifiConnected);
|
||||
if (needUpdate && mPreference != null) {
|
||||
@Override
|
||||
public void onSummaryChanged(String summary) {
|
||||
if (mInternetType == INTERNET_WIFI && mPreference != null) {
|
||||
mPreference.setSummary(summary);
|
||||
}
|
||||
return needUpdate;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@@ -34,6 +34,7 @@ import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkCapabilities.Transport;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
@@ -55,27 +56,45 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
|
||||
private static final String TAG = "InternetUpdater";
|
||||
|
||||
private OnInternetTypeChangedListener mOnInternetTypeChangedListener;
|
||||
private InternetChangeListener mListener;
|
||||
|
||||
/** Interface that handles the internet type changed callback */
|
||||
public interface OnInternetTypeChangedListener {
|
||||
/** Interface that handles the internet updater callback */
|
||||
public interface InternetChangeListener {
|
||||
/**
|
||||
* Called when internet type is changed.
|
||||
*
|
||||
* @param internetType the internet type
|
||||
*/
|
||||
void onInternetTypeChanged(@InternetType int internetType);
|
||||
default void onInternetTypeChanged(@InternetType int internetType) {};
|
||||
|
||||
/**
|
||||
* Called when airplane mode state is changed.
|
||||
*/
|
||||
default void onAirplaneModeChanged(boolean isAirplaneModeOn) {};
|
||||
|
||||
/**
|
||||
* Called when airplane mode networks state is changed.
|
||||
*/
|
||||
default void onAirplaneModeNetworksChanged(boolean available) {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates this internet is unavailable type in airplane mode on.
|
||||
* Indicates the internet is off when airplane mode is on.
|
||||
*/
|
||||
public static final int INTERNET_APM = 0;
|
||||
public static final int INTERNET_OFF = 0;
|
||||
|
||||
/**
|
||||
* Indicates this internet uses an airplane mode network type.
|
||||
* Indicates this internet is not connected (includes no networks connected) or network(s)
|
||||
* available.
|
||||
*
|
||||
* Examples include:
|
||||
* <p>When airplane mode is turned off, and some networks (Wi-Fi, Mobile-data) are turned on,
|
||||
* but no network can access the Internet.
|
||||
*
|
||||
* <p>When the airplane mode is turned on, and the WiFi is also turned on, but the WiFi is not
|
||||
* connected or cannot access the Internet.
|
||||
*/
|
||||
public static final int INTERNET_APM_NETWORKS = 1;
|
||||
public static final int INTERNET_NETWORKS_AVAILABLE = 1;
|
||||
|
||||
/**
|
||||
* Indicates this internet uses a Wi-Fi network type.
|
||||
@@ -94,8 +113,8 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@android.annotation.IntDef(prefix = { "INTERNET_" }, value = {
|
||||
INTERNET_APM,
|
||||
INTERNET_APM_NETWORKS,
|
||||
INTERNET_OFF,
|
||||
INTERNET_NETWORKS_AVAILABLE,
|
||||
INTERNET_WIFI,
|
||||
INTERNET_CELLULAR,
|
||||
INTERNET_ETHERNET,
|
||||
@@ -110,6 +129,8 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
@VisibleForTesting
|
||||
AirplaneModeEnabler mAirplaneModeEnabler;
|
||||
|
||||
@VisibleForTesting
|
||||
boolean mInternetAvailable;
|
||||
@VisibleForTesting
|
||||
@Transport int mTransport;
|
||||
private static Map<Integer, Integer> sTransportMap = new HashMap<>();
|
||||
@@ -120,22 +141,14 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
}
|
||||
|
||||
private NetworkCallback mNetworkCallback = new NetworkCallback() {
|
||||
public void onCapabilitiesChanged(@NonNull Network network,
|
||||
@NonNull NetworkCapabilities networkCapabilities) {
|
||||
checkNetworkCapabilities(networkCapabilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvailable(@NonNull Network network) {
|
||||
if (network == null) {
|
||||
return;
|
||||
}
|
||||
final NetworkCapabilities networkCapabilities =
|
||||
mConnectivityManager.getNetworkCapabilities(network);
|
||||
if (networkCapabilities == null) {
|
||||
return;
|
||||
}
|
||||
for (@Transport int transport : networkCapabilities.getTransportTypes()) {
|
||||
if (sTransportMap.containsKey(transport)) {
|
||||
mTransport = transport;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void onLost(@NonNull Network network) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
}
|
||||
};
|
||||
@@ -143,18 +156,22 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
private final BroadcastReceiver mWifiStateReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
update();
|
||||
fetchActiveNetwork();
|
||||
if (mListener != null && mAirplaneModeEnabler.isAirplaneModeOn()) {
|
||||
mListener.onAirplaneModeNetworksChanged(
|
||||
mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public InternetUpdater(Context context, Lifecycle lifecycle,
|
||||
OnInternetTypeChangedListener listener) {
|
||||
public InternetUpdater(Context context, Lifecycle lifecycle, InternetChangeListener listener) {
|
||||
mContext = context;
|
||||
mAirplaneModeEnabler = new AirplaneModeEnabler(mContext, this);
|
||||
mConnectivityManager = mContext.getSystemService(ConnectivityManager.class);
|
||||
mWifiManager = mContext.getSystemService(WifiManager.class);
|
||||
mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
mOnInternetTypeChangedListener = listener;
|
||||
mListener = listener;
|
||||
fetchActiveNetwork();
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
@@ -178,18 +195,65 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
|
||||
@Override
|
||||
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
|
||||
fetchActiveNetwork();
|
||||
if (mListener != null) {
|
||||
mListener.onAirplaneModeChanged(isAirplaneModeOn);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchActiveNetwork() {
|
||||
Network activeNetwork = mConnectivityManager.getActiveNetwork();
|
||||
if (activeNetwork == null) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkCapabilities activeNetworkCapabilities =
|
||||
mConnectivityManager.getNetworkCapabilities(activeNetwork);
|
||||
if (activeNetworkCapabilities == null) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
checkNetworkCapabilities(activeNetworkCapabilities);
|
||||
}
|
||||
|
||||
private void checkNetworkCapabilities(@NonNull NetworkCapabilities networkCapabilities) {
|
||||
if (!networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean internetAvailable = false;
|
||||
for (@Transport int transport : networkCapabilities.getTransportTypes()) {
|
||||
if (sTransportMap.containsKey(transport)) {
|
||||
mTransport = transport;
|
||||
internetAvailable = true;
|
||||
Log.i(TAG, "Detect an internet capability network with transport type: "
|
||||
+ mTransport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mInternetAvailable = internetAvailable;
|
||||
update();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void update() {
|
||||
if (mAirplaneModeEnabler.isAirplaneModeOn()) {
|
||||
mInternetType = mWifiManager.isWifiEnabled() ? INTERNET_APM_NETWORKS : INTERNET_APM;
|
||||
} else {
|
||||
mInternetType = sTransportMap.get(mTransport);
|
||||
@InternetType int internetType = INTERNET_NETWORKS_AVAILABLE;
|
||||
if (mInternetAvailable) {
|
||||
internetType = sTransportMap.get(mTransport);
|
||||
} else if (mAirplaneModeEnabler.isAirplaneModeOn()
|
||||
&& mWifiManager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
|
||||
internetType = INTERNET_OFF;
|
||||
}
|
||||
if (mOnInternetTypeChangedListener != null) {
|
||||
mOnInternetTypeChangedListener.onInternetTypeChanged(mInternetType);
|
||||
mInternetType = internetType;
|
||||
|
||||
if (mListener != null) {
|
||||
mListener.onInternetTypeChanged(mInternetType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,4 +263,19 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
public @InternetType int getInternetType() {
|
||||
return mInternetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ture when the airplane mode is on.
|
||||
*/
|
||||
public boolean isAirplaneModeOn() {
|
||||
return mAirplaneModeEnabler.isAirplaneModeOn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ture when the APM networks is available.
|
||||
*/
|
||||
public boolean isApmNetworksAvailable() {
|
||||
return mAirplaneModeEnabler.isAirplaneModeOn()
|
||||
&& (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED);
|
||||
}
|
||||
}
|
||||
|
@@ -49,9 +49,8 @@ import java.util.Collections;
|
||||
*/
|
||||
public class NetworkProviderWorker extends WifiScanWorker implements
|
||||
SignalStrengthListener.Callback, MobileDataEnabledListener.Client,
|
||||
DataConnectivityListener.Client,
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient,
|
||||
InternetUpdater.OnInternetTypeChangedListener {
|
||||
DataConnectivityListener.Client, InternetUpdater.InternetChangeListener,
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
private static final String TAG = "NetworkProviderWorker";
|
||||
private static final int PROVIDER_MODEL_DEFAULT_EXPANDED_ROW_COUNT = 4;
|
||||
private DataContentObserver mMobileDataObserver;
|
||||
|
@@ -19,8 +19,6 @@ package com.android.settings.panel;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
|
||||
import static com.android.settings.network.NetworkProviderSettings.ACTION_NETWORK_PROVIDER_SETTINGS;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
@@ -46,14 +44,15 @@ import java.util.List;
|
||||
* Represents the Internet Connectivity Panel.
|
||||
*/
|
||||
public class InternetConnectivityPanel implements PanelContent, LifecycleObserver,
|
||||
InternetUpdater.OnInternetTypeChangedListener {
|
||||
InternetUpdater.InternetChangeListener {
|
||||
|
||||
private final Context mContext;
|
||||
@VisibleForTesting
|
||||
boolean mIsProviderModelEnabled;
|
||||
private PanelContentCallback mCallback;
|
||||
private InternetUpdater mInternetUpdater;
|
||||
private @InternetUpdater.InternetType int mInternetType;
|
||||
private boolean mIsAirplaneModeOn;
|
||||
private boolean mIsApmNetworksAvailable;
|
||||
|
||||
public static InternetConnectivityPanel create(Context context) {
|
||||
return new InternetConnectivityPanel(context);
|
||||
@@ -63,7 +62,8 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
mContext = context.getApplicationContext();
|
||||
mIsProviderModelEnabled = Utils.isProviderModelEnabled(mContext);
|
||||
mInternetUpdater = new InternetUpdater(context, null /* Lifecycle */, this);
|
||||
mInternetType = mInternetUpdater.getInternetType();
|
||||
mIsAirplaneModeOn = mInternetUpdater.isAirplaneModeOn();
|
||||
mIsApmNetworksAvailable = mInternetUpdater.isApmNetworksAvailable();
|
||||
}
|
||||
|
||||
/** @OnLifecycleEvent(ON_RESUME) */
|
||||
@@ -90,7 +90,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
if (mIsProviderModelEnabled) {
|
||||
return mContext.getText(mInternetType == INTERNET_APM_NETWORKS
|
||||
return mContext.getText(mIsApmNetworksAvailable
|
||||
? R.string.airplane_mode_network_panel_title
|
||||
: R.string.provider_internet_settings);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
*/
|
||||
@Override
|
||||
public CharSequence getSubTitle() {
|
||||
if (mIsProviderModelEnabled && mInternetType == INTERNET_APM) {
|
||||
if (mIsProviderModelEnabled && mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
|
||||
return mContext.getText(R.string.condition_airplane_title);
|
||||
}
|
||||
return null;
|
||||
@@ -136,7 +136,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
|
||||
@Override
|
||||
public CharSequence getCustomizedButtonTitle() {
|
||||
if (mInternetType == INTERNET_APM) {
|
||||
if (mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
|
||||
return null;
|
||||
}
|
||||
return mContext.getText(R.string.settings_button);
|
||||
@@ -158,40 +158,43 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when internet type is changed.
|
||||
*
|
||||
* @param internetType the internet type
|
||||
* Called when airplane mode state is changed.
|
||||
*/
|
||||
public void onInternetTypeChanged(@InternetUpdater.InternetType int internetType) {
|
||||
if (internetType == mInternetType) {
|
||||
@Override
|
||||
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
|
||||
if (!isAirplaneModeOn) {
|
||||
mIsApmNetworksAvailable = false;
|
||||
}
|
||||
mIsAirplaneModeOn = isAirplaneModeOn;
|
||||
updatePanelTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when airplane mode networks state is changed.
|
||||
*/
|
||||
@Override
|
||||
public void onAirplaneModeNetworksChanged(boolean available) {
|
||||
mIsApmNetworksAvailable = available;
|
||||
updatePanelTitle();
|
||||
}
|
||||
|
||||
private void updatePanelTitle() {
|
||||
if (mCallback == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean changeToApm = (internetType == INTERNET_APM);
|
||||
final boolean changeFromApm = (mInternetType == INTERNET_APM);
|
||||
final boolean changeWithApmNetworks =
|
||||
(internetType == INTERNET_APM_NETWORKS || mInternetType == INTERNET_APM_NETWORKS);
|
||||
mInternetType = internetType;
|
||||
|
||||
if (mCallback != null) {
|
||||
if (changeToApm) {
|
||||
// The internet type is changed to the airplane mode.
|
||||
// Title: Internet
|
||||
// Sub-Title: Airplane mode is on
|
||||
// Settings button: Hide
|
||||
mCallback.onHeaderChanged();
|
||||
mCallback.onCustomizedButtonStateChanged();
|
||||
} else if (changeFromApm) {
|
||||
// The internet type is changed from the airplane mode.
|
||||
// Title: Internet
|
||||
// Settings button: Show
|
||||
mCallback.onTitleChanged();
|
||||
mCallback.onCustomizedButtonStateChanged();
|
||||
} else if (changeWithApmNetworks) {
|
||||
// The internet type is changed with the airplane mode networks.
|
||||
// Title: Airplane mode networks / Internet
|
||||
mCallback.onTitleChanged();
|
||||
}
|
||||
if (mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
|
||||
// When the airplane mode is on.
|
||||
// Title: Internet
|
||||
// Sub-Title: Airplane mode is on
|
||||
// Settings button: Hide
|
||||
mCallback.onHeaderChanged();
|
||||
} else {
|
||||
// Except for airplane mode on.
|
||||
// Title: Airplane mode networks / Internet
|
||||
// Settings button: Show
|
||||
mCallback.onTitleChanged();
|
||||
}
|
||||
mCallback.onCustomizedButtonStateChanged();
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,10 @@
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_CELLULAR;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_ETHERNET;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_NETWORKS_AVAILABLE;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_OFF;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_WIFI;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -77,15 +77,15 @@ public class ConnectedEthernetNetworkControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_internetApm_shouldBeFalse() {
|
||||
mController.onInternetTypeChanged(INTERNET_APM);
|
||||
public void isAvailable_internetOff_shouldBeFalse() {
|
||||
mController.onInternetTypeChanged(INTERNET_OFF);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_internetApmNetworks_shouldBeFalse() {
|
||||
mController.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
public void isAvailable_internetNetworksAvailable_shouldBeFalse() {
|
||||
mController.onInternetTypeChanged(INTERNET_NETWORKS_AVAILABLE);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_NETWORKS_AVAILABLE;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_WIFI;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -119,37 +119,24 @@ public class InternetPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustUseWiFiHelperSummary_internetWifi_updateSummary() {
|
||||
public void onSummaryChanged_internetWifi_updateSummary() {
|
||||
mController.onInternetTypeChanged(INTERNET_WIFI);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.mustUseWiFiHelperSummary(true /* isWifiConnected */, TEST_SUMMARY);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo(TEST_SUMMARY);
|
||||
|
||||
mController.mustUseWiFiHelperSummary(false /* isWifiConnected */, NOT_CONNECTED);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo(NOT_CONNECTED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustUseWiFiHelperSummary_internetApmNetworksWifiConnected_updateSummary() {
|
||||
mController.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.mustUseWiFiHelperSummary(true /* isWifiConnected */, TEST_SUMMARY);
|
||||
mController.onSummaryChanged(TEST_SUMMARY);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo(TEST_SUMMARY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustUseWiFiHelperSummary_internetApmNetworksWifiDisconnected_notUpdateSummary() {
|
||||
mController.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
public void onSummaryChanged_internetNetworksAvailable_notUpdateSummary() {
|
||||
mController.onInternetTypeChanged(INTERNET_NETWORKS_AVAILABLE);
|
||||
mController.displayPreference(mScreen);
|
||||
mPreference.setSummary(NOT_CONNECTED);
|
||||
|
||||
mController.mustUseWiFiHelperSummary(false /* isWifiConnected */, NOT_CONNECTED);
|
||||
mController.onSummaryChanged(TEST_SUMMARY);
|
||||
|
||||
assertThat(mPreference.getSummary()).isNotEqualTo(NOT_CONNECTED);
|
||||
assertThat(mPreference.getSummary()).isNotEqualTo(TEST_SUMMARY);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -20,10 +20,10 @@ import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_CELLULAR;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_ETHERNET;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_NETWORKS_AVAILABLE;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_OFF;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_WIFI;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -109,26 +109,30 @@ public class InternetUpdaterTest {
|
||||
@Test
|
||||
public void update_apmOnWifiOff_getInternetApm() {
|
||||
doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
doReturn(false).when(mWifiManager).isWifiEnabled();
|
||||
doReturn(WifiManager.WIFI_STATE_DISABLED).when(mWifiManager).getWifiState();
|
||||
mInternetUpdater.mInternetAvailable = false;
|
||||
|
||||
mInternetUpdater.update();
|
||||
|
||||
assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_APM);
|
||||
assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update_apmOnWifiOn_getInternetApmNetworks() {
|
||||
public void update_apmOnWifiOnNotConnected_getInternetNetworksAvailable() {
|
||||
doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
doReturn(WifiManager.WIFI_STATE_ENABLED).when(mWifiManager).getWifiState();
|
||||
mInternetUpdater.mInternetAvailable = false;
|
||||
|
||||
mInternetUpdater.update();
|
||||
|
||||
assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_NETWORKS_AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update_apmOnWifiConnected_getInternetWifi() {
|
||||
doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
doReturn(true).when(mWifiManager).isWifiEnabled();
|
||||
|
||||
mInternetUpdater.update();
|
||||
|
||||
assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_APM_NETWORKS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update_apmOffWifiConnected_getInternetWifi() {
|
||||
doReturn(false).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
mInternetUpdater.mInternetAvailable = true;
|
||||
mInternetUpdater.mTransport = TRANSPORT_WIFI;
|
||||
|
||||
mInternetUpdater.update();
|
||||
@@ -137,8 +141,9 @@ public class InternetUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update_apmOffCellularConnected_getInternetCellular() {
|
||||
doReturn(false).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
public void update_apmOnCellularConnected_getInternetCellular() {
|
||||
doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
mInternetUpdater.mInternetAvailable = true;
|
||||
mInternetUpdater.mTransport = TRANSPORT_CELLULAR;
|
||||
|
||||
mInternetUpdater.update();
|
||||
@@ -147,8 +152,9 @@ public class InternetUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update_apmOffEthernetConnected_getInternetEthernet() {
|
||||
doReturn(false).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
public void update_apmOnEthernetConnected_getInternetEthernet() {
|
||||
doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
|
||||
mInternetUpdater.mInternetAvailable = true;
|
||||
mInternetUpdater.mTransport = TRANSPORT_ETHERNET;
|
||||
|
||||
mInternetUpdater.update();
|
||||
|
@@ -16,12 +16,6 @@
|
||||
|
||||
package com.android.settings.panel;
|
||||
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_APM_NETWORKS;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_CELLULAR;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_ETHERNET;
|
||||
import static com.android.settings.network.InternetUpdater.INTERNET_WIFI;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
@@ -78,79 +72,70 @@ public class InternetConnectivityPanelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTitle_internetApmNetworks_shouldBeApmNetworks() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
public void getTitle_apmOnApmNetworksOff_shouldBeInternet() {
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onAirplaneModeNetworksChanged(false);
|
||||
|
||||
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTitle_apmOnApmNetworksOn_shouldBeApmNetworks() {
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onAirplaneModeNetworksChanged(true);
|
||||
|
||||
assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM_NETWORKS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTitle_notInternetApmNetworks_shouldBeInternet() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM);
|
||||
|
||||
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_WIFI);
|
||||
|
||||
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_CELLULAR);
|
||||
|
||||
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_ETHERNET);
|
||||
mPanel.onAirplaneModeNetworksChanged(false);
|
||||
|
||||
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSubTitle_internetApm_shouldBeApmIsOn() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM);
|
||||
public void getSubTitle_apmOnApmNetworksOff_shouldBeApmIsOn() {
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onAirplaneModeNetworksChanged(false);
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_APM_IS_ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSubTitle_notinternetApm_shouldBeNull() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isNull();
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_WIFI);
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isNull();
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_CELLULAR);
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isNull();
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_ETHERNET);
|
||||
public void getSubTitle_apmOnApmNetworksOn_shouldBeNull() {
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onAirplaneModeNetworksChanged(true);
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_internetApm_shouldBeNull() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM);
|
||||
public void getSubTitle_apmOff_shouldBeNull() {
|
||||
mPanel.onAirplaneModeChanged(false);
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_apmOnApmNetworksOff_shouldBeNull() {
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onAirplaneModeNetworksChanged(false);
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_notInternetApm_shouldBeSettings() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
public void getCustomizedButtonTitle_apmOnApmNetworksOn_shouldBeSettings() {
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onAirplaneModeNetworksChanged(true);
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
|
||||
}
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_WIFI);
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_CELLULAR);
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_ETHERNET);
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_apmOff_shouldBeSettings() {
|
||||
mPanel.onAirplaneModeChanged(false);
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
|
||||
}
|
||||
@@ -181,44 +166,46 @@ public class InternetConnectivityPanelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onInternetTypeChanged_internetTypeChangedToApm_changeHeaderAndHideSettings() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
public void onAirplaneModeOn_apmNetworksOff_changeHeaderAndHideSettings() {
|
||||
mPanel.onAirplaneModeNetworksChanged(false);
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM);
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
|
||||
verify(mPanelContentCallback).onHeaderChanged();
|
||||
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onInternetTypeChanged_internetTypeChangedFomApm_changeTitleAndShowSettings() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM);
|
||||
public void onAirplaneModeOn_apmNetworksOn_changeTitleAndShowSettings() {
|
||||
mPanel.onAirplaneModeNetworksChanged(true);
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onInternetTypeChanged_internetTypeChangedToApmNetworks_changeTitle() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_WIFI);
|
||||
public void onAirplaneModeNetworksOn_apmOff_changeTitleAndShowSettings() {
|
||||
mPanel.onAirplaneModeChanged(false);
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
mPanel.onAirplaneModeNetworksChanged(true);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onInternetTypeChanged_internetTypeChangedFromApmNetworks_changeTitle() {
|
||||
mPanel.onInternetTypeChanged(INTERNET_APM_NETWORKS);
|
||||
public void onAirplaneModeNetworksOff_apmOff_changeTitleAndShowSettings() {
|
||||
mPanel.onAirplaneModeChanged(false);
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onInternetTypeChanged(INTERNET_WIFI);
|
||||
mPanel.onAirplaneModeNetworksChanged(false);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user