From 5ee0b1e574ed93c7000e355e4a6b03fb9ed8aaba Mon Sep 17 00:00:00 2001 From: zachh Date: Tue, 3 Oct 2017 17:27:01 -0700 Subject: Only show the most recent call type icon in the new call log, instead of the last 3. This is according to the latest PRD: https://docs.google.com/document/d/1FLoQ6kNYL-QKplbniJAIUCHku87S9eYuYPs6IXe-U78 Also cleaned up warnings in CallLogQueryHandler. Screenshot: https://screenshot.googleplex.com/Z7p4BRVpLpE Bug: 34672501 Test: unit PiperOrigin-RevId: 170941445 Change-Id: Ibf79b70eda3837ea46d365729aaed0a87961e42b --- .../dialer/database/CallLogQueryHandler.java | 61 +++++----------------- 1 file changed, 14 insertions(+), 47 deletions(-) (limited to 'java/com/android/dialer/database/CallLogQueryHandler.java') diff --git a/java/com/android/dialer/database/CallLogQueryHandler.java b/java/com/android/dialer/database/CallLogQueryHandler.java index 4867d9dce..35250d668 100644 --- a/java/com/android/dialer/database/CallLogQueryHandler.java +++ b/java/com/android/dialer/database/CallLogQueryHandler.java @@ -54,12 +54,9 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { */ public static final int CALL_TYPE_ALL = -1; - private static final String TAG = "CallLogQueryHandler"; private static final int NUM_LOGS_TO_DISPLAY = 1000; /** The token for the query to fetch the old entries from the call log. */ private static final int QUERY_CALLLOG_TOKEN = 54; - /** The token for the query to mark all missed calls as old after seeing the call log. */ - private static final int UPDATE_MARK_AS_OLD_TOKEN = 55; /** The token for the query to mark all missed calls as read after seeing the call log. */ private static final int UPDATE_MARK_MISSED_CALL_AS_READ_TOKEN = 56; /** The token for the query to fetch voicemail status messages. */ @@ -82,7 +79,7 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { Context context, ContentResolver contentResolver, Listener listener, int limit) { super(contentResolver); mContext = context.getApplicationContext(); - mListener = new WeakReference(listener); + mListener = new WeakReference<>(listener); mLogLimit = limit; } @@ -107,10 +104,6 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } } - public void fetchCalls(int callType) { - fetchCalls(callType, 0); - } - public void fetchVoicemailStatus() { StringBuilder where = new StringBuilder(); List selectionArgs = new ArrayList<>(); @@ -226,28 +219,6 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { cancelOperation(QUERY_CALLLOG_TOKEN); } - /** Updates all new calls to mark them as old. */ - public void markNewCallsAsOld() { - if (!PermissionsUtil.hasPhonePermissions(mContext)) { - return; - } - // Mark all "new" calls as not new anymore. - StringBuilder where = new StringBuilder(); - where.append(Calls.NEW); - where.append(" = 1"); - - ContentValues values = new ContentValues(1); - values.put(Calls.NEW, "0"); - - startUpdate( - UPDATE_MARK_AS_OLD_TOKEN, - null, - TelecomUtil.getCallLogUri(mContext), - values, - where.toString(), - null); - } - /** Updates all missed calls to mark them as read. */ public void markMissedCallsAsRead() { if (!PermissionsUtil.hasPhonePermissions(mContext)) { @@ -316,19 +287,19 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { */ private boolean updateAdapterData(Cursor cursor) { final Listener listener = mListener.get(); - if (listener != null) { - return listener.onCallsFetched(cursor); - } - return false; + return listener != null && listener.onCallsFetched(cursor); } /** @return Query string to get all unread missed calls. */ private String getUnreadMissedCallsQuery() { - StringBuilder where = new StringBuilder(); - where.append(Calls.IS_READ).append(" = 0 OR ").append(Calls.IS_READ).append(" IS NULL"); - where.append(" AND "); - where.append(Calls.TYPE).append(" = ").append(Calls.MISSED_TYPE); - return where.toString(); + return Calls.IS_READ + + " = 0 OR " + + Calls.IS_READ + + " IS NULL" + + " AND " + + Calls.TYPE + + " = " + + Calls.MISSED_TYPE; } private void updateVoicemailStatus(Cursor statusCursor) { @@ -365,7 +336,7 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { void onMissedCallsUnreadCountFetched(Cursor cursor); /** - * Called when {@link CallLogQueryHandler#fetchCalls(int)} complete. Returns true if takes + * Called when {@link CallLogQueryHandler#fetchCalls(int, long)} complete. Returns true if takes * ownership of cursor. */ boolean onCallsFetched(Cursor combinedCursor); @@ -375,9 +346,9 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { * Simple handler that wraps background calls to catch {@link SQLiteException}, such as when the * disk is full. */ - protected class CatchingWorkerHandler extends AsyncQueryHandler.WorkerHandler { + private class CatchingWorkerHandler extends AsyncQueryHandler.WorkerHandler { - public CatchingWorkerHandler(Looper looper) { + CatchingWorkerHandler(Looper looper) { super(looper); } @@ -386,11 +357,7 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { try { // Perform same query while catching any exceptions super.handleMessage(msg); - } catch (SQLiteDiskIOException e) { - LogUtil.e("CallLogQueryHandler.handleMessage", "exception on background worker thread", e); - } catch (SQLiteFullException e) { - LogUtil.e("CallLogQueryHandler.handleMessage", "exception on background worker thread", e); - } catch (SQLiteDatabaseCorruptException e) { + } catch (SQLiteDiskIOException | SQLiteFullException | SQLiteDatabaseCorruptException e) { LogUtil.e("CallLogQueryHandler.handleMessage", "exception on background worker thread", e); } catch (IllegalArgumentException e) { LogUtil.e("CallLogQueryHandler.handleMessage", "contactsProvider not present on device", e); -- cgit v1.2.3