Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a14642cb authored by Abhijith Shastry's avatar Abhijith Shastry Committed by Android (Google) Code Review
Browse files

Merge "BlockedNumberContract API changes:"

parents 7a8c2b18 d907c64f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
+20 −13
Original line number Diff line number Diff line
@@ -88,14 +88,6 @@ public class BlockedNumberContract {
         */
        public static final String COLUMN_ORIGINAL_NUMBER = "original_number";

        /**
         * 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.
@@ -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);
    }

}