[automerger skipped] Import translations. DO NOT MERGE
am: 751ffa4da9 -s ours
am skip reason: subject contains skip directive

Change-Id: Ie839512de2fa151ee41c4e5346568ef89b29050f
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..1fab3bc
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,17 @@
+android_app {
+    name: "BlockedNumberProvider",
+
+    // Only compile source java files in this apk.
+    srcs: ["src/**/*.java"],
+    static_libs: [
+        "android-common",
+        "guava",
+    ],
+    jacoco: {
+        include_filter: ["com.android.providers.blockednumber.*"],
+    },
+    platform_apis: true,
+    certificate: "shared",
+    privileged: true,
+
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index e5afdfb..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_STATIC_JAVA_LIBRARIES += android-common guava
-
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.providers.blockednumber.*
-
-LOCAL_PACKAGE_NAME := BlockedNumberProvider
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := shared
-LOCAL_PRIVILEGED_MODULE := true
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/res/values-as/strings.xml b/res/values-as/strings.xml
deleted file mode 100644
index cd2206b..0000000
--- a/res/values-as/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--  Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="app_label" msgid="3836152623003881586">"অৱৰোধ কৰা নম্বৰৰ সঞ্চয়াগাৰ"</string>
-</resources>
diff --git a/res/values-en-rXC/strings.xml b/res/values-en-rXC/strings.xml
index 3d1a1c1..be6a766 100644
--- a/res/values-en-rXC/strings.xml
+++ b/res/values-en-rXC/strings.xml
@@ -16,5 +16,5 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="app_label" msgid="3836152623003881586">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‎‏‎‎‏‎‎‎‎‎‏‏‏‏‏‎‏‏‎‏‎‏‎‎‏‏‏‏‎‎‏‏‎‎‎‎‎‎‎‏‏‏‏‏‎‎‎‏‎‏‏‏‏‎‎‏‎‏‎‏‎‎‎‏‎‏‎‎‎‎‎‏‏‏‎‎‏‎‎Blocked Numbers Storage‎‏‎‎‏‎"</string>
+    <string name="app_label" msgid="3836152623003881586">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‏‎‎‏‎‎‎‎‎‏‏‏‏‏‎‏‏‎‏‎‏‎‎‏‏‏‏‎‎‏‏‎‎‎‎‎‎‎‏‏‏‏‏‎‎‎‏‎‏‏‏‏‎‎‏‎‏‎‏‎‎‎‏‎‏‎‎‎‎‎‏‏‏‎‎‏‎‎Blocked Numbers Storage‎‏‎‎‏‎"</string>
 </resources>
diff --git a/res/values-mr/strings.xml b/res/values-mr/strings.xml
index 23dd405..80f05ec 100644
--- a/res/values-mr/strings.xml
+++ b/res/values-mr/strings.xml
@@ -16,5 +16,5 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="app_label" msgid="3836152623003881586">"अवरोधित केलेल्या नंबरचा स्टोरेज"</string>
+    <string name="app_label" msgid="3836152623003881586">"अवरोधित केलेल्या नंबरचा संचय"</string>
 </resources>
diff --git a/res/values-or/strings.xml b/res/values-or/strings.xml
deleted file mode 100644
index 5dea283..0000000
--- a/res/values-or/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--  Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
- -->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="app_label" msgid="3836152623003881586">"ଅବରୋଧିତ ସଂଖ୍ୟାର ଷ୍ଟୋରେଜ୍"</string>
-</resources>
diff --git a/src/com/android/providers/blockednumber/BlockedNumberProvider.java b/src/com/android/providers/blockednumber/BlockedNumberProvider.java
index 44a5f84..864f08a 100644
--- a/src/com/android/providers/blockednumber/BlockedNumberProvider.java
+++ b/src/com/android/providers/blockednumber/BlockedNumberProvider.java
@@ -308,8 +308,11 @@
         switch (method) {
             case BlockedNumberContract.METHOD_IS_BLOCKED:
                 enforceReadPermissionAndPrimaryUser();
-
-                res.putBoolean(BlockedNumberContract.RES_NUMBER_IS_BLOCKED, isBlocked(arg));
+                boolean isBlocked = isBlocked(arg);
+                res.putBoolean(BlockedNumberContract.RES_NUMBER_IS_BLOCKED, isBlocked);
+                res.putInt(BlockedNumberContract.RES_BLOCK_STATUS,
+                        isBlocked ? BlockedNumberContract.STATUS_BLOCKED_IN_LIST
+                                : BlockedNumberContract.STATUS_NOT_BLOCKED);
                 break;
             case BlockedNumberContract.METHOD_CAN_CURRENT_USER_BLOCK_NUMBERS:
                 // No permission checks: any app should be able to access this API.
@@ -341,8 +344,10 @@
                 break;
             case SystemContract.METHOD_SHOULD_SYSTEM_BLOCK_NUMBER:
                 enforceSystemReadPermissionAndPrimaryUser();
+                int blockReason = shouldSystemBlockNumber(arg, extras);
                 res.putBoolean(BlockedNumberContract.RES_NUMBER_IS_BLOCKED,
-                        shouldSystemBlockNumber(arg, extras));
+                        blockReason != BlockedNumberContract.STATUS_NOT_BLOCKED);
+                res.putInt(BlockedNumberContract.RES_BLOCK_STATUS, blockReason);
                 break;
             case SystemContract.METHOD_SHOULD_SHOW_EMERGENCY_CALL_NOTIFICATION:
                 enforceSystemReadPermissionAndPrimaryUser();
@@ -474,63 +479,85 @@
                 blockSuppressionExpiryTimeMillis);
     }
 
