summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java')
-rw-r--r--java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
index 649a6639d..2f8b1f476 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
@@ -136,6 +136,10 @@ public class CallLogNotificationsQueryHelper {
return new DefaultNewCallsQuery(context.getApplicationContext(), contentResolver);
}
+ NewCallsQuery getNewCallsQuery() {
+ return mNewCallsQuery;
+ }
+
/**
* Get all voicemails with the "new" flag set to 1.
*
@@ -219,6 +223,10 @@ public class CallLogNotificationsQueryHelper {
/** Returns the new calls of a certain type for which a notification should be generated. */
@Nullable
List<NewCall> query(int type);
+
+ /** Returns a {@link NewCall} pointed by the {@code callsUri} */
+ @Nullable
+ NewCall query(Uri callsUri);
}
/** Information about a new voicemail. */
@@ -346,6 +354,26 @@ public class CallLogNotificationsQueryHelper {
}
}
+ @Nullable
+ @Override
+ public NewCall query(Uri callsUri) {
+ if (!PermissionsUtil.hasPermission(mContext, Manifest.permission.READ_CALL_LOG)) {
+ LogUtil.w(
+ "CallLogNotificationsQueryHelper.DefaultNewCallsQuery.query",
+ "No READ_CALL_LOG permission, returning null for calls lookup.");
+ return null;
+ }
+ try (Cursor cursor = mContentResolver.query(callsUri, PROJECTION, null, null, null)) {
+ if (cursor == null) {
+ return null;
+ }
+ if (!cursor.moveToFirst()) {
+ return null;
+ }
+ return createNewCallsFromCursor(cursor);
+ }
+ }
+
/** Returns an instance of {@link NewCall} created by using the values of the cursor. */
private NewCall createNewCallsFromCursor(Cursor cursor) {
String voicemailUriString = cursor.getString(VOICEMAIL_URI_COLUMN_INDEX);