SetupWizardUtils: Check if active Ethernet network reaches the Internet
Extend the current Ethernet connectivity validation to check if network is active (can receive and send data). Change-Id: I1017df7740000774acc713a419c8572ee4ea588f
This commit is contained in:
@@ -230,12 +230,13 @@ public class SetupWizardUtils {
|
|||||||
return SystemProperties.getBoolean("config.disable_bluetooth", false);
|
return SystemProperties.getBoolean("config.disable_bluetooth", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEthernetConnected(Context context) {
|
private static boolean isNetworkConnectedToInternetViaEthernet(Context context) {
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.
|
ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
|
||||||
getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(cm.getActiveNetwork());
|
NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(cm.getActiveNetwork());
|
||||||
return networkCapabilities != null &&
|
return networkCapabilities != null &&
|
||||||
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET);
|
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) &&
|
||||||
|
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
||||||
|
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasLeanback(Context context) {
|
public static boolean hasLeanback(Context context) {
|
||||||
@@ -266,7 +267,8 @@ public class SetupWizardUtils {
|
|||||||
if (!hasTelephony(context) || !simMissing(context)) {
|
if (!hasTelephony(context) || !simMissing(context)) {
|
||||||
disableComponent(context, SimMissingActivity.class);
|
disableComponent(context, SimMissingActivity.class);
|
||||||
}
|
}
|
||||||
if ((!hasWifi(context) && !hasTelephony(context)) || isEthernetConnected(context)) {
|
if ((!hasWifi(context) && !hasTelephony(context)) ||
|
||||||
|
isNetworkConnectedToInternetViaEthernet(context)) {
|
||||||
disableComponent(context, NetworkSetupActivity.class);
|
disableComponent(context, NetworkSetupActivity.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user