Use framework scheme definitions
Use PhoneAccount defined values for SCHEME_{TEL, SIP, VOICEMAIL}.
Bug:17398074
Change-Id: I9ee0aa081cd6a98fc569a32906a3de73fed6bcbe
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index f354291..72437a2 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -24,6 +24,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.UserManager;
+import android.telecomm.PhoneAccount;
import android.telecomm.PhoneAccountHandle;
import android.telecomm.TelecommManager;
import android.telephony.DisconnectCause;
@@ -123,9 +124,9 @@
String scheme = handle.getScheme();
String uriString = handle.getSchemeSpecificPart();
- if (!Constants.SCHEME_VOICEMAIL.equals(scheme)) {
+ if (!PhoneAccount.SCHEME_VOICEMAIL.equals(scheme)) {
handle = Uri.fromParts(PhoneNumberUtils.isUriNumber(uriString) ?
- Constants.SCHEME_SIP : Constants.SCHEME_TEL, uriString, null);
+ PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL, uriString, null);
}
UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
diff --git a/src/com/android/telecomm/Constants.java b/src/com/android/telecomm/Constants.java
index 9967fa2..656114f 100644
--- a/src/com/android/telecomm/Constants.java
+++ b/src/com/android/telecomm/Constants.java
@@ -28,8 +28,5 @@
// URI schemes
//
- public static final String SCHEME_SIP = "sip";
public static final String SCHEME_SMSTO = "smsto";
- public static final String SCHEME_TEL = "tel";
- public static final String SCHEME_VOICEMAIL = "voicemail";
-}
\ No newline at end of file
+}
diff --git a/src/com/android/telecomm/Log.java b/src/com/android/telecomm/Log.java
index ebcc175..3b241fa 100644
--- a/src/com/android/telecomm/Log.java
+++ b/src/com/android/telecomm/Log.java
@@ -17,6 +17,7 @@
package com.android.telecomm;
import android.net.Uri;
+import android.telecomm.PhoneAccount;
import android.telephony.PhoneNumberUtils;
import java.security.MessageDigest;
@@ -134,7 +135,7 @@
Uri uri = (Uri) pii;
// All Uri's which are not "tel" go through normal pii() method.
- if (!"tel".equals(uri.getScheme())) {
+ if (!PhoneAccount.SCHEME_TEL.equals(uri.getScheme())) {
return pii(pii);
} else {
pii = uri.getSchemeSpecificPart();
diff --git a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
index 1032018..14c86bc 100644
--- a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
@@ -24,6 +24,7 @@
import android.net.Uri;
import android.os.UserHandle;
import android.telecomm.GatewayInfo;
+import android.telecomm.PhoneAccount;
import android.telecomm.TelecommManager;
import android.telecomm.VideoProfile;
import android.telephony.DisconnectCause;
@@ -114,7 +115,7 @@
}
Uri resultHandleUri = Uri.fromParts(PhoneNumberUtils.isUriNumber(resultNumber) ?
- Constants.SCHEME_SIP : Constants.SCHEME_TEL, resultNumber, null);
+ PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL, resultNumber, null);
Uri originalUri = mIntent.getData();
@@ -163,7 +164,7 @@
return DisconnectCause.INVALID_NUMBER;
}
- boolean isVoicemailNumber = Constants.SCHEME_VOICEMAIL.equals(handle.getScheme());
+ boolean isVoicemailNumber = PhoneAccount.SCHEME_VOICEMAIL.equals(handle.getScheme());
if (isVoicemailNumber) {
if (Intent.ACTION_CALL.equals(action)) {
// Voicemail calls will be handled directly by the telephony connection manager
@@ -228,7 +229,7 @@
if (callImmediately) {
Log.i(this, "Placing call immediately instead of waiting for "
+ " OutgoingCallBroadcastReceiver: %s", intent);
- String scheme = isUriNumber ? Constants.SCHEME_SIP : Constants.SCHEME_TEL;
+ String scheme = isUriNumber ? PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL;
boolean speakerphoneOn = mIntent.getBooleanExtra(
TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
int videoState = mIntent.getIntExtra(
diff --git a/tests/src/com/android/telecomm/testapps/CallServiceNotifier.java b/tests/src/com/android/telecomm/testapps/CallServiceNotifier.java
index e8aa19f..e99c395 100644
--- a/tests/src/com/android/telecomm/testapps/CallServiceNotifier.java
+++ b/tests/src/com/android/telecomm/testapps/CallServiceNotifier.java
@@ -109,7 +109,7 @@
.withIconResId(R.drawable.stat_sys_phone_call)
.withLabel("TelecommTestApp Call Provider")
.withShortDescription("a short description for the call provider")
- .withSupportedUriScheme("tel")
+ .withSupportedUriScheme(PhoneAccount.SCHEME_TEL)
.build());
telecommManager.registerPhoneAccount(PhoneAccount.builder()
diff --git a/tests/src/com/android/telecomm/testapps/TestConnectionService.java b/tests/src/com/android/telecomm/testapps/TestConnectionService.java
index 2f8df3d..bac3915 100644
--- a/tests/src/com/android/telecomm/testapps/TestConnectionService.java
+++ b/tests/src/com/android/telecomm/testapps/TestConnectionService.java
@@ -26,6 +26,7 @@
import android.telecomm.AudioState;
import android.telecomm.Conference;
import android.telecomm.Connection;
+import android.telecomm.PhoneAccount;
import android.telecomm.PhoneCapabilities;
import android.telecomm.PropertyPresentation;
import android.telecomm.ConnectionRequest;
@@ -233,8 +234,6 @@
}
}
- private static final String SCHEME_TEL = "tel";
-
private final List<TestConnection> mCalls = new ArrayList<>();
private final Handler mHandler = new Handler();
@@ -318,7 +317,7 @@
// Use dummy number for testing incoming calls.
Uri handle = providedHandle == null ?
- Uri.fromParts(SCHEME_TEL, getDummyNumber(isVideoCall), null) : providedHandle;
+ Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(isVideoCall), null) : providedHandle;
if (isVideoCall) {
TestVideoProvider testVideoCallProvider =
new TestVideoProvider(getApplicationContext());
diff --git a/tests/src/com/android/telecomm/tests/unit/PhoneAccountRegistrarTest.java b/tests/src/com/android/telecomm/tests/unit/PhoneAccountRegistrarTest.java
index 41b7924..b64714e 100644
--- a/tests/src/com/android/telecomm/tests/unit/PhoneAccountRegistrarTest.java
+++ b/tests/src/com/android/telecomm/tests/unit/PhoneAccountRegistrarTest.java
@@ -98,7 +98,7 @@
.withIconResId(0)
.withLabel("label2")
.withShortDescription("desc2")
- .withSupportedUriScheme("tel")
+ .withSupportedUriScheme(PhoneAccount.SCHEME_TEL)
.build());
}
@@ -214,7 +214,7 @@
assertEquals(4, mRegistrar.getAllPhoneAccountHandles().size());
assertEquals(3, mRegistrar.getOutgoingPhoneAccounts().size());
assertEquals(null, mRegistrar.getSimCallManager());
- assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
}
public void testSimCallManager() throws Exception {
@@ -240,23 +240,25 @@
public void testDefaultOutgoing() {
// Establish initial conditions
- assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
PhoneAccountHandle h = new PhoneAccountHandle(new ComponentName("pkg0", "cls0"), "id1");
mRegistrar.setUserSelectedOutgoingPhoneAccount(h);
- assertPhoneAccountHandleEquals(h, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertPhoneAccountHandleEquals(h, mRegistrar.getDefaultOutgoingPhoneAccount(
+ PhoneAccount.SCHEME_TEL));
// If account is un-registered, querying returns null
mRegistrar.unregisterPhoneAccount(h);
- assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
// But if account is re-registered, setting comes back
mRegistrar.registerPhoneAccount(makeQuickAccount("pkg0", "cls0", "id1", 99));
- assertPhoneAccountHandleEquals(h, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertPhoneAccountHandleEquals(h, mRegistrar.getDefaultOutgoingPhoneAccount(
+ PhoneAccount.SCHEME_TEL));
// De-register by setting to null
mRegistrar.setUserSelectedOutgoingPhoneAccount(null);
- assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
// If argument not have CALL_PROVIDER capability, this is a no-op
mRegistrar.setUserSelectedOutgoingPhoneAccount(
new PhoneAccountHandle(new ComponentName("pkg0", "cls0"), "id0"));
- assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
// If only have one account, it is the default
mRegistrar.unregisterPhoneAccount(
new PhoneAccountHandle(new ComponentName("pkg0", "cls0"), "id0"));
@@ -266,7 +268,7 @@
new PhoneAccountHandle(new ComponentName("pkg1", "cls1"), "id2"));
assertPhoneAccountHandleEquals(
new PhoneAccountHandle(new ComponentName("pkg1", "cls1"), "id3"),
- mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
// If have one account but not suitable, default returns null
mRegistrar.unregisterPhoneAccount(
new PhoneAccountHandle(new ComponentName("pkg1", "cls1"), "id3"));
@@ -279,7 +281,7 @@
.withLabel("label0")
.withShortDescription("desc0")
.build());
- assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount("tel"));
+ assertEquals(null, mRegistrar.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL));
}
private static PhoneAccount makeQuickAccount(String pkg, String cls, String id, int idx) {
@@ -303,4 +305,4 @@
s.simCallManager = new PhoneAccountHandle(new ComponentName("pkg0", "cls0"), "id1");
return s;
}
-}
\ No newline at end of file
+}