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

Commit f8c8ac34 authored by Walter Jang's avatar Walter Jang
Browse files

Revert "Don't pass read-only portions of RawContactDeltaList to contact save service"

This reverts commit e5bac73a.

Revert "Don't prune read only contacts in SaveService for joins and splits"

This reverts commit I717717a3c8b55315dcf3dde026af4c267f62e709.

Bug 27108237
Bug 27250533
Bug 23896510

Change-Id: If52f514c01f0d346fddc4083c710b7147761dd7d
parent b320c749
Loading
Loading
Loading
Loading
+2 −32
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ import com.android.contacts.common.model.CPOWrapper;
import com.android.contacts.common.model.RawContactDelta;
import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.model.RawContactModifier;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.compat.PinnedPositionsCompat;
@@ -68,7 +67,6 @@ import com.google.common.collect.Sets;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

@@ -375,16 +373,8 @@ public class ContactSaveService extends IntentService {
            String saveModeExtraKey, int saveMode, boolean isProfile,
            Class<? extends Activity> callbackActivity, String callbackAction,
            Bundle updatedPhotos, String joinContactIdExtraKey, Long joinContactId) {

        // Don't pass read-only RawContactDeltas in RawContactDeltaList to contact save service,
        // because 1. read-only RawContactDeltas are not writable anyway; 2. read-only
        // RawContactDeltas may be problematic, see b/23896510.
        // Except when we must create aggregation exceptions between the raw contacts
        if (!(saveMode == SaveMode.JOIN || saveMode == SaveMode.SPLIT)) {
            removeReadOnlyContacts(context, state);
        }

        Intent serviceIntent = new Intent(context, ContactSaveService.class);
        Intent serviceIntent = new Intent(
                context, ContactSaveService.class);
        serviceIntent.setAction(ContactSaveService.ACTION_SAVE_CONTACT);
        serviceIntent.putExtra(EXTRA_CONTACT_STATE, (Parcelable) state);
        serviceIntent.putExtra(EXTRA_SAVE_IS_PROFILE, isProfile);
@@ -409,26 +399,6 @@ public class ContactSaveService extends IntentService {
        return serviceIntent;
    }

    private static void removeReadOnlyContacts(Context context, RawContactDeltaList state) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "Before trimming: " + state.size());
        }
        int countReadOnly = 0;
        final Iterator<RawContactDelta> iterator = state.iterator();
        while (iterator.hasNext()) {
            final RawContactDelta rawContactDelta = iterator.next();
            final AccountType accountType = rawContactDelta.getRawContactAccountType(context);
            if (accountType != null && !accountType.areContactsWritable()) {
                countReadOnly++;
                iterator.remove();
            }
        }
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "# of read-only removed: " + countReadOnly);
            Log.v(TAG, "After trimming: " + state.size());
        }
    }

    private void saveContact(Intent intent) {
        RawContactDeltaList state = intent.getParcelableExtra(EXTRA_CONTACT_STATE);
        boolean isProfile = intent.getBooleanExtra(EXTRA_SAVE_IS_PROFILE, false);
+2 −1
Original line number Diff line number Diff line
@@ -979,7 +979,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
    abstract protected boolean doSaveAction(int saveMode, Long joinContactId);

    protected boolean startSaveService(Context context, Intent intent, int saveMode) {
        final boolean result = ContactSaveService.startService(context, intent, saveMode);
        final boolean result = ContactSaveService.startService(
                context, intent, saveMode);
        if (!result) {
            onCancelEditConfirmed();
        }