diff options
author | Sarmad Hashmi <mhashmi@google.com> | 2016-04-09 22:18:12 -0700 |
---|---|---|
committer | Sarmad Hashmi <mhashmi@google.com> | 2016-04-12 16:30:47 -0700 |
commit | 0839b1eccc8e373e01d96cc97f079b1ce44b5d33 (patch) | |
tree | e4b11f8917dd64e8ee26851fb6dc186c0be94628 /src | |
parent | 215e1f189805fbc3dd30e084b715d5e219852902 (diff) |
Add after call notification code in InCallUI.
+Add asynchronous call to update inCallHistory boolean variable which
specifies whether the number is in the call history (has previously
called before)
+Add CallHistoryStatus enum and variable to Call object to determine if
the number is present in the call history
+Added SpamCallListListener object which listens for changes in the
CallList
+Update the CallHistoryStatus for the call whenever an incoming call
comes in
+Added 11 tests for new listener
BUG=27323295
Change-Id: I242cd4a53b3aeca69fbce972221a2c941d9d37ce
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java index 34b2f0ea9..b95d58e26 100644 --- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java +++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java @@ -17,6 +17,7 @@ package com.android.dialer.calllog; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; import android.content.ContentResolver; import android.content.ContentValues; @@ -58,7 +59,8 @@ public class CallLogAsyncTaskUtil { MARK_VOICEMAIL_READ, MARK_CALL_READ, GET_CALL_DETAILS, - UPDATE_DURATION + UPDATE_DURATION, + GET_NUMBER_IN_CALL_HISTORY } private static final class CallDetailQuery { @@ -122,6 +124,10 @@ public class CallLogAsyncTaskUtil { void onGetCallDetails(PhoneCallDetails[] details); } + public interface OnGetNumberInCallHistoryListener { + void onComplete(boolean inCallHistory); + } + public interface OnCallLogQueryFinishedListener { void onQueryFinished(boolean hasEntry); } @@ -456,6 +462,42 @@ public class CallLogAsyncTaskUtil { }); } + /** + * Checks if the number is in the call history. + */ + public static void getNumberInCallHistory( + final Context context, + final String number, + final OnGetNumberInCallHistoryListener listener) { + Preconditions.checkNotNull(listener); + if (!PermissionsUtil.hasPhonePermissions(context)) { + return; + } + if (sAsyncTaskExecutor == null) { + initTaskExecutor(); + } + + sAsyncTaskExecutor.submit(Tasks.GET_NUMBER_IN_CALL_HISTORY, + new AsyncTask<Void, Void, Boolean>() { + @Override + public Boolean doInBackground(Void... params) { + try (Cursor cursor = context.getContentResolver().query( + TelecomUtil.getCallLogUri(context), + new String[] {CallLog.Calls._ID}, + CallLog.Calls.NUMBER + " = ?", + new String[] {number}, + null)) { + return cursor != null && cursor.getCount() > 0; + } + } + + @Override + public void onPostExecute(Boolean inCallHistory) { + listener.onComplete(inCallHistory); + } + }); + } + @VisibleForTesting public static void resetForTest() { sAsyncTaskExecutor = null; |