diff options
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | api/system-current.txt | 2 | ||||
| -rw-r--r-- | api/test-current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/provider/BlockedNumberContract.java | 33 |
4 files changed, 23 insertions, 16 deletions
diff --git a/api/current.txt b/api/current.txt index c7f0a75dcc53..763efc870fa1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -30136,6 +30136,7 @@ package android.provider { } public class BlockedNumberContract { + method public static boolean canCurrentUserBlockNumbers(android.content.Context); method public static boolean isBlocked(android.content.Context, java.lang.String); field public static final java.lang.String AUTHORITY = "com.android.blockednumber"; field public static final android.net.Uri AUTHORITY_URI; @@ -30145,7 +30146,6 @@ package android.provider { field public static final java.lang.String COLUMN_E164_NUMBER = "e164_number"; field public static final java.lang.String COLUMN_ID = "_id"; field public static final java.lang.String COLUMN_ORIGINAL_NUMBER = "original_number"; - field public static final java.lang.String COLUMN_STRIPPED_NUMBER = "stripped_number"; field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/blocked_number"; field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/blocked_numbers"; field public static final android.net.Uri CONTENT_URI; diff --git a/api/system-current.txt b/api/system-current.txt index 3c5e59e6a4c3..29b1e53313a9 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -32183,6 +32183,7 @@ package android.provider { } public class BlockedNumberContract { + method public static boolean canCurrentUserBlockNumbers(android.content.Context); method public static boolean isBlocked(android.content.Context, java.lang.String); field public static final java.lang.String AUTHORITY = "com.android.blockednumber"; field public static final android.net.Uri AUTHORITY_URI; @@ -32192,7 +32193,6 @@ package android.provider { field public static final java.lang.String COLUMN_E164_NUMBER = "e164_number"; field public static final java.lang.String COLUMN_ID = "_id"; field public static final java.lang.String COLUMN_ORIGINAL_NUMBER = "original_number"; - field public static final java.lang.String COLUMN_STRIPPED_NUMBER = "stripped_number"; field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/blocked_number"; field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/blocked_numbers"; field public static final android.net.Uri CONTENT_URI; diff --git a/api/test-current.txt b/api/test-current.txt index 3e755ae299c7..75f03b4153b6 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -30149,6 +30149,7 @@ package android.provider { } public class BlockedNumberContract { + method public static boolean canCurrentUserBlockNumbers(android.content.Context); method public static boolean isBlocked(android.content.Context, java.lang.String); field public static final java.lang.String AUTHORITY = "com.android.blockednumber"; field public static final android.net.Uri AUTHORITY_URI; @@ -30158,7 +30159,6 @@ package android.provider { field public static final java.lang.String COLUMN_E164_NUMBER = "e164_number"; field public static final java.lang.String COLUMN_ID = "_id"; field public static final java.lang.String COLUMN_ORIGINAL_NUMBER = "original_number"; - field public static final java.lang.String COLUMN_STRIPPED_NUMBER = "stripped_number"; field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/blocked_number"; field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/blocked_numbers"; field public static final android.net.Uri CONTENT_URI; diff --git a/core/java/android/provider/BlockedNumberContract.java b/core/java/android/provider/BlockedNumberContract.java index 2a9d4ae762e9..7a9d0625c199 100644 --- a/core/java/android/provider/BlockedNumberContract.java +++ b/core/java/android/provider/BlockedNumberContract.java @@ -91,14 +91,6 @@ public class BlockedNumberContract { /** * Phone number to block. The system generates it from {@link #COLUMN_ORIGINAL_NUMBER} * by removing all formatting characters. - * <p>Must NOT be specified in {@code insert}. - * <p>TYPE: String</p> - */ - public static final String COLUMN_STRIPPED_NUMBER = "stripped_number"; - - /** - * Phone number to block. The system generates it from {@link #COLUMN_ORIGINAL_NUMBER} - * by removing all formatting characters. * <p>Optional in {@code insert}. When not specified, the system tries to generate it * assuming the current country. (Which will still be null if the number is not valid.) * <p>TYPE: String</p> @@ -112,17 +104,32 @@ public class BlockedNumberContract { /** @hide */ public static final String RES_NUMBER_IS_BLOCKED = "blocked"; + /** @hide */ + public static final String METHOD_CAN_CURRENT_USER_BLOCK_NUMBERS = + "can_current_user_block_numbers"; + + /** @hide */ + public static final String RES_CAN_BLOCK_NUMBERS = "can_block"; + /** * Returns whether a given number is in the blocked list. - * - * TODO This should probably catch IllegalArgumentException to guard against the case where - * the provider is encrypted or the user is not running. - * (See addEntryAndRemoveExpiredEntries() in - * http://ag/#/c/844426/3/core/java/android/provider/CallLog.java) + * <p> Note that if the {@link #canCurrentUserBlockNumbers} is {@code false} for the user + * context {@code context}, this method will throw an {@link UnsupportedOperationException}. */ public static boolean isBlocked(Context context, String phoneNumber) { final Bundle res = context.getContentResolver().call(AUTHORITY_URI, METHOD_IS_BLOCKED, phoneNumber, null); return res != null && res.getBoolean(RES_NUMBER_IS_BLOCKED, false); } + + /** + * Returns {@code true} if blocking numbers is supported for the current user. + * <p> Typically, blocking numbers is only supported for the primary user. + */ + public static boolean canCurrentUserBlockNumbers(Context context) { + final Bundle res = context.getContentResolver().call( + AUTHORITY_URI, METHOD_CAN_CURRENT_USER_BLOCK_NUMBERS, null, null); + return res != null && res.getBoolean(RES_CAN_BLOCK_NUMBERS, false); + } + } |