Merge "refactor nvreset to rebootRadioModem and resetRadioModemConfig"
diff --git a/src/com/android/phone/CLIRListPreference.java b/src/com/android/phone/CLIRListPreference.java
old mode 100644
new mode 100755
index b3ff171..5c6132b
--- a/src/com/android/phone/CLIRListPreference.java
+++ b/src/com/android/phone/CLIRListPreference.java
@@ -7,6 +7,7 @@
import android.os.Handler;
import android.os.Message;
import android.preference.ListPreference;
+import android.telephony.CarrierConfigManager;
import android.util.AttributeSet;
import android.util.Log;
@@ -26,6 +27,12 @@
private Phone mPhone;
private TimeConsumingPreferenceListener mTcpListener;
+ private final String[] mEntries = getContext().getResources()
+ .getStringArray(R.array.clir_display_values);
+ private final String[] mValues = getContext().getResources()
+ .getStringArray(R.array.clir_values);
+ private boolean mConfigSupportNetworkDefault;
+
int clirArray[];
public CLIRListPreference(Context context, AttributeSet attrs) {
@@ -40,7 +47,7 @@
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
- mPhone.setOutgoingCallerIdDisplay(findIndexOfValue(getValue()),
+ mPhone.setOutgoingCallerIdDisplay(convertValueToCLIRMode(getValue()),
mHandler.obtainMessage(MyHandler.MESSAGE_SET_CLIR));
if (mTcpListener != null) {
mTcpListener.onStarted(this, false);
@@ -51,6 +58,19 @@
TimeConsumingPreferenceListener listener, boolean skipReading, Phone phone) {
mPhone = phone;
mTcpListener = listener;
+ mConfigSupportNetworkDefault = PhoneGlobals.getInstance()
+ .getCarrierConfigForSubId(mPhone.getSubId())
+ .getBoolean(CarrierConfigManager.KEY_SUPPORT_CLIR_NETWORK_DEFAULT_BOOL);
+ // When "Network default" is not supported, create entries with remaining two values.
+ if (!mConfigSupportNetworkDefault) {
+ String[] noNetworkDefaultEntries = {mEntries[CommandsInterface.CLIR_INVOCATION],
+ mEntries[CommandsInterface.CLIR_SUPPRESSION]};
+ String[] noNetworkDefaultValues = {mValues[CommandsInterface.CLIR_INVOCATION],
+ mValues[CommandsInterface.CLIR_SUPPRESSION]};
+ setEntries(noNetworkDefaultEntries);
+ setEntryValues(noNetworkDefaultValues);
+ }
+
if (!skipReading) {
Log.i(LOG_TAG, "init: requesting CLIR");
mPhone.getOutgoingCallerIdDisplay(mHandler.obtainMessage(MyHandler.MESSAGE_GET_CLIR,
@@ -92,7 +112,10 @@
value = CommandsInterface.CLIR_DEFAULT;
break;
}
- setValueIndex(value);
+ value = (!mConfigSupportNetworkDefault && value == CommandsInterface.CLIR_DEFAULT)
+ ? CommandsInterface.CLIR_SUPPRESSION : value;
+
+ setValue(mValues[value]);
// set the string summary to reflect the value
int summary = R.string.sum_default_caller_id;
@@ -110,6 +133,25 @@
setSummary(summary);
}
+ /**
+ * When "Network default" is hidden, UI list index(0-1) doesn't match CLIR Mode(0-2 for Modem).
+ * In order to send request to Modem, it is necessary to convert value to CLIR Mode.
+ * ("Hide" = CommandsInterface.CLIR_INVOCATION, "Show" = CommandsInterface.CLIR_SUPPRESSION)
+ *
+ * @param String of entry value.
+ * @return "CommandInterface.CLIR_*" for Modem.
+ */
+ private int convertValueToCLIRMode(String value) {
+ if (mValues[CommandsInterface.CLIR_INVOCATION].equals(value)) {
+ return CommandsInterface.CLIR_INVOCATION;
+ } else if (mValues[CommandsInterface.CLIR_SUPPRESSION].equals(value)) {
+ return CommandsInterface.CLIR_SUPPRESSION;
+ } else {
+ return mConfigSupportNetworkDefault ? CommandsInterface.CLIR_DEFAULT :
+ CommandsInterface.CLIR_SUPPRESSION;
+ }
+ }
+
private class MyHandler extends Handler {
static final int MESSAGE_GET_CLIR = 0;
static final int MESSAGE_SET_CLIR = 1;
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 1fbbd33..1619aa1 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -62,7 +62,6 @@
import android.text.TextWatcher;
import android.text.method.DialerKeyListener;
import android.text.style.TtsSpan;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.HapticFeedbackConstants;
@@ -348,8 +347,21 @@
// Allow turning screen on
setTurnScreenOn(true);
- mAreEmergencyDialerShortcutsEnabled = FeatureFlagUtils
- .isEnabled(this, FeatureFlagUtils.EMERGENCY_DIAL_SHORTCUTS);
+ CarrierConfigManager configMgr = getSystemService(CarrierConfigManager.class);
+ PersistableBundle carrierConfig =
+ configMgr.getConfigForSubId(SubscriptionManager.getDefaultVoiceSubscriptionId());
+
+ // Disable emergency dialer shortcut when can't get the location information or inserting
+ // the SIM of the blacklisted carrier.
+ boolean isSupport = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_SUPPORT_EMERGENCY_DIALER_SHORTCUT_BOOL);
+ Log.d(LOG_TAG, "Is the carrier supported: " + isSupport);
+ TelephonyManager tm = getSystemService(TelephonyManager.class);
+ if (isSupport && !TextUtils.isEmpty(tm.getNetworkCountryIso())) {
+ mAreEmergencyDialerShortcutsEnabled = true;
+ } else {
+ mAreEmergencyDialerShortcutsEnabled = false;
+ }
Log.d(LOG_TAG, "Enable emergency dialer shortcut: "
+ mAreEmergencyDialerShortcutsEnabled);
@@ -400,11 +412,6 @@
// Check whether we should show the onscreen "Dial" button and co.
// Read carrier config through the public API because PhoneGlobals is not available when we
// run as a secondary user.
- CarrierConfigManager configMgr =
- (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
- PersistableBundle carrierConfig =
- configMgr.getConfigForSubId(SubscriptionManager.getDefaultVoiceSubscriptionId());
-
if (carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_ONSCREEN_DIAL_BUTTON_BOOL)) {
mDialButton.setOnClickListener(this);
} else {
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f896012..09c4d97 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -4308,21 +4308,20 @@
@Override
public int getRadioAccessFamily(int phoneId, String callingPackage) {
Phone phone = PhoneFactory.getPhone(phoneId);
+ int raf = RadioAccessFamily.RAF_UNKNOWN;
if (phone == null) {
- return RadioAccessFamily.RAF_UNKNOWN;
+ return raf;
}
- int subId = phone.getSubId();
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getRadioAccessFamily")) {
- return RadioAccessFamily.RAF_UNKNOWN;
- }
-
final long identity = Binder.clearCallingIdentity();
try {
- return ProxyController.getInstance().getRadioAccessFamily(phoneId);
+ TelephonyPermissions
+ .enforeceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
+ mApp, phone.getSubId(), "getRadioAccessFamily");
+ raf = ProxyController.getInstance().getRadioAccessFamily(phoneId);
} finally {
Binder.restoreCallingIdentity(identity);
}
+ return raf;
}
@Override