Merge "Improve SimPhonebookContract javadocs and qualifiers"

This commit is contained in:
Marcus Hagerott
2021-04-07 15:43:33 +00:00
committed by Gerrit Code Review
2 changed files with 36 additions and 18 deletions

View File

@@ -33998,8 +33998,8 @@ package android.provider {
public static final class SimPhonebookContract.SimRecords { public static final class SimPhonebookContract.SimRecords {
method @NonNull public static android.net.Uri getContentUri(int, int); method @NonNull public static android.net.Uri getContentUri(int, int);
method @WorkerThread public static int getEncodedNameLength(@NonNull android.content.ContentResolver, @NonNull String); method @IntRange(from=0) @WorkerThread public static int getEncodedNameLength(@NonNull android.content.ContentResolver, @NonNull String);
method @NonNull public static android.net.Uri getItemUri(int, int, int); method @NonNull public static android.net.Uri getItemUri(int, int, @IntRange(from=1) int);
field public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sim-contact_v2"; field public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sim-contact_v2";
field public static final String CONTENT_TYPE = "vnd.android.cursor.dir/sim-contact_v2"; field public static final String CONTENT_TYPE = "vnd.android.cursor.dir/sim-contact_v2";
field public static final String ELEMENTARY_FILE_TYPE = "elementary_file_type"; field public static final String ELEMENTARY_FILE_TYPE = "elementary_file_type";

View File

@@ -17,13 +17,14 @@
package android.provider; package android.provider;
import static android.provider.SimPhonebookContract.ElementaryFiles.EF_ADN; import static android.provider.SimPhonebookContract.ElementaryFiles.EF_ADN;
import static android.provider.SimPhonebookContract.ElementaryFiles.EF_ADN_PATH_SEGMENT;
import static android.provider.SimPhonebookContract.ElementaryFiles.EF_FDN; import static android.provider.SimPhonebookContract.ElementaryFiles.EF_FDN;
import static android.provider.SimPhonebookContract.ElementaryFiles.EF_FDN_PATH_SEGMENT;
import static android.provider.SimPhonebookContract.ElementaryFiles.EF_SDN; import static android.provider.SimPhonebookContract.ElementaryFiles.EF_SDN;
import static android.provider.SimPhonebookContract.ElementaryFiles.EF_SDN_PATH_SEGMENT; import static android.provider.SimPhonebookContract.ElementaryFiles.PATH_SEGMENT_EF_ADN;
import static android.provider.SimPhonebookContract.ElementaryFiles.PATH_SEGMENT_EF_FDN;
import static android.provider.SimPhonebookContract.ElementaryFiles.PATH_SEGMENT_EF_SDN;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.annotation.WorkerThread; import android.annotation.WorkerThread;
@@ -78,11 +79,11 @@ public final class SimPhonebookContract {
public static String getEfUriPath(@ElementaryFiles.EfType int efType) { public static String getEfUriPath(@ElementaryFiles.EfType int efType) {
switch (efType) { switch (efType) {
case EF_ADN: case EF_ADN:
return EF_ADN_PATH_SEGMENT; return PATH_SEGMENT_EF_ADN;
case EF_FDN: case EF_FDN:
return EF_FDN_PATH_SEGMENT; return PATH_SEGMENT_EF_FDN;
case EF_SDN: case EF_SDN:
return EF_SDN_PATH_SEGMENT; return PATH_SEGMENT_EF_SDN;
default: default:
throw new IllegalArgumentException("Unsupported EfType " + efType); throw new IllegalArgumentException("Unsupported EfType " + efType);
} }
@@ -109,9 +110,9 @@ public final class SimPhonebookContract {
* the phone number can contain at most {@link ElementaryFiles#PHONE_NUMBER_MAX_LENGTH} * the phone number can contain at most {@link ElementaryFiles#PHONE_NUMBER_MAX_LENGTH}
* characters. The {@link SimRecords#NAME} column can contain at most * characters. The {@link SimRecords#NAME} column can contain at most
* {@link ElementaryFiles#NAME_MAX_LENGTH} bytes when it is encoded for storage on the SIM. * {@link ElementaryFiles#NAME_MAX_LENGTH} bytes when it is encoded for storage on the SIM.
* Encoding is done internally and so the name should be provided unencoded but the number of * Encoding is done internally and so the name should be provided to these provider APIs as a
* bytes required to encode it will vary depending on the characters it contains. This length * Java String but the number of bytes required to encode it for storage will vary depending on
* can be determined by calling * the characters it contains. This length can be determined by calling
* {@link SimRecords#getEncodedNameLength(ContentResolver, String)}. * {@link SimRecords#getEncodedNameLength(ContentResolver, String)}.
* </p> * </p>
* <h3>Operations </h3> * <h3>Operations </h3>
@@ -308,7 +309,8 @@ public final class SimPhonebookContract {
*/ */
@NonNull @NonNull
public static Uri getItemUri( public static Uri getItemUri(
int subscriptionId, @ElementaryFiles.EfType int efType, int recordNumber) { int subscriptionId, @ElementaryFiles.EfType int efType,
@IntRange(from = 1) int recordNumber) {
// Elementary file record indices are 1-based. // Elementary file record indices are 1-based.
Preconditions.checkArgument(recordNumber > 0, "Invalid recordNumber"); Preconditions.checkArgument(recordNumber > 0, "Invalid recordNumber");
@@ -332,6 +334,7 @@ public final class SimPhonebookContract {
* @see ElementaryFiles#NAME_MAX_LENGTH * @see ElementaryFiles#NAME_MAX_LENGTH
*/ */
@WorkerThread @WorkerThread
@IntRange(from = 0)
public static int getEncodedNameLength( public static int getEncodedNameLength(
@NonNull ContentResolver resolver, @NonNull String name) { @NonNull ContentResolver resolver, @NonNull String name) {
Objects.requireNonNull(name); Objects.requireNonNull(name);
@@ -442,12 +445,27 @@ public final class SimPhonebookContract {
* methods operating on this Uri will throw UnsupportedOperationException * methods operating on this Uri will throw UnsupportedOperationException
*/ */
public static final int EF_SDN = 3; public static final int EF_SDN = 3;
/** @hide */ /**
public static final String EF_ADN_PATH_SEGMENT = "adn"; * The Uri path segment used to target the ADN elementary file for SimPhonebookProvider
/** @hide */ * content operations.
public static final String EF_FDN_PATH_SEGMENT = "fdn"; *
/** @hide */ * @hide
public static final String EF_SDN_PATH_SEGMENT = "sdn"; */
public static final String PATH_SEGMENT_EF_ADN = "adn";
/**
* The Uri path segment used to target the FDN elementary file for SimPhonebookProvider
* content operations.
*
* @hide
*/
public static final String PATH_SEGMENT_EF_FDN = "fdn";
/**
* The Uri path segment used to target the SDN elementary file for SimPhonebookProvider
* content operations.
*
* @hide
*/
public static final String PATH_SEGMENT_EF_SDN = "sdn";
/** The MIME type of CONTENT_URI providing a directory of ADN-like elementary files. */ /** The MIME type of CONTENT_URI providing a directory of ADN-like elementary files. */
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/sim-elementary-file"; public static final String CONTENT_TYPE = "vnd.android.cursor.dir/sim-elementary-file";
/** The MIME type of a CONTENT_URI subdirectory of a single ADN-like elementary file. */ /** The MIME type of a CONTENT_URI subdirectory of a single ADN-like elementary file. */