Merge "Remove DEFAULT_ACCOUNT_STATE_INVALID from ContactsContract.java. This state is not used anywhere and it is not possible to set it." into main
diff --git a/core/api/current.txt b/core/api/current.txt
index 6d6f7e3..309f3f1e 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -36940,7 +36940,6 @@
method @NonNull public static android.provider.ContactsContract.RawContacts.DefaultAccountAndState ofLocal();
method @NonNull public static android.provider.ContactsContract.RawContacts.DefaultAccountAndState ofNotSet();
field public static final int DEFAULT_ACCOUNT_STATE_CLOUD = 3; // 0x3
- field public static final int DEFAULT_ACCOUNT_STATE_INVALID = 0; // 0x0
field public static final int DEFAULT_ACCOUNT_STATE_LOCAL = 2; // 0x2
field public static final int DEFAULT_ACCOUNT_STATE_NOT_SET = 1; // 0x1
}
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index f6eb4b5..01c230f 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -3027,8 +3027,6 @@
* specified {@link Account} will be saved in the default account.
* The default account can have one of the following four states:
* <ul>
- * <li> {@link #DEFAULT_ACCOUNT_STATE_INVALID}: An invalid state that should not
- * occur on the device. </li>
* <li> {@link #DEFAULT_ACCOUNT_STATE_NOT_SET}: The default account has not
* been set by the user. </li>
* <li> {@link #DEFAULT_ACCOUNT_STATE_LOCAL}: The default account is set to
@@ -3037,15 +3035,11 @@
* {@link Account} will be saved in a null or custom local account. </li>
* <li> {@link #DEFAULT_ACCOUNT_STATE_CLOUD}: The default account is set to a
* cloud-synced account. New raw contacts requested for insertion without a specified
- * {@link Account} will be saved in {@link mCloudAccount}. </li>
+ * {@link Account} will be saved in the default cloud account. </li>
* </ul>
*/
@FlaggedApi(Flags.FLAG_NEW_DEFAULT_ACCOUNT_API_ENABLED)
public static final class DefaultAccountAndState {
- // The state of the default account.
- /** A state that is invalid. */
- public static final int DEFAULT_ACCOUNT_STATE_INVALID = 0;
-
/** A state indicating that default account is not set. */
public static final int DEFAULT_ACCOUNT_STATE_NOT_SET = 1;
@@ -3086,7 +3080,7 @@
*/
public DefaultAccountAndState(@DefaultAccountState int state,
@Nullable Account cloudAccount) {
- if (state == DEFAULT_ACCOUNT_STATE_INVALID) {
+ if (!isValidDefaultAccountState(state)) {
throw new IllegalArgumentException("Invalid default account state.");
}
if ((state == DEFAULT_ACCOUNT_STATE_CLOUD) != (cloudAccount != null)) {
@@ -3170,6 +3164,12 @@
that.mCloudAccount);
}
+ private static boolean isValidDefaultAccountState(int state) {
+ return state == DEFAULT_ACCOUNT_STATE_NOT_SET
+ || state == DEFAULT_ACCOUNT_STATE_LOCAL
+ || state == DEFAULT_ACCOUNT_STATE_CLOUD;
+ }
+
/**
* Annotation for all default account states.
*
@@ -3178,8 +3178,7 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef(
prefix = {"DEFAULT_ACCOUNT_STATE_"},
- value = {DEFAULT_ACCOUNT_STATE_INVALID,
- DEFAULT_ACCOUNT_STATE_NOT_SET,
+ value = {DEFAULT_ACCOUNT_STATE_NOT_SET,
DEFAULT_ACCOUNT_STATE_LOCAL, DEFAULT_ACCOUNT_STATE_CLOUD})
public @interface DefaultAccountState {
}