Fix Self Managed ConnectionService CTSVerifier test.

Test was not properly unregistering its phone accounts or disconnecting
its calls, leaving the verifier in a bad state for subsequent test runs.

Test: Ran CTS Verifier.
Bug: 37948011
Change-Id: Ibafb1a6196ac5f6bdf7d46cda9d65ba56933d8c6
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java
index e134b51..6b0b3da 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java
@@ -102,7 +102,7 @@
     }
 
     /**
-     * Registers the test self-managed phone account.
+     * Registers the test self-managed phone accounts.
      * @param context The context.
      */
     public static void registerTestSelfManagedPhoneAccount(Context context) {
@@ -113,6 +113,17 @@
     }
 
     /**
+     * Unregisters the test self-managed phone accounts.
+     * @param context The context.
+     */
+    public static void unRegisterTestSelfManagedPhoneAccount(Context context) {
+        TelecomManager telecomManager = (TelecomManager) context.getSystemService(
+                Context.TELECOM_SERVICE);
+        telecomManager.unregisterPhoneAccount(TEST_SELF_MANAGED_PHONE_ACCOUNT_HANDLE);
+        telecomManager.unregisterPhoneAccount(TEST_SELF_MANAGED_PHONE_ACCOUNT_HANDLE_2);
+    }
+
+    /**
      * Retrieves the test phone account, or null if not registered.
      * @param context The context.
      * @return The Phone Account.
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/SelfManagedIncomingCallTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/SelfManagedIncomingCallTestActivity.java
index 530b246..2b06446 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/SelfManagedIncomingCallTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/SelfManagedIncomingCallTestActivity.java
@@ -146,7 +146,7 @@
 
         });
 
-        mStep3Status = view.findViewById(R.id.step_2_status);
+        mStep3Status = view.findViewById(R.id.step_3_status);
         mConfirm = view.findViewById(R.id.telecom_incoming_self_mgd_confirm_answer_button);
         mConfirm.setOnClickListener(v -> {
             CtsConnectionService ctsConnectionService = CtsConnectionService.getConnectionService();
@@ -161,11 +161,16 @@
             }
 
             if (connections.get(0).getState() == Connection.STATE_ACTIVE) {
+                connections
+                        .stream()
+                        .forEach((c) -> c.onDisconnect());
                 mStep3Status.setImageResource(R.drawable.fs_good);
                 getPassButton().setEnabled(true);
             } else {
                 mStep3Status.setImageResource(R.drawable.fs_error);
             }
+
+            PhoneAccountUtils.unRegisterTestSelfManagedPhoneAccount(this);
         });
 
         mShowUi.setEnabled(false);