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

Commit 3a4e7a28 authored by benny.lin's avatar benny.lin
Browse files

Pop-up "couldn't save contact changes" while switch ap during change the contact photo.



Photo file will be deleted while switch ap during change the contact photo. When savemode is close state, photo will be deleted.

Change-Id: I78be2f9bfa5ad6e9543b28b8293ff2240428f242
Signed-off-by: default avatarbenny.lin <benny634@gmail.com>
parent 955ace24
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -320,6 +320,8 @@ public class ContactSaveService extends IntentService {
        serviceIntent.setAction(ContactSaveService.ACTION_SAVE_CONTACT);
        serviceIntent.putExtra(EXTRA_CONTACT_STATE, (Parcelable) state);
        serviceIntent.putExtra(EXTRA_SAVE_IS_PROFILE, isProfile);
        serviceIntent.putExtra(EXTRA_SAVE_MODE, saveMode);

        if (updatedPhotos != null) {
            serviceIntent.putExtra(EXTRA_UPDATED_PHOTOS, (Parcelable) updatedPhotos);
        }
@@ -340,7 +342,7 @@ public class ContactSaveService extends IntentService {
        RawContactDeltaList state = intent.getParcelableExtra(EXTRA_CONTACT_STATE);
        boolean isProfile = intent.getBooleanExtra(EXTRA_SAVE_IS_PROFILE, false);
        Bundle updatedPhotos = intent.getParcelableExtra(EXTRA_UPDATED_PHOTOS);

        int saveMode = intent.getIntExtra(EXTRA_SAVE_MODE, -1);
        // Trim any empty fields, and RawContacts, before persisting
        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this);
        RawContactModifier.trimEmpty(state, accountTypes);
@@ -465,7 +467,7 @@ public class ContactSaveService extends IntentService {
                    }
                }

                if (!saveUpdatedPhoto(rawContactId, photoUri)) succeeded = false;
                if (!saveUpdatedPhoto(rawContactId, photoUri, saveMode)) succeeded = false;
            }
        }

@@ -486,12 +488,12 @@ public class ContactSaveService extends IntentService {
     * Save updated photo for the specified raw-contact.
     * @return true for success, false for failure
     */
    private boolean saveUpdatedPhoto(long rawContactId, Uri photoUri) {
    private boolean saveUpdatedPhoto(long rawContactId, Uri photoUri, int saveMode) {
        final Uri outputUri = Uri.withAppendedPath(
                ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
                RawContacts.DisplayPhoto.CONTENT_DIRECTORY);

        return ContactPhotoUtils.savePhotoFromUriToUri(this, photoUri, outputUri, true);
        return ContactPhotoUtils.savePhotoFromUriToUri(this, photoUri, outputUri, (saveMode == 0));
    }

    /**