API for blocked number provider
Bug 26232372 Change-Id: I4d243c00ab9f02af527a96d7b549abfe7876f565
This commit is contained in:
@@ -29383,6 +29383,22 @@ package android.provider {
|
||||
field public static final java.lang.String _ID = "_id";
|
||||
}
|
||||
|
||||
public class BlockedNumberContract {
|
||||
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;
|
||||
}
|
||||
|
||||
public static class BlockedNumberContract.BlockedNumbers {
|
||||
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;
|
||||
}
|
||||
|
||||
public class Browser {
|
||||
ctor public Browser();
|
||||
method public static final void sendString(android.content.Context, java.lang.String);
|
||||
|
||||
@@ -31388,6 +31388,22 @@ package android.provider {
|
||||
field public static final java.lang.String _ID = "_id";
|
||||
}
|
||||
|
||||
public class BlockedNumberContract {
|
||||
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;
|
||||
}
|
||||
|
||||
public static class BlockedNumberContract.BlockedNumbers {
|
||||
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;
|
||||
}
|
||||
|
||||
public class Browser {
|
||||
ctor public Browser();
|
||||
method public static final void sendString(android.content.Context, java.lang.String);
|
||||
|
||||
@@ -29395,6 +29395,22 @@ package android.provider {
|
||||
field public static final java.lang.String _ID = "_id";
|
||||
}
|
||||
|
||||
public class BlockedNumberContract {
|
||||
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;
|
||||
}
|
||||
|
||||
public static class BlockedNumberContract.BlockedNumbers {
|
||||
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;
|
||||
}
|
||||
|
||||
public class Browser {
|
||||
ctor public Browser();
|
||||
method public static final void sendString(android.content.Context, java.lang.String);
|
||||
|
||||
134
core/java/android/provider/BlockedNumberContract.java
Normal file
134
core/java/android/provider/BlockedNumberContract.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
package android.provider;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* Constants and methods to access blocked phone numbers for incoming calls and texts.
|
||||
*
|
||||
* TODO javadoc
|
||||
* - Proper javadoc tagging.
|
||||
* - Code sample?
|
||||
* - Describe who can access it.
|
||||
*/
|
||||
public class BlockedNumberContract {
|
||||
private BlockedNumberContract() {
|
||||
}
|
||||
|
||||
/** The authority for the contacts provider */
|
||||
public static final String AUTHORITY = "com.android.blockednumber";
|
||||
|
||||
/** A content:// style uri to the authority for the contacts provider */
|
||||
public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
|
||||
|
||||
/**
|
||||
* TODO javadoc
|
||||
*
|
||||
* Constants to interact with the blocked phone number list.
|
||||
*/
|
||||
public static class BlockedNumbers {
|
||||
private BlockedNumbers() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO javadoc
|
||||
*
|
||||
* Content URI for the blocked numbers.
|
||||
*
|
||||
* Supported operations
|
||||
* blocked
|
||||
* - query
|
||||
* - delete
|
||||
* - insert
|
||||
*
|
||||
* blocked/ID
|
||||
* - query (selection is not supported)
|
||||
* - delete (selection is not supported)
|
||||
*/
|
||||
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
|
||||
"blocked");
|
||||
|
||||
/**
|
||||
* The MIME type of {@link #CONTENT_URI} itself providing a directory of blocked phone
|
||||
* numbers.
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/blocked_numbers";
|
||||
|
||||
/**
|
||||
* The MIME type of a blocked phone number under {@link #CONTENT_URI}.
|
||||
*/
|
||||
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/blocked_number";
|
||||
|
||||
/**
|
||||
* Auto-generated ID field which monotonically increases.
|
||||
* <p>TYPE: long</p>
|
||||
*/
|
||||
public static final String COLUMN_ID = "_id";
|
||||
|
||||
/**
|
||||
* Phone number to block.
|
||||
* <p>Must be specified in {@code insert}.
|
||||
* <p>TYPE: String</p>
|
||||
*/
|
||||
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.
|
||||
* <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>
|
||||
*/
|
||||
public static final String COLUMN_E164_NUMBER = "e164_number";
|
||||
|
||||
/** @hide */
|
||||
public static final String COLUMN_INDEX_STRIPPED = "index_stripped";
|
||||
|
||||
/** @hide */
|
||||
public static final String COLUMN_INDEX_E164 = "index_e164";
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static final String METHOD_IS_BLOCKED = "is_blocked";
|
||||
|
||||
/** @hide */
|
||||
public static final String RES_NUMBER_IS_BLOCKED = "blocked";
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user