Merge "API changes in GatewayInfo, Response, and PropertyPresentation (3/4)" into lmp-dev
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ae0a7c1..0cd350b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -95,6 +95,7 @@
So, (94 - 38)/2 ==> 28dp -->
<dimen name="incoming_call_widget_asset_margin">28dp</dimen>
<!-- Action bar dimensions. Keep in sync with same value in Dialer. -->
- <dimen name="action_bar_height">64dp</dimen>
+ <dimen name="action_bar_height">56dp</dimen>
+ <dimen name="action_bar_elevation">2dp</dimen>
<dimen name="actionbar_contentInsetStart">72dp</dimen>
</resources>
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/res/values/styles.xml b/res/values/styles.xml
index 76b100a..afc1bd2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -242,6 +242,7 @@
<item name="android:background">@color/actionbar_background_color</item>
<item name="android:titleTextStyle">@style/DialtactsActionBarTitleText</item>
<item name="android:height">@dimen/action_bar_height</item>
+ <item name="android:elevation">@dimen/action_bar_elevation</item>
<!-- Empty icon -->
<item name="android:icon">@android:color/transparent</item>
<!-- Shift the title text to the right -->
@@ -250,7 +251,7 @@
<!-- Text in the action bar at the top of the screen. Should be kept in sync with Dialer. -->
<style name="DialtactsActionBarTitleText"
- parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
+ parent="@android:style/TextAppearance.Material.Widget.ActionBar.Title">
<item name="android:textColor">@color/phone_settings_actionbar_text_color</item>
</style>
diff --git a/sip/src/com/android/services/telephony/sip/SipConnection.java b/sip/src/com/android/services/telephony/sip/SipConnection.java
index 583fa0e..08ca2f0 100644
--- a/sip/src/com/android/services/telephony/sip/SipConnection.java
+++ b/sip/src/com/android/services/telephony/sip/SipConnection.java
@@ -230,6 +230,8 @@
case DIALING:
case ALERTING:
setDialing();
+ // For SIP calls, we need to ask the framework to play the ringback for us.
+ setRequestingRingback(true);
break;
case INCOMING:
case WAITING:
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index e6fc11c..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
@@ -249,7 +249,7 @@
boolean isLteOnCdma = mPhone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE;
mIsGlobalCdma = isLteOnCdma && getResources().getBoolean(R.bool.config_show_cdma);
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- if (tm.getSimplifiedNetworkSettingsEnabled(SubscriptionManager.getDefaultSubId())) {
+ if (tm.getSimplifiedNetworkSettingsEnabledForSubscriber(SubscriptionManager.getDefaultSubId())) {
prefSet.removePreference(mButtonPreferredNetworkMode);
prefSet.removePreference(mButtonEnabledNetworks);
prefSet.removePreference(mLteDataServicePref);
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 99cb206..2ac98d3 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -21,6 +21,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
@@ -37,6 +38,7 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telephony.CellInfo;
import android.telephony.IccOpenLogicalChannelResponse;
@@ -129,12 +131,11 @@
AppOpsManager mAppOps;
MainThreadHandler mMainThreadHandler;
- /**
- * Indicates if Android should display a simplified Mobile Network Settings UI in a specific
- * subscription.
- */
- Set<Long> mSimplifiedNetworkSettings;
- Map<Long, AdnRecord> mAdnRecordsForDisplay;
+ SharedPreferences carrierPrivilegeConfigs;
+ private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_";
+ private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_";
+ private static final String PREF_CARRIERS_SIMPLIFIED_NETWORK_SETTINGS_PREFIX =
+ "carrier_simplified_network_settings_";
/**
* A request object to use for transmitting data to an ICC.
@@ -696,10 +697,10 @@
mApp = app;
mPhone = phone;
mCM = PhoneGlobals.getInstance().mCM;
- mSimplifiedNetworkSettings = new HashSet<Long>();
mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE);
mMainThreadHandler = new MainThreadHandler();
- mAdnRecordsForDisplay = new HashMap<Long, AdnRecord>();
+ carrierPrivilegeConfigs =
+ PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
publish();
}
@@ -714,17 +715,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 +747,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 +779,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 +866,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 +895,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 +926,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 +1036,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 +1048,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 +1107,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 +1139,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 +1191,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 +1202,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 +1401,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 +1412,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 +1426,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 +1437,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 +1479,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 +1496,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 +1512,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 +1528,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 +1563,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();
}
@@ -1929,52 +1930,94 @@
mPhone.getContext().getPackageManager(), intent);
}
+ private String getIccId(long subId) {
+ UiccCard card = getPhone(subId).getUiccCard();
+ if (card == null) {
+ loge("getIccId: No UICC");
+ return null;
+ }
+ String iccId = card.getIccId();
+ if (TextUtils.isEmpty(iccId)) {
+ loge("getIccId: ICC ID is null or empty.");
+ return null;
+ }
+ return iccId;
+ }
+
@Override
- public void enableSimplifiedNetworkSettings(long subId, boolean enable) {
+ public void enableSimplifiedNetworkSettingsForSubscriber(long subId, boolean enable) {
enforceModifyPermissionOrCarrierPrivilege();
- if (enable) {
- mSimplifiedNetworkSettings.add(subId);
- } else {
- mSimplifiedNetworkSettings.remove(subId);
+
+ String iccId = getIccId(subId);
+ if (iccId != null) {
+ String snsPrefKey = PREF_CARRIERS_SIMPLIFIED_NETWORK_SETTINGS_PREFIX + iccId;
+ SharedPreferences.Editor editor = carrierPrivilegeConfigs.edit();
+ if (enable) {
+ editor.putBoolean(snsPrefKey, true);
+ } else {
+ editor.remove(snsPrefKey);
+ }
+ editor.commit();
}
}
@Override
- public boolean getSimplifiedNetworkSettingsEnabled(long subId) {
+ public boolean getSimplifiedNetworkSettingsEnabledForSubscriber(long subId) {
enforceReadPermission();
- return mSimplifiedNetworkSettings.contains(subId);
+ String iccId = getIccId(subId);
+ if (iccId != null) {
+ String snsPrefKey = PREF_CARRIERS_SIMPLIFIED_NETWORK_SETTINGS_PREFIX + iccId;
+ return carrierPrivilegeConfigs.getBoolean(snsPrefKey, false);
+ }
+ return false;
}
@Override
- public void setLine1NumberForDisplay(long subId, String alphaTag, String number) {
+ public void setLine1NumberForDisplayForSubscriber(long subId, String alphaTag, String number) {
enforceModifyPermissionOrCarrierPrivilege();
- mAdnRecordsForDisplay.put(subId, new AdnRecord(alphaTag, number));
+
+ String iccId = getIccId(subId);
+ if (iccId != null) {
+ String alphaTagPrefKey = PREF_CARRIERS_ALPHATAG_PREFIX + iccId;
+ SharedPreferences.Editor editor = carrierPrivilegeConfigs.edit();
+ if (alphaTag == null) {
+ editor.remove(alphaTagPrefKey);
+ } else {
+ editor.putString(alphaTagPrefKey, alphaTag);
+ }
+
+ String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId;
+ if (number == null) {
+ editor.remove(numberPrefKey);
+ } else {
+ editor.putString(numberPrefKey, number);
+ }
+ editor.commit();
+ }
}
@Override
public String getLine1NumberForDisplay(long subId) {
enforceReadPermission();
- if (!mAdnRecordsForDisplay.containsKey(subId)) {
- return null;
+
+ String iccId = getIccId(subId);
+ if (iccId != null) {
+ String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId;
+ return carrierPrivilegeConfigs.getString(numberPrefKey, null);
}
- AdnRecord adnRecord = mAdnRecordsForDisplay.get(subId);
- if (adnRecord.getNumber() == null || adnRecord.getNumber().isEmpty()) {
- return null;
- }
- return adnRecord.getNumber();
+ return null;
}
@Override
public String getLine1AlphaTagForDisplay(long subId) {
enforceReadPermission();
- if (!mAdnRecordsForDisplay.containsKey(subId)) {
- return null;
+
+ String iccId = getIccId(subId);
+ if (iccId != null) {
+ String alphaTagPrefKey = PREF_CARRIERS_ALPHATAG_PREFIX + iccId;
+ return carrierPrivilegeConfigs.getString(alphaTagPrefKey, null);
}
- AdnRecord adnRecord = mAdnRecordsForDisplay.get(subId);
- if (adnRecord.getAlphaTag() == null || adnRecord.getAlphaTag().isEmpty()) {
- return null;
- }
- return adnRecord.getAlphaTag();
+ return null;
}
@Override
diff --git a/src/com/android/services/telephony/TelecommAccountRegistry.java b/src/com/android/services/telephony/TelecommAccountRegistry.java
index 0aba6b4..749739a 100644
--- a/src/com/android/services/telephony/TelecommAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecommAccountRegistry.java
@@ -25,13 +25,16 @@
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;
@@ -43,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 {
@@ -82,7 +85,7 @@
// Populate the phone account data.
long subId = mPhone.getSubId();
int slotId = mPhone.getPhoneId() + 1;
- String line1Number = telephonyManager.getLine1Number(subId);
+ String line1Number = telephonyManager.getLine1NumberForSubscriber(subId);
if (line1Number == null) {
line1Number = "";
}
@@ -90,12 +93,30 @@
if (subNumber == null) {
subNumber = "";
}
- String label = isEmergency
- ? "Emergency calls"
- : dummyPrefix + "SIM " + slotId;
- String description = isEmergency
- ? "Emergency calling only"
- : dummyPrefix + "SIM card in slot " + slotId;
+
+ 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(
@@ -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,6 +148,15 @@
// 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();
}
@@ -153,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();
}
@@ -212,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) {