Merge "Add new config to combine unavailable and unknown option"
diff --git a/res/values/config.xml b/res/values/config.xml
index b0e50b0..15f765b 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -73,4 +73,8 @@
<!-- When set, Telecom will attempt to bind to the {@link CallDiagnosticService} implementation
defined by the app with this package name. -->
<string name="call_diagnostic_service_package_name"></string>
+
+ <!-- When true, the options in the call blocking settings to block unavailable and unknown
+ callers are combined into a single toggle. -->
+ <bool name="combine_options_to_block_unavailable_and_unknown_callers">true</bool>
</resources>
diff --git a/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java b/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java
index c0bb56a..b1a1b0e 100644
--- a/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java
+++ b/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java
@@ -45,6 +45,7 @@
private static final String BLOCK_UNAVAILABLE_NUMBERS_KEY =
"block_unavailable_calls_setting";
private boolean mIsCombiningRestrictedAndUnknownOption = false;
+ private boolean mIsCombiningUnavailableAndUnknownOption = false;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -94,11 +95,17 @@
R.bool.combine_options_to_block_restricted_and_unknown_callers);
if (mIsCombiningRestrictedAndUnknownOption) {
Preference restricted_pref = findPreference(BLOCK_RESTRICTED_NUMBERS_KEY);
- Preference unavailable_pref = findPreference(BLOCK_UNAVAILABLE_NUMBERS_KEY);
screen.removePreference(restricted_pref);
- screen.removePreference(unavailable_pref);
Log.i(this, "onCreate: removed block restricted preference.");
}
+
+ mIsCombiningUnavailableAndUnknownOption = getResources().getBoolean(
+ R.bool.combine_options_to_block_unavailable_and_unknown_callers);
+ if (mIsCombiningUnavailableAndUnknownOption) {
+ Preference unavailable_pref = findPreference(BLOCK_UNAVAILABLE_NUMBERS_KEY);
+ screen.removePreference(unavailable_pref);
+ Log.i(this, "onCreate: removed block unavailable preference.");
+ }
}
/**
@@ -136,14 +143,20 @@
@Override
public boolean onPreferenceChange(Preference preference, Object objValue) {
- if (mIsCombiningRestrictedAndUnknownOption
- && preference.getKey().equals(BLOCK_UNKNOWN_NUMBERS_KEY)) {
- Log.i(this, "onPreferenceChange: changing %s and %s to %b",
- preference.getKey(), BLOCK_RESTRICTED_NUMBERS_KEY, (boolean) objValue);
- BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(), BLOCK_RESTRICTED_NUMBERS_KEY,
- (boolean) objValue);
- BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(),
- BLOCK_UNAVAILABLE_NUMBERS_KEY, (boolean) objValue);
+ if (preference.getKey().equals(BLOCK_UNKNOWN_NUMBERS_KEY)) {
+ if (mIsCombiningRestrictedAndUnknownOption) {
+ Log.i(this, "onPreferenceChange: changing %s and %s to %b",
+ preference.getKey(), BLOCK_RESTRICTED_NUMBERS_KEY, (boolean) objValue);
+ BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(),
+ BLOCK_RESTRICTED_NUMBERS_KEY, (boolean) objValue);
+ }
+
+ if (mIsCombiningUnavailableAndUnknownOption) {
+ Log.i(this, "onPreferenceChange: changing %s and %s to %b",
+ preference.getKey(), BLOCK_UNAVAILABLE_NUMBERS_KEY, (boolean) objValue);
+ BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(),
+ BLOCK_UNAVAILABLE_NUMBERS_KEY, (boolean) objValue);
+ }
}
BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(), preference.getKey(),
(boolean) objValue);