Check wifi/telephony/ethernet status when relevant

Change-Id: I5d34b0fc5059f2b2eaceaf459180002b525c4249
diff --git a/src/org/lineageos/setupwizard/NetworkSetupActivity.java b/src/org/lineageos/setupwizard/NetworkSetupActivity.java
index 372c901..3c9cf2a 100644
--- a/src/org/lineageos/setupwizard/NetworkSetupActivity.java
+++ b/src/org/lineageos/setupwizard/NetworkSetupActivity.java
@@ -6,6 +6,8 @@
 
 package org.lineageos.setupwizard;
 
+import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP;
+
 import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_ENABLE_NEXT_ON_CONNECT;
 import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_PREFS_SET_BACK_TEXT;
 import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_PREFS_SHOW_BUTTON_BAR;
@@ -23,6 +25,11 @@
 
     @Override
     protected void onStartSubactivity() {
+        if ((!SetupWizardUtils.hasWifi(this) && !SetupWizardUtils.hasTelephony(this)) ||
+                SetupWizardUtils.isNetworkConnectedToInternetViaEthernet(this)) {
+            finishAction(RESULT_SKIP);
+            return;
+        }
         if (SetupWizardUtils.isOwner()) {
             tryEnablingWifi();
         }
diff --git a/src/org/lineageos/setupwizard/SimMissingActivity.java b/src/org/lineageos/setupwizard/SimMissingActivity.java
index 3980cb4..c446401 100644
--- a/src/org/lineageos/setupwizard/SimMissingActivity.java
+++ b/src/org/lineageos/setupwizard/SimMissingActivity.java
@@ -7,6 +7,7 @@
 package org.lineageos.setupwizard;
 
 import static com.google.android.setupcompat.util.ResultCodes.RESULT_ACTIVITY_NOT_FOUND;
+import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP;
 
 import android.content.Intent;
 
@@ -19,8 +20,8 @@
 public class SimMissingActivity extends SubBaseActivity {
 
     protected void onStartSubactivity() {
-        if (!SetupWizardUtils.simMissing(this)) {
-            nextAction(RESULT_OK);
+        if (!SetupWizardUtils.simMissing(this) || !SetupWizardUtils.hasTelephony(this)) {
+            finishAction(RESULT_SKIP);
             return;
         }
         getGlifLayout().setDescriptionText(getString(R.string.sim_missing_summary));
diff --git a/src/org/lineageos/setupwizard/util/SetupWizardUtils.java b/src/org/lineageos/setupwizard/util/SetupWizardUtils.java
index e114269..e5c78ac 100644
--- a/src/org/lineageos/setupwizard/util/SetupWizardUtils.java
+++ b/src/org/lineageos/setupwizard/util/SetupWizardUtils.java
@@ -52,9 +52,7 @@
 
 import org.lineageos.setupwizard.BaseSetupWizardActivity;
 import org.lineageos.setupwizard.BluetoothSetupActivity;
-import org.lineageos.setupwizard.NetworkSetupActivity;
 import org.lineageos.setupwizard.SetupWizardApp;
-import org.lineageos.setupwizard.SimMissingActivity;
 
 import java.io.File;
 import java.util.List;
@@ -209,7 +207,7 @@
         return SystemProperties.getBoolean("config.disable_bluetooth", false);
     }
 
-    private static boolean isNetworkConnectedToInternetViaEthernet(Context context) {
+    public static boolean isNetworkConnectedToInternetViaEthernet(Context context) {
         ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
         NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(cm.getActiveNetwork());
         return networkCapabilities != null &&
@@ -238,13 +236,6 @@
         if (!hasLeanback(context) || isBluetoothDisabled()) {
             disableComponent(context, BluetoothSetupActivity.class);
         }
-        if (!hasTelephony(context)) {
-            disableComponent(context, SimMissingActivity.class);
-        }
-        if ((!hasWifi(context) && !hasTelephony(context)) ||
-                isNetworkConnectedToInternetViaEthernet(context)) {
-            disableComponent(context, NetworkSetupActivity.class);
-        }
     }
 
     /**