summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2015-07-29 19:53:21 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-29 19:53:21 +0000
commitc05c65971c404bce8d1d8a439da347d309b3c1d1 (patch)
treef1fff835e0601bea0dd50354dc520a1d3ac4daa1
parentb53425375dcb6fda3c6537cc8b690fa278dc16ec (diff)
parent615ed9c5e89f06a56ed6ad30244a9f6cb495e85c (diff)
downloadpackages_apps_Contacts-c05c65971c404bce8d1d8a439da347d309b3c1d1.tar.gz
packages_apps_Contacts-c05c65971c404bce8d1d8a439da347d309b3c1d1.tar.bz2
packages_apps_Contacts-c05c65971c404bce8d1d8a439da347d309b3c1d1.zip
am 615ed9c5: Check for WRITE_CONTACTS permission
* commit '615ed9c5e89f06a56ed6ad30244a9f6cb495e85c': Check for WRITE_CONTACTS permission
-rw-r--r--src/com/android/contacts/ContactSaveService.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index dc6cdebbb..6178e9de4 100644
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -16,6 +16,7 @@
package com.android.contacts;
+import static android.Manifest.permission.WRITE_CONTACTS;
import android.app.Activity;
import android.app.IntentService;
import android.content.ContentProviderOperation;
@@ -54,6 +55,7 @@ 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.AccountWithDataSet;
+import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.editor.ContactEditorFragment;
import com.android.contacts.util.ContactPhotoUtils;
@@ -187,6 +189,14 @@ public class ContactSaveService extends IntentService {
Log.d(TAG, "onHandleIntent: could not handle null intent");
return;
}
+ if (!PermissionsUtil.hasPermission(this, WRITE_CONTACTS)) {
+ Log.w(TAG, "No WRITE_CONTACTS permission, unable to write to CP2");
+ // TODO: add more specific error string such as "Turn on Contacts
+ // permission to update your contacts"
+ showToast(R.string.contactSavedErrorToast);
+ return;
+ }
+
// Call an appropriate method. If we're sure it affects how incoming phone calls are
// handled, then notify the fact to in-call screen.
String action = intent.getAction();