diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-10-18 02:50:55 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-10-18 02:50:55 +0000 |
commit | ef7a7eb0f103d41df55385267ac52dc3dcf603cb (patch) | |
tree | 8bb6b163a88cf321073913c2b0b7dad5ecbd854e /java/com/android/dialer/assisteddialing/ConcreteCreator.java | |
parent | c2590357cf857e714f875f2a7c222d1bd128c2c5 (diff) | |
parent | 6f78d935ff64f178e9fe8891082c18578d4e4b74 (diff) |
Merge changes Ida554313,Ie7187b02,I7a7c23b4
* changes:
Stop showing partially matched numbers that are not global phone numbers.
Display Voicemail Contact Name and Photo in Voicemail Fragment.
Add temporary assisted dialing setting to Dialer.
Diffstat (limited to 'java/com/android/dialer/assisteddialing/ConcreteCreator.java')
-rw-r--r-- | java/com/android/dialer/assisteddialing/ConcreteCreator.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java index a8a9d2ab3..1790b8f3f 100644 --- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java +++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java @@ -20,8 +20,10 @@ import android.annotation.TargetApi; import android.content.Context; import android.os.Build; import android.os.Build.VERSION_CODES; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.telephony.TelephonyManager; +import com.android.dialer.assisteddialing.ui.R; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProvider; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -63,8 +65,15 @@ public final class ConcreteCreator { throw new NullPointerException("Provided context was null"); } - if ((Build.VERSION.SDK_INT < BUILD_CODE_FLOOR || Build.VERSION.SDK_INT > BUILD_CODE_CEILING) - || !configProvider.getBoolean("assisted_dialing_enabled", false)) { + if (!isAssistedDialingEnabled(configProvider)) { + LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "feature not enabled"); + return new AssistedDialingMediatorStub(); + } + + if (!PreferenceManager.getDefaultSharedPreferences(context) + .getBoolean(context.getString(R.string.assisted_dialing_setting_toggle_key), false)) { + LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "disabled by local setting"); + return new AssistedDialingMediatorStub(); } @@ -74,4 +83,16 @@ public final class ConcreteCreator { return new AssistedDialingMediatorImpl( new LocationDetector(telephonyManager), new NumberTransformer(constraints)); } + + /** Returns a boolean indicating whether or not the assisted dialing feature is enabled. */ + public static boolean isAssistedDialingEnabled(@NonNull ConfigProvider configProvider) { + if (configProvider == null) { + LogUtil.i("ConcreteCreator.isAssistedDialingEnabled", "provided configProvider was null"); + throw new NullPointerException("Provided configProvider was null"); + } + + return (Build.VERSION.SDK_INT >= BUILD_CODE_FLOOR + && Build.VERSION.SDK_INT <= BUILD_CODE_CEILING) + && configProvider.getBoolean("assisted_dialing_enabled", false); + } } |