Use framework scheme definitions

Use PhoneAccount defined values for SCHEME_{TEL, SIP, VOICEMAIL}.

Bug:17398074
Change-Id: I36adb16f659daef89957072f9e00d08ea2cb8e9e
diff --git a/sip/src/com/android/services/telephony/sip/SipConnection.java b/sip/src/com/android/services/telephony/sip/SipConnection.java
index 534b27a..583fa0e 100644
--- a/sip/src/com/android/services/telephony/sip/SipConnection.java
+++ b/sip/src/com/android/services/telephony/sip/SipConnection.java
@@ -21,13 +21,13 @@
 import android.os.Message;
 import android.telecomm.AudioState;
 import android.telecomm.Connection;
+import android.telecomm.PhoneAccount;
 import android.telecomm.PhoneCapabilities;
 import android.util.Log;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.sip.SipPhone;
-import com.android.phone.Constants;
 
 import java.util.List;
 import java.util.Objects;
@@ -307,7 +307,7 @@
         if (address == null) {
             address = "";
         }
-        return Uri.fromParts(Constants.SCHEME_SIP, address, null);
+        return Uri.fromParts(PhoneAccount.SCHEME_SIP, address, null);
     }
 
     private void close() {
diff --git a/sip/src/com/android/services/telephony/sip/SipUtil.java b/sip/src/com/android/services/telephony/sip/SipUtil.java
index 5733a18..e926fa1 100644
--- a/sip/src/com/android/services/telephony/sip/SipUtil.java
+++ b/sip/src/com/android/services/telephony/sip/SipUtil.java
@@ -32,8 +32,6 @@
             "com.android.services.telephony.sip.phone_account";
     static final String GATEWAY_PROVIDER_PACKAGE =
             "com.android.phone.extra.GATEWAY_PROVIDER_PACKAGE";
-    static final String SCHEME_TEL = "tel";
-    static final String SCHEME_SIP = "sip";
 
     private static boolean sIsVoipSupported;
     private static boolean sIsVoipSupportedInitialized;
diff --git a/src/com/android/phone/CallController.java b/src/com/android/phone/CallController.java
index a42f57d..a25b7a9 100644
--- a/src/com/android/phone/CallController.java
+++ b/src/com/android/phone/CallController.java
@@ -32,6 +32,7 @@
 import android.os.Message;
 import android.os.SystemProperties;
 import android.provider.CallLog.Calls;
+import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
 import android.util.Log;
@@ -466,7 +467,8 @@
                 //   app.cdmaOtaInCallScreenUiState.state are redundant.
                 //   Combine them.
 
-                boolean voicemailUriSpecified = scheme != null && scheme.equals("voicemail");
+                boolean voicemailUriSpecified = scheme != null &&
+                    scheme.equals(PhoneAccount.SCHEME_VOICEMAIL);
                 // Check for an obscure ECM-related scenario: If the phone
                 // is currently in ECM (Emergency callback mode) and we
                 // dial a non-emergency number, that automatically
diff --git a/src/com/android/phone/CallGatewayManager.java b/src/com/android/phone/CallGatewayManager.java
index 893070b..a349d17 100644
--- a/src/com/android/phone/CallGatewayManager.java
+++ b/src/com/android/phone/CallGatewayManager.java
@@ -18,6 +18,7 @@
 
 import android.content.Intent;
 import android.net.Uri;
+import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 import android.util.Log;
@@ -185,7 +186,7 @@
      */
     public static String formatProviderUri(Uri uri) {
         if (uri != null) {
-            if (Constants.SCHEME_TEL.equals(uri.getScheme())) {
+            if (PhoneAccount.SCHEME_TEL.equals(uri.getScheme())) {
                 return PhoneNumberUtils.formatNumber(uri.getSchemeSpecificPart());
             } else {
                 return uri.toString();
diff --git a/src/com/android/phone/Constants.java b/src/com/android/phone/Constants.java
index 3e10c3a..79a1e9a 100644
--- a/src/com/android/phone/Constants.java
+++ b/src/com/android/phone/Constants.java
@@ -125,16 +125,6 @@
     }
 
     //
-    // URI schemes
-    //
-
-    public static final String SCHEME_SIP = "sip";
-    public static final String SCHEME_SMS = "sms";
-    public static final String SCHEME_SMSTO = "smsto";
-    public static final String SCHEME_TEL = "tel";
-    public static final String SCHEME_VOICEMAIL = "voicemail";
-
-    //
     // TODO: Move all the various EXTRA_* and intent action constants here too.
     // (Currently they're all over the place: InCallScreen,
     // OutgoingCallBroadcaster, OtaUtils, etc.)
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index bed49a9..ca42f2a 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -30,6 +30,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.provider.Settings;
+import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.text.Editable;
 import android.text.TextUtils;
@@ -213,7 +214,7 @@
 
         // Extract phone number from intent
         Uri data = getIntent().getData();
-        if (data != null && (Constants.SCHEME_TEL.equals(data.getScheme()))) {
+        if (data != null && (PhoneAccount.SCHEME_TEL.equals(data.getScheme()))) {
             String number = PhoneNumberUtils.getNumberFromIntent(getIntent(), this);
             if (number != null) {
                 mDigits.setText(number);
@@ -520,7 +521,7 @@
                 return;
             }
             Intent intent = new Intent(Intent.ACTION_CALL_EMERGENCY);
-            intent.setData(Uri.fromParts(Constants.SCHEME_TEL, mLastNumber, null));
+            intent.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, mLastNumber, null));
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             startActivity(intent);
             finish();
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 6650892..668038c 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -40,6 +40,7 @@
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.PhoneLookup;
 import android.provider.Settings;
+import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
 import android.text.BidiFormatter;
@@ -322,7 +323,7 @@
             }
 
             Intent intent = new Intent(Intent.ACTION_CALL,
-                    Uri.fromParts(Constants.SCHEME_VOICEMAIL, "", null));
+                    Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null));
             PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
 
             SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
diff --git a/src/com/android/phone/OtaUtils.java b/src/com/android/phone/OtaUtils.java
index fe11831..4a9154f 100644
--- a/src/com/android/phone/OtaUtils.java
+++ b/src/com/android/phone/OtaUtils.java
@@ -37,6 +37,7 @@
 import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.os.UserHandle;
+import android.telecomm.PhoneAccount;
 import android.telephony.TelephonyManager;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -687,7 +688,7 @@
         if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
             // Place an outgoing call to the special OTASP number:
             Intent newIntent = new Intent(Intent.ACTION_CALL);
-            newIntent.setData(Uri.fromParts(Constants.SCHEME_TEL, OTASP_NUMBER, null));
+            newIntent.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, OTASP_NUMBER, null));
 
             // Initiate the outgoing call:
             mApplication.callController.placeCall(newIntent);
