Merge "Make final confirmation of dialog only shows in-call state" into main
diff --git a/src/com/android/settings/system/reset/ResetNetworkConfirm.kt b/src/com/android/settings/system/reset/ResetNetworkConfirm.kt
index b353f69..3412825 100644
--- a/src/com/android/settings/system/reset/ResetNetworkConfirm.kt
+++ b/src/com/android/settings/system/reset/ResetNetworkConfirm.kt
@@ -21,6 +21,7 @@
 import android.content.DialogInterface
 import android.os.Bundle
 import android.os.Looper
+import android.telecom.TelecomManager
 import android.telephony.SubscriptionManager
 import android.util.Log
 import android.view.LayoutInflater
@@ -89,7 +90,12 @@
     /** Configure the UI for the final confirmation interaction */
     private fun View.establishFinalConfirmationState() {
         requireViewById<View>(R.id.execute_reset_network).setOnClickListener {
-            showResetInternetDialog();
+            val tm = context.getSystemService(TelecomManager::class.java)
+            if (tm != null && tm.isInCall) {
+                showResetInternetDialog();
+            } else {
+                onResetClicked()
+            }
         }
     }
 
@@ -138,9 +144,13 @@
      * settings to its factory-default state.
      */
     @VisibleForTesting
-    suspend fun onResetClicked() {
-        showProgressDialog()
-        resetNetwork()
+    fun onResetClicked() {
+        if (!Utils.isMonkeyRunning() && !resetStarted) {
+            resetStarted = true
+            viewLifecycleOwner.lifecycleScope.launch {
+                showProgressDialog()
+                resetNetwork() }
+        }
     }
 
     private fun showProgressDialog() {
@@ -165,10 +175,7 @@
         val builder = AlertDialog.Builder(requireContext())
         val resetInternetClickListener =
             DialogInterface.OnClickListener { dialog, which ->
-                if (!Utils.isMonkeyRunning() && !resetStarted) {
-                    resetStarted = true
-                    viewLifecycleOwner.lifecycleScope.launch { onResetClicked() }
-                }
+                onResetClicked()
             }
 
         builder.setTitle(R.string.reset_your_internet_title)