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

Commit 7897ac0d authored by Walter Jang's avatar Walter Jang Committed by Android (Google) Code Review
Browse files

Merge "Fix bug causing a read-only default account to be set" into mnc-dev

parents ee8e95a9 4e1a8de3
Loading
Loading
Loading
Loading
+18 −21
Original line number Diff line number Diff line
@@ -1066,15 +1066,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
     * Saves all writable accounts and the default account, but only for new contacts.
     */
    protected void saveDefaultAccountIfNecessary() {
        // Verify that this is a newly created contact, that the contact is composed of only
        // 1 raw contact, and that the contact is not a user profile.
        if (!Intent.ACTION_INSERT.equals(mAction)
                && !ContactEditorBaseActivity.ACTION_INSERT.equals(mAction)
                && mState.size() == 1
                && !isEditingUserProfile()) {
            return;
        }

        // Verify that this is a newly created contact composed of only 1 raw contact
        // and not a user profile
        if (isInsert(mAction) && mState.size() == 1 && !isEditingUserProfile()) {
            // Find the associated account for this contact (retrieve it here because there are
            // multiple paths to creating a contact and this ensures we always have the correct
            // account).
@@ -1087,6 +1081,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
                    new AccountWithDataSet(name, type, dataSet);
            mEditorUtils.saveDefaultAndAllAccounts(account);
        }
    }

    //
    // Data binding
@@ -1636,8 +1631,10 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
     * Whether the argument Intent requested a contact insert action or not.
     */
    protected static boolean isInsert(Intent intent) {
        if (intent == null) return false;
        final String action = intent.getAction();
        return intent == null ? false : isInsert(intent.getAction());
    }

    protected static boolean isInsert(String action) {
        return Intent.ACTION_INSERT.equals(action)
                || ContactEditorBaseActivity.ACTION_INSERT.equals(action);
    }