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: benny.lin <benny634@gmail.com>
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
old mode 100644
new mode 100755
index 7a8f9f3..e686100
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -320,6 +320,8 @@
         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 @@
         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 @@
                     }
                 }
 
-                if (!saveUpdatedPhoto(rawContactId, photoUri)) succeeded = false;
+                if (!saveUpdatedPhoto(rawContactId, photoUri, saveMode)) succeeded = false;
             }
         }
 
@@ -486,12 +488,12 @@
      * 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));
     }
 
     /**