diff --git a/src/com/android/phone/OutgoingCallBroadcaster.java b/src/com/android/phone/OutgoingCallBroadcaster.java
index 6d8830e..0f47c12 100644
--- a/src/com/android/phone/OutgoingCallBroadcaster.java
+++ b/src/com/android/phone/OutgoingCallBroadcaster.java
@@ -35,6 +35,7 @@
 import android.os.RemoteException;
 import android.os.SystemProperties;
 import android.os.UserHandle;
+import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 import android.util.Log;
@@ -607,7 +608,7 @@
         // a plain address, whether it could be a tel: URI, etc.)
         Uri uri = intent.getData();
         String scheme = uri.getScheme();
-        if (Constants.SCHEME_SIP.equals(scheme) || PhoneNumberUtils.isUriNumber(number)) {
+        if (PhoneAccount.SCHEME_SIP.equals(scheme) || PhoneNumberUtils.isUriNumber(number)) {
             Log.i(TAG, "The requested number was detected as SIP call.");
             startSipCallOptionHandler(this, intent, uri, number);
             finish();
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 41f4710..2b864cc 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -33,6 +33,7 @@
 import android.os.Message;
 import android.os.RemoteException;
 import android.os.SystemProperties;
+import android.telecomm.PhoneAccount;
 import android.telecomm.VideoProfile;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
@@ -597,7 +598,7 @@
         if (useGateway) {
             // TODO: 'tel' should be a constant defined in framework base
             // somewhere (it is in webkit.)
-            if (null == gatewayUri || !Constants.SCHEME_TEL.equals(gatewayUri.getScheme())) {
+            if (null == gatewayUri || !PhoneAccount.SCHEME_TEL.equals(gatewayUri.getScheme())) {
                 Log.e(LOG_TAG, "Unsupported URL:" + gatewayUri);
                 return CALL_STATUS_FAILED;
             }
@@ -1234,7 +1235,7 @@
 
         // The sip: scheme is simple: just treat the rest of the URI as a
         // SIP address.
-        if (Constants.SCHEME_SIP.equals(scheme)) {
+        if (PhoneAccount.SCHEME_SIP.equals(scheme)) {
             return uri.getSchemeSpecificPart();
         }
 
@@ -1245,7 +1246,7 @@
 
         // Check for a voicemail-dialing request.  If the voicemail number is
         // empty, throw a VoiceMailNumberMissingException.
-        if (Constants.SCHEME_VOICEMAIL.equals(scheme) &&
+        if (PhoneAccount.SCHEME_VOICEMAIL.equals(scheme) &&
                 (number == null || TextUtils.isEmpty(number)))
             throw new VoiceMailNumberMissingException();
 
diff --git a/src/com/android/phone/SimContacts.java b/src/com/android/phone/SimContacts.java
index bebb6ea..cc2b992 100644
--- a/src/com/android/phone/SimContacts.java
+++ b/src/com/android/phone/SimContacts.java
@@ -38,6 +38,7 @@
 import android.provider.ContactsContract.CommonDataKinds.StructuredName;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.RawContacts;
+import android.telecomm.PhoneAccount;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.ContextMenu;
@@ -345,7 +346,7 @@
                         return true;
                     }
                     Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
-                            Uri.fromParts(Constants.SCHEME_TEL, phoneNumber, null));
+                            Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null));
                     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                           | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                     startActivity(intent);
diff --git a/src/com/android/services/telephony/TelecommAccountRegistry.java b/src/com/android/services/telephony/TelecommAccountRegistry.java
index 095073b..1eaf6e1 100644
--- a/src/com/android/services/telephony/TelecommAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecommAccountRegistry.java
@@ -97,7 +97,7 @@
                     : dummyPrefix + "SIM card in slot " + slotId;
             PhoneAccount account = PhoneAccount.builder()
                     .withAccountHandle(phoneAccountHandle)
-                    .withHandle(Uri.fromParts(TEL_SCHEME, line1Number, null))
+                    .withHandle(Uri.fromParts(PhoneAccount.SCHEME_TEL, line1Number, null))
                     .withSubscriptionNumber(subNumber)
                     .withCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
                             PhoneAccount.CAPABILITY_CALL_PROVIDER)
@@ -132,8 +132,6 @@
         }
     };
 
