summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2015-07-14 18:21:40 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-14 18:21:40 +0000
commit3c8a0f30d3e397a994a18d33611d2964a85c4939 (patch)
treedbee8472d8fa974dbd74a2557ae47da1a28c3832 /src
parent927afb6a3f933f9a5caf9e57fb09ae09f58b10aa (diff)
parentacab024e60a3fe95931b2dfc44c114d31870c336 (diff)
am acab024e: am ff36e959: am 112665f0: am 515575eb: Permission protect UndemoteOutgoingCallReceiver
* commit 'acab024e60a3fe95931b2dfc44c114d31870c336': Permission protect UndemoteOutgoingCallReceiver
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java b/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java
index fd3d512f0..172a4efef 100644
--- a/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java
+++ b/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java
@@ -16,6 +16,9 @@
package com.android.dialer.interactions;
+import static android.Manifest.permission.READ_CONTACTS;
+import static android.Manifest.permission.WRITE_CONTACTS;
+
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
@@ -41,7 +44,8 @@ public class UndemoteOutgoingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
- if (!PermissionsUtil.hasContactsPermissions(context)) {
+ if (!PermissionsUtil.hasPermission(context, READ_CONTACTS)
+ || !PermissionsUtil.hasPermission(context, WRITE_CONTACTS)) {
return;
}
if (intent != null && Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction())) {
@@ -65,14 +69,29 @@ public class UndemoteOutgoingCallReceiver extends BroadcastReceiver {
// If the contact is not demoted, this will not do anything. Otherwise, it will
// restore it to an unpinned position. If it was a frequently called contact, it will
// show up once again show up on the favorites screen.
- PinnedPositions.undemote(context.getContentResolver(), id);
+ if (PermissionsUtil.hasPermission(context, WRITE_CONTACTS)) {
+ try {
+ PinnedPositions.undemote(context.getContentResolver(), id);
+ } catch (SecurityException e) {
+ // Just in case
+ }
+ }
}
private long getContactIdFromPhoneNumber(Context context, String number) {
+ if (!PermissionsUtil.hasPermission(context, READ_CONTACTS)) {
+ return NO_CONTACT_FOUND;
+ }
final Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(number));
- final Cursor cursor = context.getContentResolver().query(contactUri, new String[] {
- PhoneLookup._ID}, null, null, null);
+ final Cursor cursor;
+ try {
+ cursor = context.getContentResolver().query(contactUri, new String[] {
+ PhoneLookup._ID}, null, null, null);
+ } catch (SecurityException e) {
+ // Just in case
+ return NO_CONTACT_FOUND;
+ }
if (cursor == null) {
return NO_CONTACT_FOUND;
}