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

Commit d907c64f authored by Abhijith Shastry's avatar Abhijith Shastry
Browse files

BlockedNumberContract API changes:

1. Add a method isProviderSupportedForCurrentUser for multi-user scenarios.
2. Remove STRIPPED_NUMBER column.

BUG: 26232372

Change-Id: Ida703d7a873915a02cd7918ed297cf039a7956c9
parent 1444cfd5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30135,6 +30135,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;
@@ -30144,7 +30145,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
@@ -32182,6 +32182,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;
@@ -32191,7 +32192,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
@@ -30148,6 +30148,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;
@@ -30157,7 +30158,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);
    }

}