diff options
author | twyen <twyen@google.com> | 2018-03-12 15:14:30 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-12 16:00:14 -0700 |
commit | 6b56ebf4753ba9f6db95c7ce3b380ed8556ede55 (patch) | |
tree | fbe3fc71bf85c6cd17487c0dd2b1be777f110701 /java | |
parent | ce208d1065453d81c50ddd2359dee52cb1e6db62 (diff) |
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
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java | 31 |
1 files changed, 18 insertions, 13 deletions
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<String> TRANSSION_CODES = - new ArrayList<String>() { - { - 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; @@ -181,6 +174,18 @@ public class SpecialCharSequenceMgr { } /** + * Get the OEM codes from the config provider. The config provider should be aware of the device + * and manufacturer. + */ + private static ImmutableSet<String> 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. * * <p>This code works alongside the Asynchronous query handler {@link QueryHandler} and query |