Loading src/com/android/dialer/calllog/CallLogNotificationsService.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public class CallLogNotificationsService extends IntentService { return; } if (!PermissionsUtil.hasPhonePermissions(this)) { if (!PermissionsUtil.hasPermission(this, android.Manifest.permission.READ_CALL_LOG)) { return; } Loading src/com/android/dialer/calllog/DefaultVoicemailNotifier.java +26 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.dialer.calllog; import static android.Manifest.permission.READ_CALL_LOG; import static android.Manifest.permission.READ_CONTACTS; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; Loading @@ -32,6 +35,7 @@ import android.text.TextUtils; import android.util.Log; import com.android.common.io.MoreCloseables; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.calllog.PhoneAccountUtils; Loading Loading @@ -66,8 +70,8 @@ public class DefaultVoicemailNotifier { (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); ContentResolver contentResolver = context.getContentResolver(); sInstance = new DefaultVoicemailNotifier(context, notificationManager, createNewCallsQuery(contentResolver), createNameLookupQuery(contentResolver)); createNewCallsQuery(context, contentResolver), createNameLookupQuery(context, contentResolver)); } return sInstance; } Loading Loading @@ -243,8 +247,9 @@ public class DefaultVoicemailNotifier { } /** Create a new instance of {@link NewCallsQuery}. */ public static NewCallsQuery createNewCallsQuery(ContentResolver contentResolver) { return new DefaultNewCallsQuery(contentResolver); public static NewCallsQuery createNewCallsQuery(Context context, ContentResolver contentResolver) { return new DefaultNewCallsQuery(context.getApplicationContext(), contentResolver); } /** Loading @@ -270,13 +275,19 @@ public class DefaultVoicemailNotifier { private static final int TRANSCRIPTION_COLUMN_INDEX = 6; private final ContentResolver mContentResolver; private final Context mContext; private DefaultNewCallsQuery(ContentResolver contentResolver) { private DefaultNewCallsQuery(Context context, ContentResolver contentResolver) { mContext = context; mContentResolver = contentResolver; } @Override public NewCall[] query() { if (!PermissionsUtil.hasPermission(mContext, READ_CALL_LOG)) { Log.w(TAG, "No READ_CALL_LOG permission, returning null for calls lookup."); return null; } final String selection = String.format("%s = 1 AND %s = ?", Calls.NEW, Calls.TYPE); final String[] selectionArgs = new String[]{ Integer.toString(Calls.VOICEMAIL_TYPE) }; Cursor cursor = null; Loading Loading @@ -326,8 +337,9 @@ public class DefaultVoicemailNotifier { } /** Create a new instance of {@link NameLookupQuery}. */ public static NameLookupQuery createNameLookupQuery(ContentResolver contentResolver) { return new DefaultNameLookupQuery(contentResolver); public static NameLookupQuery createNameLookupQuery(Context context, ContentResolver contentResolver) { return new DefaultNameLookupQuery(context.getApplicationContext(), contentResolver); } /** Loading @@ -339,13 +351,19 @@ public class DefaultVoicemailNotifier { private static final int DISPLAY_NAME_COLUMN_INDEX = 0; private final ContentResolver mContentResolver; private final Context mContext; private DefaultNameLookupQuery(ContentResolver contentResolver) { private DefaultNameLookupQuery(Context context, ContentResolver contentResolver) { mContext = context; mContentResolver = contentResolver; } @Override public String query(String number) { if (!PermissionsUtil.hasPermission(mContext, READ_CONTACTS)) { Log.w(TAG, "No READ_CONTACTS permission, returning null for name lookup."); return null; } Cursor cursor = null; try { cursor = mContentResolver.query( Loading Loading
src/com/android/dialer/calllog/CallLogNotificationsService.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public class CallLogNotificationsService extends IntentService { return; } if (!PermissionsUtil.hasPhonePermissions(this)) { if (!PermissionsUtil.hasPermission(this, android.Manifest.permission.READ_CALL_LOG)) { return; } Loading
src/com/android/dialer/calllog/DefaultVoicemailNotifier.java +26 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.dialer.calllog; import static android.Manifest.permission.READ_CALL_LOG; import static android.Manifest.permission.READ_CONTACTS; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; Loading @@ -32,6 +35,7 @@ import android.text.TextUtils; import android.util.Log; import com.android.common.io.MoreCloseables; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.calllog.PhoneAccountUtils; Loading Loading @@ -66,8 +70,8 @@ public class DefaultVoicemailNotifier { (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); ContentResolver contentResolver = context.getContentResolver(); sInstance = new DefaultVoicemailNotifier(context, notificationManager, createNewCallsQuery(contentResolver), createNameLookupQuery(contentResolver)); createNewCallsQuery(context, contentResolver), createNameLookupQuery(context, contentResolver)); } return sInstance; } Loading Loading @@ -243,8 +247,9 @@ public class DefaultVoicemailNotifier { } /** Create a new instance of {@link NewCallsQuery}. */ public static NewCallsQuery createNewCallsQuery(ContentResolver contentResolver) { return new DefaultNewCallsQuery(contentResolver); public static NewCallsQuery createNewCallsQuery(Context context, ContentResolver contentResolver) { return new DefaultNewCallsQuery(context.getApplicationContext(), contentResolver); } /** Loading @@ -270,13 +275,19 @@ public class DefaultVoicemailNotifier { private static final int TRANSCRIPTION_COLUMN_INDEX = 6; private final ContentResolver mContentResolver; private final Context mContext; private DefaultNewCallsQuery(ContentResolver contentResolver) { private DefaultNewCallsQuery(Context context, ContentResolver contentResolver) { mContext = context; mContentResolver = contentResolver; } @Override public NewCall[] query() { if (!PermissionsUtil.hasPermission(mContext, READ_CALL_LOG)) { Log.w(TAG, "No READ_CALL_LOG permission, returning null for calls lookup."); return null; } final String selection = String.format("%s = 1 AND %s = ?", Calls.NEW, Calls.TYPE); final String[] selectionArgs = new String[]{ Integer.toString(Calls.VOICEMAIL_TYPE) }; Cursor cursor = null; Loading Loading @@ -326,8 +337,9 @@ public class DefaultVoicemailNotifier { } /** Create a new instance of {@link NameLookupQuery}. */ public static NameLookupQuery createNameLookupQuery(ContentResolver contentResolver) { return new DefaultNameLookupQuery(contentResolver); public static NameLookupQuery createNameLookupQuery(Context context, ContentResolver contentResolver) { return new DefaultNameLookupQuery(context.getApplicationContext(), contentResolver); } /** Loading @@ -339,13 +351,19 @@ public class DefaultVoicemailNotifier { private static final int DISPLAY_NAME_COLUMN_INDEX = 0; private final ContentResolver mContentResolver; private final Context mContext; private DefaultNameLookupQuery(ContentResolver contentResolver) { private DefaultNameLookupQuery(Context context, ContentResolver contentResolver) { mContext = context; mContentResolver = contentResolver; } @Override public String query(String number) { if (!PermissionsUtil.hasPermission(mContext, READ_CONTACTS)) { Log.w(TAG, "No READ_CONTACTS permission, returning null for name lookup."); return null; } Cursor cursor = null; try { cursor = mContentResolver.query( Loading