From 6b56ebf4753ba9f6db95c7ce3b380ed8556ede55 Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 12 Mar 2018 15:14:30 -0700 Subject: Use config provider for OEM MMI codes Previously the OEM MMI codes are hardcoded and inadvertently affected other devices. In this CL it is read from the config provider instead. The config provider is expected to provide values based on the OEM. Bug: 72162360,74016291 Test: SpecialCharSequenceMgrTest PiperOrigin-RevId: 188786408 Change-Id: Ie70e49a8a9d2ced5da9cf502c020477615bbe8a2 --- .../dialer/dialpadview/SpecialCharSequenceMgr.java | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'java/com/android/dialer/dialpadview') diff --git a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java index 3321d93f2..d88bac3f7 100644 --- a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java +++ b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java @@ -59,14 +59,15 @@ import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.Selec import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.telephony.TelephonyManagerCompat; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.PermissionsUtil; +import com.google.common.collect.ImmutableSet; import com.google.zxing.BarcodeFormat; import com.google.zxing.MultiFormatWriter; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -93,17 +94,8 @@ public class SpecialCharSequenceMgr { private static final String ADN_NAME_COLUMN_NAME = "name"; private static final int ADN_QUERY_TOKEN = -1; - @VisibleForTesting - static final List TRANSSION_CODES = - new ArrayList() { - { - add("*#07#"); - add("*#87#"); - add("*#43#"); - add("*#2727#"); - add("*#88#"); - } - }; + /** Comma separated MMI codes specific to OEM/device. */ + @VisibleForTesting static final String CONFIG_OEM_MMI_CODES_CSV = "oem_mmi_codes_csv"; /** * Remembers the previous {@link QueryHandler} and cancel the operation when needed, to prevent @@ -172,7 +164,8 @@ public class SpecialCharSequenceMgr { TelephonyManagerCompat.handleSecretCode(context, secretCode); return true; } - if (TRANSSION_CODES.contains(input)) { + + if (getOemSecretCodes(context).contains(input)) { String secretCode = input.substring(2, input.length() - 1); TelephonyManagerCompat.handleSecretCode(context, secretCode); return true; @@ -180,6 +173,18 @@ public class SpecialCharSequenceMgr { return false; } + /** + * Get the OEM codes from the config provider. The config provider should be aware of the device + * and manufacturer. + */ + private static ImmutableSet getOemSecretCodes(Context context) { + String csv = ConfigProviderBindings.get(context).getString(CONFIG_OEM_MMI_CODES_CSV, null); + if (TextUtils.isEmpty(csv)) { + return ImmutableSet.of(); + } + return ImmutableSet.copyOf(csv.split(",")); + } + /** * Handle ADN requests by filling in the SIM contact number into the requested EditText. * -- cgit v1.2.3