Add the rules to disable emergency dialer shortcut feature.
1.Let emergency dialer shortcut can be disabled by carrier config.
2.Disable emergency dialer shortcut when no location detected.
Test: manual
Bug: 117865402
Change-Id: Ic1919b6ea50007d3fdccd8a8fe8f34eb1751513c
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 {