Merge "Update telemgr calls with subId to new APIs with ForSubscriber suffix." into lmp-dev
diff --git a/res/values/config.xml b/res/values/config.xml
index 0ced13f..3daf89a 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -120,8 +120,6 @@
<bool name="config_enabled_lte" translatable="false">false</bool>
<!-- Show cdma auto network mode in (glabal) roaming -->
<bool name="config_show_cdma" translatable="false">false</bool>
- <!-- Display enhanced 4G LTE mode menu if true -->
- <bool name="config_enhanced_4g_lte_mode_enable" translatable="false">false</bool>
<!-- Package name for the default in-call UI and dialer [DO NOT TRANSLATE] -->
<string name="ui_default_package" translatable="false">com.android.dialer</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0282c76..b78876f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1218,4 +1218,8 @@
<!-- Label for close button in dialog, for video calling setting. -->
<string name="enable_video_calling_dialog_close">Close</string>
+ <!-- Strings used in Settings->Sim cards for each installed Sim. -->
+ <string name="sim_label_emergency_calls">Emergency calls</string>
+ <string name="sim_description_emergency_calls">Emergency calling only</string>
+ <string name="sim_description_default">SIM card in slot <xliff:g id="slot_id">%d</xliff:g></string>
</resources>
diff --git a/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java b/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
index f830f67..6149231 100644
--- a/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
+++ b/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
@@ -30,6 +30,7 @@
import com.android.phone.R;
+import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -70,20 +71,19 @@
PhoneAccountHandle accountHandle =
SipUtil.createAccountHandle(context, mProfile.getUriString());
-
- PhoneAccount.Builder builder = PhoneAccount.builder()
- .withAccountHandle(accountHandle)
- .withCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
- .withHandle(Uri.parse(mProfile.getUriString()))
- .withLabel(mProfile.getDisplayName())
- .withShortDescription(mProfile.getDisplayName())
- .withIconResId(R.drawable.ic_dialer_sip_black_24dp)
- .withSupportedUriScheme(PhoneAccount.SCHEME_SIP);
-
+ List supportedUriSchemes = Arrays.asList(PhoneAccount.SCHEME_SIP);
if (useSipForPstnCalls) {
- builder.withSupportedUriScheme(PhoneAccount.SCHEME_TEL);
+ supportedUriSchemes.add(PhoneAccount.SCHEME_TEL);
}
+ PhoneAccount.Builder builder = PhoneAccount.builder(
+ accountHandle, mProfile.getDisplayName())
+ .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
+ .setAddress(Uri.parse(mProfile.getUriString()))
+ .setShortDescription(mProfile.getDisplayName())
+ .setIconResId(R.drawable.ic_dialer_sip_black_24dp)
+ .setSupportedUriSchemes(supportedUriSchemes);
+
return builder.build();
}
}
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/SipConnectionService.java b/sip/src/com/android/services/telephony/sip/SipConnectionService.java
index ffaf64d..b12709b 100644
--- a/sip/src/com/android/services/telephony/sip/SipConnectionService.java
+++ b/sip/src/com/android/services/telephony/sip/SipConnectionService.java
@@ -88,7 +88,7 @@
final SipConnection connection = new SipConnection();
- connection.setHandle(request.getHandle(), PropertyPresentation.ALLOWED);
+ connection.setHandle(request.getAddress(), PropertyPresentation.ALLOWED);
connection.setInitializing();
connection.onAddedToCallService();
boolean attemptCall = true;
@@ -265,7 +265,7 @@
private com.android.internal.telephony.Connection startCallWithPhone(
SipPhone phone, ConnectionRequest request) {
- String number = request.getHandle().getSchemeSpecificPart();
+ String number = request.getAddress().getSchemeSpecificPart();
if (VERBOSE) log("startCallWithPhone, number: " + number);
try {
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/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 6324eae..88de152 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -1681,7 +1681,7 @@
}
List<PhoneAccountHandle> simCallManagers = telecommManager.getSimCallManagers();
- if (simCallManagers.size() > 1) {
+ if (!simCallManagers.isEmpty()) {
mSimCallManagerAccount.setModel(
telecommManager,
simCallManagers,
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/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index a975e42..20134ba 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -122,10 +122,7 @@
@Override
public void onDismiss(DialogInterface dialog) {
// Assuming that onClick gets called first
- if (!mOkClicked) {
- mButtonDataRoam.setChecked(false);
- getPreferenceScreen().setEnabled(true);
- }
+ mButtonDataRoam.setChecked(mOkClicked);
}
/**
@@ -185,6 +182,9 @@
preferredNetworkMode);
mButtonEnabledNetworks.setValue(Integer.toString(settingsNetworkMode));
return true;
+ } else if (preference == mButtonDataRoam) {
+ // Do not disable the preference screen if the user clicks Data roaming.
+ return true;
} else {
// if the button is anything but the simple toggle preference,
// we'll need to disable all preferences to reject all click
@@ -330,22 +330,13 @@
android.util.Log.d(LOG_TAG, "keep ltePref");
}
- // Enable enhanced 4G LTE mode settings depending on the value in config.xml
- final boolean isEnhanced4GLteModeEnabled = getResources().getBoolean(
- R.bool.config_enhanced_4g_lte_mode_enable);
- if (!isEnhanced4GLteModeEnabled) {
+ // Enable enhanced 4G LTE mode settings depending on whether exists on platform
+ if (!ImsManager.isEnhanced4gLteModeSettingEnabledByPlatform(this)) {
Preference pref = prefSet.findPreference(BUTTON_4G_LTE_KEY);
if (pref != null) {
prefSet.removePreference(pref);
}
}
- Preference pref = prefSet.findPreference(BUTTON_4G_LTE_KEY);
- if (pref != null) {
- if (!ImsManager.isEnhanced4gLteModeSettingEnabledByPlatform(this)) {
- ((SwitchPreference)pref).setChecked(false);
- pref.setEnabled(false);
- }
- }
ActionBar actionBar = getActionBar();
if (actionBar != null) {
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/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index df4312f..98affd8 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -714,17 +714,17 @@
private Phone getPhone(long subId) {
// FIXME: hack for the moment
return mPhone;
- // return PhoneUtils.getPhoneUsingSubId(subId);
+ // return PhoneUtils.getPhoneForSubscriber(subId);
}
//
// Implementation of the ITelephony interface.
//
public void dial(String number) {
- dialUsingSubId(getPreferredVoiceSubscription(), number);
+ dialForSubscriber(getPreferredVoiceSubscription(), number);
}
- public void dialUsingSubId(long subId, String number) {
+ public void dialForSubscriber(long subId, String number) {
if (DBG) log("dial: " + number);
// No permission check needed here: This is just a wrapper around the
// ACTION_DIAL intent, which is available to any app since it puts up
@@ -746,10 +746,10 @@
}
public void call(String callingPackage, String number) {
- callUsingSubId(getPreferredVoiceSubscription(), callingPackage, number);
+ callForSubscriber(getPreferredVoiceSubscription(), callingPackage, number);
}
- public void callUsingSubId(long subId, String callingPackage, String number) {
+ public void callForSubscriber(long subId, String callingPackage, String number) {
if (DBG) log("call: " + number);
// This is just a wrapper around the ACTION_CALL intent, but we still
@@ -778,23 +778,23 @@
* @return true is a call was ended
*/
public boolean endCall() {
- return endCallUsingSubId(getDefaultSubscription());
+ return endCallForSubscriber(getDefaultSubscription());
}
/**
* End a call based on the call state of the subId
* @return true is a call was ended
*/
- public boolean endCallUsingSubId(long subId) {
+ public boolean endCallForSubscriber(long subId) {
enforceCallPermission();
return (Boolean) sendRequest(CMD_END_CALL, subId, null);
}
public void answerRingingCall() {
- answerRingingCallUsingSubId(getDefaultSubscription());
+ answerRingingCallForSubscriber(getDefaultSubscription());
}
- public void answerRingingCallUsingSubId(long subId) {
+ public void answerRingingCallForSubscriber(long subId) {
if (DBG) log("answerRingingCall...");
// TODO: there should eventually be a separate "ANSWER_PHONE" permission,
// but that can probably wait till the big TelephonyManager API overhaul.
@@ -865,26 +865,26 @@
}
public boolean isOffhook() {
- return isOffhookUsingSubId(getDefaultSubscription());
+ return isOffhookForSubscriber(getDefaultSubscription());
}
- public boolean isOffhookUsingSubId(long subId) {
+ public boolean isOffhookForSubscriber(long subId) {
return (getPhone(subId).getState() == PhoneConstants.State.OFFHOOK);
}
public boolean isRinging() {
- return (isRingingUsingSubId(getDefaultSubscription()));
+ return (isRingingForSubscriber(getDefaultSubscription()));
}
- public boolean isRingingUsingSubId(long subId) {
+ public boolean isRingingForSubscriber(long subId) {
return (getPhone(subId).getState() == PhoneConstants.State.RINGING);
}
public boolean isIdle() {
- return isIdleUsingSubId(getDefaultSubscription());
+ return isIdleForSubscriber(getDefaultSubscription());
}
- public boolean isIdleUsingSubId(long subId) {
+ public boolean isIdleForSubscriber(long subId) {
return (getPhone(subId).getState() == PhoneConstants.State.IDLE);
}
@@ -894,29 +894,29 @@
}
public boolean supplyPin(String pin) {
- return supplyPinUsingSubId(getDefaultSubscription(), pin);
+ return supplyPinForSubscriber(getDefaultSubscription(), pin);
}
- public boolean supplyPinUsingSubId(long subId, String pin) {
- int [] resultArray = supplyPinReportResultUsingSubId(subId, pin);
+ public boolean supplyPinForSubscriber(long subId, String pin) {
+ int [] resultArray = supplyPinReportResultForSubscriber(subId, pin);
return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false;
}
public boolean supplyPuk(String puk, String pin) {
- return supplyPukUsingSubId(getDefaultSubscription(), puk, pin);
+ return supplyPukForSubscriber(getDefaultSubscription(), puk, pin);
}
- public boolean supplyPukUsingSubId(long subId, String puk, String pin) {
- int [] resultArray = supplyPukReportResultUsingSubId(subId, puk, pin);
+ public boolean supplyPukForSubscriber(long subId, String puk, String pin) {
+ int [] resultArray = supplyPukReportResultForSubscriber(subId, puk, pin);
return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false;
}
/** {@hide} */
public int[] supplyPinReportResult(String pin) {
- return supplyPinReportResultUsingSubId(getDefaultSubscription(), pin);
+ return supplyPinReportResultForSubscriber(getDefaultSubscription(), pin);
}
- public int[] supplyPinReportResultUsingSubId(long subId, String pin) {
+ public int[] supplyPinReportResultForSubscriber(long subId, String pin) {
enforceModifyPermission();
final UnlockSim checkSimPin = new UnlockSim(getPhone(subId).getIccCard());
checkSimPin.start();
@@ -925,10 +925,10 @@
/** {@hide} */
public int[] supplyPukReportResult(String puk, String pin) {
- return supplyPukReportResultUsingSubId(getDefaultSubscription(), puk, pin);
+ return supplyPukReportResultForSubscriber(getDefaultSubscription(), puk, pin);
}
- public int[] supplyPukReportResultUsingSubId(long subId, String puk, String pin) {
+ public int[] supplyPukReportResultForSubscriber(long subId, String puk, String pin) {
enforceModifyPermission();
final UnlockSim checkSimPuk = new UnlockSim(getPhone(subId).getIccCard());
checkSimPuk.start();
@@ -1035,11 +1035,11 @@
}
public void updateServiceLocation() {
- updateServiceLocationUsingSubId(getDefaultSubscription());
+ updateServiceLocationForSubscriber(getDefaultSubscription());
}
- public void updateServiceLocationUsingSubId(long subId) {
+ public void updateServiceLocationForSubscriber(long subId) {
// No permission check needed here: this call is harmless, and it's
// needed for the ServiceState.requestStateUpdate() call (which is
// already intentionally exposed to 3rd parties.)
@@ -1047,32 +1047,32 @@
}
public boolean isRadioOn() {
- return isRadioOnUsingSubId(getDefaultSubscription());
+ return isRadioOnForSubscriber(getDefaultSubscription());
}
- public boolean isRadioOnUsingSubId(long subId) {
+ public boolean isRadioOnForSubscriber(long subId) {
return getPhone(subId).getServiceState().getState() != ServiceState.STATE_POWER_OFF;
}
public void toggleRadioOnOff() {
- toggleRadioOnOffUsingSubId(getDefaultSubscription());
+ toggleRadioOnOffForSubscriber(getDefaultSubscription());
}
- public void toggleRadioOnOffUsingSubId(long subId) {
+ public void toggleRadioOnOffForSubscriber(long subId) {
enforceModifyPermission();
- getPhone(subId).setRadioPower(!isRadioOnUsingSubId(subId));
+ getPhone(subId).setRadioPower(!isRadioOnForSubscriber(subId));
}
public boolean setRadio(boolean turnOn) {
- return setRadioUsingSubId(getDefaultSubscription(), turnOn);
+ return setRadioForSubscriber(getDefaultSubscription(), turnOn);
}
- public boolean setRadioUsingSubId(long subId, boolean turnOn) {
+ public boolean setRadioForSubscriber(long subId, boolean turnOn) {
enforceModifyPermission();
if ((getPhone(subId).getServiceState().getState() !=
ServiceState.STATE_POWER_OFF) != turnOn) {
- toggleRadioOnOffUsingSubId(subId);
+ toggleRadioOnOffForSubscriber(subId);
}
return true;
}
@@ -1106,10 +1106,10 @@
}
public boolean setRadioPower(boolean turnOn) {
- return setRadioPowerUsingSubId(getDefaultSubscription(), turnOn);
+ return setRadioPowerForSubscriber(getDefaultSubscription(), turnOn);
}
- public boolean setRadioPowerUsingSubId(long subId, boolean turnOn) {
+ public boolean setRadioPowerForSubscriber(long subId, boolean turnOn) {
enforceModifyPermission();
getPhone(subId).setRadioPower(turnOn);
return true;
@@ -1138,19 +1138,19 @@
}
public boolean handlePinMmi(String dialString) {
- return handlePinMmiUsingSubId(getDefaultSubscription(), dialString);
+ return handlePinMmiForSubscriber(getDefaultSubscription(), dialString);
}
- public boolean handlePinMmiUsingSubId(long subId, String dialString) {
+ public boolean handlePinMmiForSubscriber(long subId, String dialString) {
enforceModifyPermission();
return (Boolean) sendRequest(CMD_HANDLE_PIN_MMI, dialString, subId);
}
public int getCallState() {
- return getCallStateUsingSubId(getDefaultSubscription());
+ return getCallStateForSubscriber(getDefaultSubscription());
}
- public int getCallStateUsingSubId(long subId) {
+ public int getCallStateForSubscriber(long subId) {
return DefaultPhoneNotifier.convertCallState(getPhone(subId).getState());
}
@@ -1190,10 +1190,10 @@
@Override
public void enableLocationUpdates() {
- enableLocationUpdatesUsingSubId(getDefaultSubscription());
+ enableLocationUpdatesForSubscriber(getDefaultSubscription());
}
- public void enableLocationUpdatesUsingSubId(long subId) {
+ public void enableLocationUpdatesForSubscriber(long subId) {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
getPhone(subId).enableLocationUpdates();
@@ -1201,10 +1201,10 @@
@Override
public void disableLocationUpdates() {
- disableLocationUpdatesUsingSubId(getDefaultSubscription());
+ disableLocationUpdatesForSubscriber(getDefaultSubscription());
}
- public void disableLocationUpdatesUsingSubId(long subId) {
+ public void disableLocationUpdatesForSubscriber(long subId) {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
getPhone(subId).disableLocationUpdates();
@@ -1400,10 +1400,10 @@
}
public int getActivePhoneType() {
- return getActivePhoneTypeUsingSubId(getDefaultSubscription());
+ return getActivePhoneTypeForSubscriber(getDefaultSubscription());
}
- public int getActivePhoneTypeUsingSubId(long subId) {
+ public int getActivePhoneTypeForSubscriber(long subId) {
return getPhone(subId).getPhoneType();
}
@@ -1411,11 +1411,11 @@
* Returns the CDMA ERI icon index to display
*/
public int getCdmaEriIconIndex() {
- return getCdmaEriIconIndexUsingSubId(getDefaultSubscription());
+ return getCdmaEriIconIndexForSubscriber(getDefaultSubscription());
}
- public int getCdmaEriIconIndexUsingSubId(long subId) {
+ public int getCdmaEriIconIndexForSubscriber(long subId) {
return getPhone(subId).getCdmaEriIconIndex();
}
@@ -1425,10 +1425,10 @@
* 1 - FLASHING
*/
public int getCdmaEriIconMode() {
- return getCdmaEriIconModeUsingSubId(getDefaultSubscription());
+ return getCdmaEriIconModeForSubscriber(getDefaultSubscription());
}
- public int getCdmaEriIconModeUsingSubId(long subId) {
+ public int getCdmaEriIconModeForSubscriber(long subId) {
return getPhone(subId).getCdmaEriIconMode();
}
@@ -1436,10 +1436,10 @@
* Returns the CDMA ERI text,
*/
public String getCdmaEriText() {
- return getCdmaEriTextUsingSubId(getDefaultSubscription());
+ return getCdmaEriTextForSubscriber(getDefaultSubscription());
}
- public String getCdmaEriTextUsingSubId(long subId) {
+ public String getCdmaEriTextForSubscriber(long subId) {
return getPhone(subId).getCdmaEriText();
}
@@ -1478,13 +1478,13 @@
* Returns the unread count of voicemails
*/
public int getVoiceMessageCount() {
- return getVoiceMessageCountUsingSubId(getDefaultSubscription());
+ return getVoiceMessageCountForSubscriber(getDefaultSubscription());
}
/**
* Returns the unread count of voicemails for a subId
*/
- public int getVoiceMessageCountUsingSubId( long subId) {
+ public int getVoiceMessageCountForSubscriber( long subId) {
return getPhone(subId).getVoiceMessageCount();
}
@@ -1495,14 +1495,14 @@
*/
@Override
public int getNetworkType() {
- return getNetworkTypeUsingSubId(getDefaultSubscription());
+ return getNetworkTypeForSubscriber(getDefaultSubscription());
}
/**
* Returns the network type for a subId
*/
@Override
- public int getNetworkTypeUsingSubId(long subId) {
+ public int getNetworkTypeForSubscriber(long subId) {
return getPhone(subId).getServiceState().getDataNetworkType();
}
@@ -1511,14 +1511,14 @@
*/
@Override
public int getDataNetworkType() {
- return getDataNetworkTypeUsingSubId(getDefaultSubscription());
+ return getDataNetworkTypeForSubscriber(getDefaultSubscription());
}
/**
* Returns the data network type for a subId
*/
@Override
- public int getDataNetworkTypeUsingSubId(long subId) {
+ public int getDataNetworkTypeForSubscriber(long subId) {
return getPhone(subId).getServiceState().getDataNetworkType();
}
@@ -1527,14 +1527,14 @@
*/
@Override
public int getVoiceNetworkType() {
- return getVoiceNetworkTypeUsingSubId(getDefaultSubscription());
+ return getVoiceNetworkTypeForSubscriber(getDefaultSubscription());
}
/**
* Returns the Voice network type for a subId
*/
@Override
- public int getVoiceNetworkTypeUsingSubId(long subId) {
+ public int getVoiceNetworkTypeForSubscriber(long subId) {
return getPhone(subId).getServiceState().getVoiceNetworkType();
}
@@ -1562,10 +1562,10 @@
* or {@link Phone#LTE_ON_CDMA_TRUE}
*/
public int getLteOnCdmaMode() {
- return getLteOnCdmaModeUsingSubId(getDefaultSubscription());
+ return getLteOnCdmaModeForSubscriber(getDefaultSubscription());
}
- public int getLteOnCdmaModeUsingSubId(long subId) {
+ public int getLteOnCdmaModeForSubscriber(long subId) {
return getPhone(subId).getLteOnCdmaMode();
}
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 4dd342f..749739a 100644
--- a/src/com/android/services/telephony/TelecommAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecommAccountRegistry.java
@@ -25,14 +25,18 @@
import android.telecomm.PhoneAccount;
import android.telecomm.PhoneAccountHandle;
import android.telecomm.TelecommManager;
+import android.telephony.SubInfoRecord;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.text.TextUtils;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.TelephonyIntents;
+import com.android.phone.R;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@@ -42,11 +46,11 @@
*/
final class TelecommAccountRegistry {
private final static int[] phoneAccountIcons = {
- com.android.phone.R.drawable.ic_multi_sim,
- com.android.phone.R.drawable.ic_multi_sim1,
- com.android.phone.R.drawable.ic_multi_sim2,
- com.android.phone.R.drawable.ic_multi_sim3,
- com.android.phone.R.drawable.ic_multi_sim4
+ R.drawable.ic_multi_sim,
+ R.drawable.ic_multi_sim1,
+ R.drawable.ic_multi_sim2,
+ R.drawable.ic_multi_sim3,
+ R.drawable.ic_multi_sim4
};
private final class AccountEntry {
@@ -89,23 +93,40 @@
if (subNumber == null) {
subNumber = "";
}
- String label = isEmergency
- ? "Emergency calls"
- : dummyPrefix + "SIM " + slotId;
- String description = isEmergency
- ? "Emergency calling only"
- : dummyPrefix + "SIM card in slot " + slotId;
- PhoneAccount account = PhoneAccount.builder()
- .withAccountHandle(phoneAccountHandle)
- .withHandle(Uri.fromParts(TEL_SCHEME, line1Number, null))
- .withSubscriptionNumber(subNumber)
- .withCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
+
+ String subDisplayName = null;
+ SubInfoRecord record = SubscriptionManager.getSubInfoForSubscriber(subId);
+ if (record != null) {
+ subDisplayName = record.displayName;
+ }
+
+ if (TextUtils.isEmpty(subDisplayName)) {
+ // Either the sub record is not there or it has an empty display name.
+ Log.w(this, "Could not get a display name for subid: %d", subId);
+ subDisplayName = mContext.getResources().getString(
+ R.string.sim_description_default, slotId);
+ }
+
+ // The label is user-visible so let's use the display name that the user may
+ // have set in Settings->Sim cards.
+ String label = isEmergency ?
+ mContext.getResources().getString(R.string.sim_label_emergency_calls) :
+ dummyPrefix + subDisplayName;
+ String description = isEmergency ?
+ mContext.getResources().getString(R.string.sim_description_emergency_calls) :
+ dummyPrefix + mContext.getResources().getString(
+ R.string.sim_description_default, slotId);
+
+ PhoneAccount account = PhoneAccount.builder(phoneAccountHandle, label)
+ .setAddress(Uri.fromParts(PhoneAccount.SCHEME_TEL, line1Number, null))
+ .setSubscriptionAddress(
+ Uri.fromParts(PhoneAccount.SCHEME_TEL, subNumber, null))
+ .setCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
PhoneAccount.CAPABILITY_CALL_PROVIDER)
- .withIconResId(getPhoneAccountIcon(slotId))
- .withLabel(label)
- .withShortDescription(description)
- .withSupportedUriScheme(PhoneAccount.SCHEME_TEL)
- .withSupportedUriScheme(PhoneAccount.SCHEME_VOICEMAIL)
+ .setIconResId(getPhoneAccountIcon(slotId))
+ .setShortDescription(description)
+ .setSupportedUriSchemes(Arrays.asList(
+ PhoneAccount.SCHEME_TEL, PhoneAccount.SCHEME_VOICEMAIL))
.build();
// Register with Telecomm and put into the account entry.
@@ -117,6 +138,7 @@
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
+ boolean rebuildAccounts = false;
String action = intent.getAction();
if (TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED.equals(action)) {
int status = intent.getIntExtra(
@@ -126,14 +148,21 @@
// Anytime the SIM state changes...rerun the setup
// We rely on this notification even when the status is EXTRA_VALUE_NOCHANGE,
// so we explicitly do not check for that here.
+ rebuildAccounts = true;
+ } else if (TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE.equals(action)) {
+ String columnName = intent.getStringExtra(TelephonyIntents.EXTRA_COLUMN_NAME);
+ String stringContent = intent.getStringExtra(TelephonyIntents.EXTRA_STRING_CONTENT);
+ Log.v(this, "SUBINFO_CONTENT_CHANGE: Column: %s Content: %s",
+ columnName, stringContent);
+ rebuildAccounts = true;
+ }
+ if (rebuildAccounts) {
tearDownAccounts();
setupAccounts();
}
}
};
- 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;
@@ -155,10 +184,12 @@
* Sets up all the phone accounts for SIMs on first boot.
*/
void setupOnBoot() {
- IntentFilter intentFilter =
- new IntentFilter(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
+ // We need to register for both types of intents if we want to see added/removed Subs
+ // along with changes to a given Sub.
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
+ intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE);
mContext.registerReceiver(mReceiver, intentFilter);
-
setupAccounts();
}
@@ -214,8 +245,6 @@
if (phones.length > 0 && "TRUE".equals(System.getProperty("dummy_sim"))) {
mAccounts.add(new AccountEntry(phones[0], false /* emergency */, true /* isDummy */));
}
-
- // TODO: Add SIP accounts.
}
private int getPhoneAccountIcon(int index) {
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..29e78fa 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 =
@@ -67,7 +65,7 @@
final ConnectionRequest request) {
Log.i(this, "onCreateOutgoingConnection, request: " + request);
- Uri handle = request.getHandle();
+ Uri handle = request.getAddress();
if (handle == null) {
Log.d(this, "onCreateOutgoingConnection, handle is null");
return Connection.createFailedConnection(DisconnectCause.NO_PHONE_NUMBER_SUPPLIED,
@@ -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);