-    private boolean shouldSystemBlockNumber(String phoneNumber, Bundle extras) {
+    private int shouldSystemBlockNumber(String phoneNumber, Bundle extras) {
         if (getBlockSuppressionStatus().isSuppressed) {
-            return false;
+            return BlockedNumberContract.STATUS_NOT_BLOCKED;
         }
         if (isEmergencyNumber(phoneNumber)) {
-            return false;
+            return BlockedNumberContract.STATUS_NOT_BLOCKED;
         }
 
         boolean isBlocked = false;
+        int blockReason = BlockedNumberContract.STATUS_NOT_BLOCKED;
         if (extras != null && !extras.isEmpty()) {
             // check enhanced blocking setting
             boolean contactExist = extras.getBoolean(BlockedNumberContract.EXTRA_CONTACT_EXIST);
             int presentation = extras.getInt(BlockedNumberContract.EXTRA_CALL_PRESENTATION);
             switch (presentation) {
                 case TelecomManager.PRESENTATION_ALLOWED:
-                    isBlocked = getEnhancedBlockSetting(
+                    if (getEnhancedBlockSetting(
                             SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED)
-                                    && !contactExist;
+                                    && !contactExist) {
+                        blockReason = BlockedNumberContract.STATUS_BLOCKED_NOT_IN_CONTACTS;
+                    }
                     break;
                 case TelecomManager.PRESENTATION_RESTRICTED:
-                    isBlocked = getEnhancedBlockSetting(
-                            SystemContract.ENHANCED_SETTING_KEY_BLOCK_PRIVATE);
+                    if (getEnhancedBlockSetting(
+                            SystemContract.ENHANCED_SETTING_KEY_BLOCK_PRIVATE)) {
+                        blockReason = BlockedNumberContract.STATUS_BLOCKED_RESTRICTED;
+                    }
                     break;
                 case TelecomManager.PRESENTATION_PAYPHONE:
-                    isBlocked = getEnhancedBlockSetting(
-                            SystemContract.ENHANCED_SETTING_KEY_BLOCK_PAYPHONE);
+                    if (getEnhancedBlockSetting(
+                            SystemContract.ENHANCED_SETTING_KEY_BLOCK_PAYPHONE)) {
+                        blockReason = BlockedNumberContract.STATUS_BLOCKED_PAYPHONE;
+                    }
                     break;
                 case TelecomManager.PRESENTATION_UNKNOWN:
-                    isBlocked = getEnhancedBlockSetting(
-                            SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNKNOWN);
+                    if (getEnhancedBlockSetting(
+                            SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNKNOWN)) {
+                        blockReason = BlockedNumberContract.STATUS_BLOCKED_UNKNOWN_NUMBER;
+                    }
                     break;
                 default:
                     break;
             }
         }
-        return isBlocked || isBlocked(phoneNumber);
+        if (blockReason == BlockedNumberContract.STATUS_NOT_BLOCKED && isBlocked(phoneNumber)) {
+            blockReason = BlockedNumberContract.STATUS_BLOCKED_IN_LIST;
+        }
+        return blockReason;
     }
 
     private boolean shouldShowEmergencyCallNotification() {
         return isEnhancedCallBlockingEnabledByPlatform()
-                && isAnyEnhancedBlockingSettingEnabled()
+                && (isShowCallBlockingDisabledNotificationAlways()
+                        || isAnyEnhancedBlockingSettingEnabled())
                 && getBlockSuppressionStatus().isSuppressed
                 && getEnhancedBlockSetting(
                         SystemContract.ENHANCED_SETTING_KEY_SHOW_EMERGENCY_CALL_NOTIFICATION);
     }
 
-    private boolean isEnhancedCallBlockingEnabledByPlatform() {
+    private PersistableBundle getCarrierConfig() {
         CarrierConfigManager configManager = (CarrierConfigManager) getContext().getSystemService(
                 Context.CARRIER_CONFIG_SERVICE);
         PersistableBundle carrierConfig = configManager.getConfig();
         if (carrierConfig == null) {
             carrierConfig = configManager.getDefaultConfig();
         }
-        return carrierConfig.getBoolean(
+        return carrierConfig;
+    }
+
+    private boolean isEnhancedCallBlockingEnabledByPlatform() {
+        return getCarrierConfig().getBoolean(
                 CarrierConfigManager.KEY_SUPPORT_ENHANCED_CALL_BLOCKING_BOOL);
     }
 
+    private boolean isShowCallBlockingDisabledNotificationAlways() {
+        return getCarrierConfig().getBoolean(
+                CarrierConfigManager.KEY_SHOW_CALL_BLOCKING_DISABLED_NOTIFICATION_ALWAYS_BOOL);
+    }
+
     private boolean isAnyEnhancedBlockingSettingEnabled() {
         return getEnhancedBlockSetting(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED)
                 || getEnhancedBlockSetting(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PRIVATE)
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..e4e57ed
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,21 @@
+android_test {
+    name: "BlockedNumberProviderTest",
+    static_libs: [
+        "mockito-target-minus-junit4",
+        "android-support-test",
+    ],
+    libs: [
+        "android.test.runner",
+        "android.test.base",
+        "android.test.mock",
+    ],
+    // Only compile source java files in this apk.
+    srcs: ["src/**/*.java"],
+    platform_apis: true,
+    test_suites: ["device-tests"],
+    instrumentation_for: "BlockedNumberProvider",
+    certificate: "shared",
+    optimize: {
+        enabled: false,
+    },
+}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 379f7b8..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    mockito-target-minus-junit4 \
-    android-support-test
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base android.test.mock
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := BlockedNumberProviderTest
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-LOCAL_INSTRUMENTATION_FOR := BlockedNumberProvider
-LOCAL_CERTIFICATE := shared
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
diff --git a/tests/src/com/android/providers/blockednumber/BlockedNumberContractTest.java b/tests/src/com/android/providers/blockednumber/BlockedNumberContractTest.java
index 89cca78..93e9cee 100644
--- a/tests/src/com/android/providers/blockednumber/BlockedNumberContractTest.java
+++ b/tests/src/com/android/providers/blockednumber/BlockedNumberContractTest.java
@@ -16,6 +16,7 @@
 
 package com.android.providers.blockednumber;
 
+import static android.provider.BlockedNumberContract.STATUS_NOT_BLOCKED;
 import static android.provider.BlockedNumberContract.SystemContract
         .ENHANCED_SETTING_KEY_BLOCK_PAYPHONE;
 
@@ -97,8 +98,9 @@
     @SmallTest
     @Test
     public void testShouldSystemBlockNumberException() {
-        assertFalse(BlockedNumberContract.SystemContract.shouldSystemBlockNumber(mMockContext,
-                TEST_NUMBER, null));
+        assertEquals(STATUS_NOT_BLOCKED,
+                BlockedNumberContract.SystemContract.shouldSystemBlockNumber(mMockContext,
+                        TEST_NUMBER, null));
     }
 
     /**
diff --git a/tests/src/com/android/providers/blockednumber/BlockedNumberProviderTest.java b/tests/src/com/android/providers/blockednumber/BlockedNumberProviderTest.java
index 91d2430..828028f 100644
--- a/tests/src/com/android/providers/blockednumber/BlockedNumberProviderTest.java
+++ b/tests/src/com/android/providers/blockednumber/BlockedNumberProviderTest.java
@@ -611,19 +611,24 @@
         insert(cv(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, emergencyNumber));
 
         assertIsBlocked(true, emergencyNumber);
-        assertFalse(SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber, null));
+        assertEquals(BlockedNumberContract.STATUS_NOT_BLOCKED,
+                SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber, null));
 
         setEnhancedBlockSetting(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED, true);
-        assertFalse(SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
+        assertEquals(BlockedNumberContract.STATUS_NOT_BLOCKED,
+                SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
                 createBundleForEnhancedBlocking(TelecomManager.PRESENTATION_ALLOWED, false)));
         setEnhancedBlockSetting(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PRIVATE, true);
-        assertFalse(SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
+        assertEquals(BlockedNumberContract.STATUS_NOT_BLOCKED,
+                SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
                 createBundleForEnhancedBlocking(TelecomManager.PRESENTATION_RESTRICTED, false)));
         setEnhancedBlockSetting(SystemContract.ENHANCED_SETTING_KEY_BLOCK_PAYPHONE, true);
-        assertFalse(SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
+        assertEquals(BlockedNumberContract.STATUS_NOT_BLOCKED,
+                SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
                 createBundleForEnhancedBlocking(TelecomManager.PRESENTATION_PAYPHONE, false)));
         setEnhancedBlockSetting(SystemContract.ENHANCED_SETTING_KEY_BLOCK_UNKNOWN, true);
-        assertFalse(SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
+        assertEquals(BlockedNumberContract.STATUS_NOT_BLOCKED,
+                SystemContract.shouldSystemBlockNumber(mMockContext, emergencyNumber,
                 createBundleForEnhancedBlocking(TelecomManager.PRESENTATION_UNKNOWN, false)));
     }
 
@@ -707,8 +712,9 @@
     }
 
     private void assertShouldSystemBlock(boolean expected, String phoneNumber, Bundle extras) {
-        assertEquals(expected, SystemContract.shouldSystemBlockNumber(mMockContext, phoneNumber,
-                extras));
+        assertEquals(expected,
+                SystemContract.shouldSystemBlockNumber(mMockContext, phoneNumber, extras)
+                        != BlockedNumberContract.STATUS_NOT_BLOCKED);
     }
 
     private void setEnhancedBlockSetting(String key, boolean value) {