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

Commit 17b54cdf authored by Liefu Liu's avatar Liefu Liu Committed by Android (Google) Code Review
Browse files

Merge "Added Settings#resetAccountAttributes API." into main

parents 063fc5c4 ff654744
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -38308,6 +38308,7 @@ package android.provider {
  public static final class ContactsContract.Settings implements android.provider.ContactsContract.SettingsColumns {
    method @FlaggedApi("android.provider.new_account_attributes_api_enabled") @RequiresPermission(android.Manifest.permission.READ_CONTACTS) public static long getAccountAttributes(@NonNull android.content.ContentResolver, @Nullable android.accounts.Account, @Nullable String);
    method @Deprecated @FlaggedApi("android.provider.new_default_account_api_enabled") @Nullable public static android.accounts.Account getDefaultAccount(@NonNull android.content.ContentResolver);
    method @FlaggedApi("android.provider.new_account_attributes_api_enabled") @RequiresPermission(android.Manifest.permission.WRITE_CONTACTS) public static void resetAccountAttributes(@NonNull android.content.ContentResolver, @Nullable android.accounts.Account, @Nullable String);
    method @FlaggedApi("android.provider.new_account_attributes_api_enabled") @RequiresPermission(android.Manifest.permission.WRITE_CONTACTS) public static void setAccountAttributes(@NonNull android.content.ContentResolver, @Nullable android.accounts.Account, @Nullable String, long);
    field public static final String ACTION_SET_DEFAULT_ACCOUNT = "android.provider.action.SET_DEFAULT_ACCOUNT";
    field public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
+55 −8
Original line number Diff line number Diff line
@@ -9393,6 +9393,14 @@ public final class ContactsContract {
        public static final String SET_ACCOUNT_ATTRIBUTES_METHOD =
                "setAccountAttributes";

        /**
         * The method to invoke in order to reset the account attributes.
         *
         * @hide
         */
        public static final String RESET_ACCOUNT_ATTRIBUTES_METHOD =
                "resetAccountAttributes";

        /**
         * The method to invoke in order to get the account attributes.
         *
@@ -9547,8 +9555,9 @@ public final class ContactsContract {
         * attributes enabled or set.
         *
         * @param resolver The {@link ContentResolver} to use for the query.
         * @param account  The account to query. If {@code null}, this will query the
         * attributes of the local, device-only account.
         * @param account  The account to query. If {@code null}, this queries the attributes of
         *                 the <strong>local, device-only account</strong> (where both account_name
         *                 and account_type are null).
         * @param dataSet  The data set specific to the account type, which may be {@code null}.
         * @return A {@code long} representing the attributes bitmask.
         * @throws IllegalStateException if the specified account does not exist or its
@@ -9590,16 +9599,17 @@ public final class ContactsContract {
         * <h4>Security</h4>
         * <p> This method requires that the calling application to be the authenticator
         * for the account's type.
         * @see android.accounts.AccountManager#getAuthenticatorTypes()
         *
         * @param resolver      The {@code ContentResolver} to use for the update.
         * @param account         The target account. If {@code null}, this operation applies to the
         *                        local, device-only account.
         * @param account       @param account The target account.
         * @param dataSet       The data set within the account, which may be {@code null}.
         * @param newAttributes The complete new bitmask of attributes to apply.
         * @throws IllegalArgumentException if {@code newAttributes} contains any undefined
         *                                  bits, has semantic conflicts, or the account is
         *                                  otherwise invalid.
         * @throws SecurityException        if the calling package is not the authenticator for the
         *                                  account type.
         * @see android.accounts.AccountManager#getAuthenticatorTypes()
         */
        @FlaggedApi(Flags.FLAG_NEW_ACCOUNT_ATTRIBUTES_API_ENABLED)
        @RequiresPermission(android.Manifest.permission.WRITE_CONTACTS)
@@ -9619,6 +9629,43 @@ public final class ContactsContract {
                    SET_ACCOUNT_ATTRIBUTES_METHOD, null,
                    extras);
        }

        /**
         * Resets the attributes for a given account to their system-evaluated defaults.
         *
         * <p>This operation removes any explicit overrides set via
         * {@link #setAccountAttributes} and causes the system to immediately re-evaluate the
         * account's attributes based on its type and other characteristics
         *
         * <h4>Security</h4>
         * <p>This method requires that the calling application be the authenticator for the
         * account's type, as defined in {@link android.accounts.AccountManager}.
         *
         * @param resolver The {@code ContentResolver} to use for the update.
         * @param account  @param account The target account.
         * @param dataSet  The data set within the account, which may be {@code null}.
         * @throws IllegalArgumentException if the target account is otherwise invalid.
         * @throws SecurityException        if the calling package is not the authenticator for the
         *                                  account type.
         * @see android.accounts.AccountManager#getAuthenticatorTypes()
         */
        @FlaggedApi(Flags.FLAG_NEW_ACCOUNT_ATTRIBUTES_API_ENABLED)
        @RequiresPermission(android.Manifest.permission.WRITE_CONTACTS)
        public static void resetAccountAttributes(@NonNull ContentResolver resolver,
                @Nullable Account account, @Nullable String dataSet) {
            Bundle extras = new Bundle();
            if (account != null) {
                extras.putString(ACCOUNT_NAME, account.name);
                extras.putString(ACCOUNT_TYPE, account.type);
            }
            if (!TextUtils.isEmpty(dataSet)) {
                extras.putString(DATA_SET, dataSet);
            }
            // No need to put attributes, the method name implies the action.
            nullSafeCall(resolver, ContactsContract.AUTHORITY_URI,
                    RESET_ACCOUNT_ATTRIBUTES_METHOD, null,
                    extras);
        }
    }

    /**