diff options
author | 2024-09-16 17:06:29 +0000 | |
---|---|---|
committer | 2024-09-16 17:06:29 +0000 | |
commit | d09a25782b5d69279b2eb8f19a34bf8799e38eca (patch) | |
tree | 218e9b4e06c78e5d06a015554b19c40ca0265e54 | |
parent | 6774f72ad74e737a93bd0bdb109d2b83546f05b6 (diff) | |
parent | 9ebcfd453e8e8bcd4328737253449721145b6fbc (diff) |
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
-rw-r--r-- | core/api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/provider/ContactsContract.java | 19 |
2 files changed, 9 insertions, 11 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 6d6f7e3c63d1..309f3f1e5ea8 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -36940,7 +36940,6 @@ package android.provider { 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 f6eb4b52984d..01c230fe8f63 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -3027,8 +3027,6 @@ public final class ContactsContract { * 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 @@ public final class ContactsContract { * {@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 final class ContactsContract { */ 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 @@ public final class ContactsContract { 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 @@ public final class ContactsContract { @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 { } |