Merge "Add new API for new feature of display name in Japanese."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8d6e084..6b8c0b2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -356,6 +356,10 @@
     <string name="phone_settings_unknown_txt">Unknown</string>
     <!-- Explanatory text under the call type "phone_settings_unknown_txt". This occurs when no caller ID information unavailable (e.g., international calls, IP phones that operators cannot identify the caller) -->
     <string name="phone_settings_unknown_summary_txt">Block calls from unidentified callers</string>
+    <!-- Call type to be blocked. See the explanatory text "phone_settings_unavailable_summary_txt".  -->
+    <string name="phone_settings_unavailable_txt">Unavailable</string>
+    <!-- Explanatory text under the call type "phone_settings_unavailable_txt". -->
+    <string name="phone_settings_unavailable_summary_txt">Block calls where the number is unavailable</string>
     <!-- Notification. Make this translation consistent with "phone_settings_call_blocking_txt". -->
     <string name="phone_strings_call_blocking_turned_off_notification_title_txt">Call Blocking</string>
     <!-- Notification that appears when the feature Call Blocking has been disabled. -->
diff --git a/res/xml/enhanced_call_blocking_settings.xml b/res/xml/enhanced_call_blocking_settings.xml
index 73ed2af..50c9b36 100644
--- a/res/xml/enhanced_call_blocking_settings.xml
+++ b/res/xml/enhanced_call_blocking_settings.xml
@@ -40,5 +40,11 @@
         android:summary="@string/phone_settings_unknown_summary_txt"
         android:persistent="false"
         android:defaultValue="false"/>
+    <SwitchPreference
+        android:key="block_unavailable_calls_setting"
+        android:title="@string/phone_settings_unavailable_txt"
+        android:summary="@string/phone_settings_unavailable_summary_txt"
+        android:persistent="false"
+        android:defaultValue="false"/>
     <!--Add divider to separate this enhanced call blocking settings from other settings-->
 </PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 36d2db7..746ab57 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -998,6 +998,9 @@
             case TelecomManager.PRESENTATION_UNKNOWN:
                 s.append("Unknown");
                 break;
+            case TelecomManager.PRESENTATION_UNAVAILABLE:
+                s.append("Unavailable");
+                break;
             default:
                 s.append("<undefined>");
         }
diff --git a/src/com/android/server/telecom/callfiltering/BlockCheckerFilter.java b/src/com/android/server/telecom/callfiltering/BlockCheckerFilter.java
index daf6be0..36f2077 100644
--- a/src/com/android/server/telecom/callfiltering/BlockCheckerFilter.java
+++ b/src/com/android/server/telecom/callfiltering/BlockCheckerFilter.java
@@ -155,6 +155,7 @@
                 return CallLog.Calls.BLOCK_REASON_BLOCKED_NUMBER;
 
             case BlockedNumberContract.STATUS_BLOCKED_UNKNOWN_NUMBER:
+            case BlockedNumberContract.STATUS_BLOCKED_UNAVAILABLE:
                 return CallLog.Calls.BLOCK_REASON_UNKNOWN_NUMBER;
 
             case BlockedNumberContract.STATUS_BLOCKED_RESTRICTED:
diff --git a/src/com/android/server/telecom/settings/BlockedNumbersActivity.java b/src/com/android/server/telecom/settings/BlockedNumbersActivity.java
index b573042..036fb91 100644
--- a/src/com/android/server/telecom/settings/BlockedNumbersActivity.java
+++ b/src/com/android/server/telecom/settings/BlockedNumbersActivity.java
@@ -19,7 +19,6 @@
 import android.annotation.Nullable;
 import android.app.ActionBar;
 import android.app.AlertDialog;
-import android.app.Dialog;
 import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
@@ -35,14 +34,13 @@
 import android.database.Cursor;
 import android.os.Bundle;
 import android.provider.BlockedNumberContract;
-import android.provider.ContactsContract;
 import android.telephony.PhoneNumberFormattingTextWatcher;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.TelephonyManager;
 import android.text.Editable;
-import android.text.InputType;
 import android.text.TextUtils;
 import android.text.TextWatcher;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.MenuItem;
 import android.view.View;
diff --git a/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java b/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java
index ecc019f..c0bb56a 100644
--- a/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java
+++ b/src/com/android/server/telecom/settings/EnhancedCallBlockingFragment.java
@@ -42,6 +42,8 @@
             "block_private_number_calls_setting";
     private static final String BLOCK_UNKNOWN_NUMBERS_KEY =
             "block_unknown_calls_setting";
+    private static final String BLOCK_UNAVAILABLE_NUMBERS_KEY =
+            "block_unavailable_calls_setting";
     private boolean mIsCombiningRestrictedAndUnknownOption = false;
 
     @Override
@@ -55,6 +57,7 @@
         setOnPreferenceChangeListener(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PRIVATE);
         setOnPreferenceChangeListener(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PAYPHONE);
         setOnPreferenceChangeListener(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNKNOWN);
+        setOnPreferenceChangeListener(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNAVAILABLE);
         if (!showPayPhoneBlocking()) {
             Preference payPhoneOption = getPreferenceScreen().findPreference(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PAYPHONE);
             getPreferenceScreen().removePreference(payPhoneOption);
@@ -90,8 +93,10 @@
         mIsCombiningRestrictedAndUnknownOption = getResources().getBoolean(
                         R.bool.combine_options_to_block_restricted_and_unknown_callers);
         if (mIsCombiningRestrictedAndUnknownOption) {
-            Preference pref = findPreference(BLOCK_RESTRICTED_NUMBERS_KEY);
-            screen.removePreference(pref);
+            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.");
         }
     }
@@ -116,6 +121,7 @@
             updateEnhancedBlockPref(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PAYPHONE);
         }
         updateEnhancedBlockPref(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNKNOWN);
+        updateEnhancedBlockPref(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNAVAILABLE);
     }
 
     /**
@@ -136,6 +142,8 @@
                     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);
         }
         BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(), preference.getKey(),
                 (boolean) objValue);