-    private static final String TEL_SCHEME = "tel";
-    private static final String VOICEMAIL_SCHEME = "voicemail";
     private static TelecommAccountRegistry sInstance;
     private final Context mContext;
     private final TelecommManager mTelecommManager;
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 732c107..60e5d17 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -22,6 +22,7 @@
 import android.os.Message;
 import android.telecomm.AudioState;
 import android.telecomm.Connection;
+import android.telecomm.PhoneAccount;
 import android.telecomm.PhoneCapabilities;
 import android.telephony.DisconnectCause;
 
@@ -639,7 +640,7 @@
         if (address == null) {
             address = "";
         }
-        return Uri.fromParts(TelephonyConnectionService.SCHEME_TEL, address, null);
+        return Uri.fromParts(PhoneAccount.SCHEME_TEL, address, null);
     }
 
     /**
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index c56f745..5d96665 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -22,6 +22,7 @@
 import android.telecomm.Connection;
 import android.telecomm.ConnectionRequest;
 import android.telecomm.ConnectionService;
+import android.telecomm.PhoneAccount;
 import android.telecomm.PhoneAccountHandle;
 import android.telephony.DisconnectCause;
 import android.telephony.PhoneNumberUtils;
@@ -45,9 +46,6 @@
  * Service for making GSM and CDMA connections.
  */
 public class TelephonyConnectionService extends ConnectionService {
-    static String SCHEME_TEL = "tel";
-    static String SCHEME_VOICEMAIL = "voicemail";
-
     private final GsmConferenceController mGsmConferenceController =
             new GsmConferenceController(this);
     private final CdmaConferenceController mCdmaConferenceController =
@@ -76,7 +74,7 @@
 
         String scheme = handle.getScheme();
         final String number;
-        if (SCHEME_VOICEMAIL.equals(scheme)) {
+        if (PhoneAccount.SCHEME_VOICEMAIL.equals(scheme)) {
             // TODO: We don't check for SecurityException here (requires
             // CALL_PRIVILEGED permission).
             final Phone phone = getPhoneForAccount(request.getAccountHandle(), false);
@@ -88,9 +86,9 @@
             }
 
             // Convert voicemail: to tel:
-            handle = Uri.fromParts(SCHEME_TEL, number, null);
+            handle = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
         } else {
-            if (!SCHEME_TEL.equals(scheme)) {
+            if (!PhoneAccount.SCHEME_TEL.equals(scheme)) {
                 Log.d(this, "onCreateOutgoingConnection, Handle %s is not type tel", scheme);
                 return Connection.createFailedConnection(DisconnectCause.INVALID_NUMBER,
                         "Handle scheme is not type tel");
diff --git a/tests/src/com/android/phone/tests/CallDialTest.java b/tests/src/com/android/phone/tests/CallDialTest.java
index 5ea80d1..baade32 100644
--- a/tests/src/com/android/phone/tests/CallDialTest.java
+++ b/tests/src/com/android/phone/tests/CallDialTest.java
@@ -23,6 +23,7 @@
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.telecomm.PhoneAccount;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 import android.util.Log;
@@ -125,9 +126,9 @@
             if (number.contains(":")) {
                 uri = Uri.parse(number);
             } else if (PhoneNumberUtils.isUriNumber(number)) {
-                uri = Uri.fromParts(Constants.SCHEME_SIP, number, null);
+                uri = Uri.fromParts(PhoneAccount.SCHEME_SIP, number, null);
             } else {
-                uri = Uri.fromParts(Constants.SCHEME_TEL, number, null);
+                uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
             }
         }
         log("==> uri: " + uri);