Improve removing PROPERTY_IS_DOWNGRADED_CONFERENCE from connection

For some operators network, the address of SRVCC conference is not
"Conference call" and is an unidentifiable character as phone number.
SRVCC conference connenction should not remove
PROPERTY_IS_DOWNGRADED_CONFERENCE, so only remove it from connection if
its address is an identifiable phone number.

Test: manual
Test: atest TelephonyConferenceControllerTest
Bug: 233552226

Change-Id: I7df7295facbe16a3b3edf4ca89074b1f95cb36a3
diff --git a/src/com/android/services/telephony/TelephonyConferenceController.java b/src/com/android/services/telephony/TelephonyConferenceController.java
index 9aa3dbe..f0aa641 100644
--- a/src/com/android/services/telephony/TelephonyConferenceController.java
+++ b/src/com/android/services/telephony/TelephonyConferenceController.java
@@ -20,6 +20,8 @@
 import android.telecom.Connection;
 import android.telecom.DisconnectCause;
 import android.telecom.PhoneAccountHandle;
+import android.text.TextUtils;
+import android.util.Patterns;
 
 import com.android.internal.telephony.Call;
 import com.android.phone.PhoneUtils;
@@ -40,7 +42,6 @@
  */
 final class TelephonyConferenceController {
     private static final int TELEPHONY_CONFERENCE_MAX_SIZE = 5;
-    private static final String RIL_REPORTED_CONFERENCE_CALL_STRING = "Conference Call";
 
     private final TelephonyConnection.TelephonyConnectionListener mTelephonyConnectionListener =
             new TelephonyConnection.TelephonyConnectionListener() {
@@ -271,13 +272,13 @@
                             // Remove all instances of PROPERTY_IS_DOWNGRADED_CONFERENCE. This
                             // property should only be set on the parent call (i.e. the newly
                             // created TelephonyConference.
-                            // This doesn't apply to a connection whose address is "Conference
-                            // Call", which may be updated by some modem to create a connection
-                            // to represent a merged conference connection in SRVCC.
+                            // This doesn't apply to a connection whose address is not an
+                            // identifiable phone number, which may be updated by some modem
+                            // to create a connection to represent a merged conference connection
+                            // in SRVCC.
                             if (connection.getAddress() == null
-                                    || !connection.getAddress().getSchemeSpecificPart()
-                                            .equalsIgnoreCase(
-                                                    RIL_REPORTED_CONFERENCE_CALL_STRING)) {
+                                    || isPhoneNumber(
+                                            connection.getAddress().getSchemeSpecificPart())) {
                                 Log.d(this, "Removing PROPERTY_IS_DOWNGRADED_CONFERENCE"
                                         + " from connection %s", connection);
                                 int newProperties = connection.getConnectionProperties()
@@ -320,4 +321,11 @@
             }
         }
     }
+
+    private boolean isPhoneNumber(String number) {
+        if (TextUtils.isEmpty(number)) {
+            return false;
+        }
+        return Patterns.PHONE.matcher(number).matches();
+    }
 }