diff options
Diffstat (limited to 'java/com/android/dialer')
8 files changed, 55 insertions, 127 deletions
diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java index e1ec0f6b1..40d922f41 100644 --- a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java +++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java @@ -54,7 +54,7 @@ class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper { .append(AnnotatedCallLog.IS_VOICEMAIL + " integer, ") // Columns only in AnnotatedCallLog .append(AnnotatedCallLog.NUMBER + " blob, ") - .append(AnnotatedCallLog.TYPE + " integer") + .append(AnnotatedCallLog.CALL_TYPE + " integer") .append(");") .toString(); diff --git a/java/com/android/dialer/calllog/database/annotated_call_log.proto b/java/com/android/dialer/calllog/database/annotated_call_log.proto deleted file mode 100644 index de2bc5f14..000000000 --- a/java/com/android/dialer/calllog/database/annotated_call_log.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto2"; - -option java_package = "com.android.dialer"; -option java_multiple_files = true; -option optimize_for = LITE_RUNTIME; - -// DIALER_SCRUB.UNCOMMENT_IN_OPEN_SOURCE option optimize_for = LITE_RUNTIME; - -package com.android.dialer; - -// A list of android.provider.CallLog.Calls.TYPE values ordered from newest to -// oldest. -message CallTypes { - repeated int32 type = 1; -} diff --git a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java index 25950f6b9..d466da9ae 100644 --- a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java +++ b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java @@ -148,6 +148,13 @@ public class AnnotatedCallLogContract { */ String IS_VOICEMAIL = "is_voicemail"; + /** + * Copied from {@link android.provider.CallLog.Calls#TYPE}. + * + * <p>Type: INTEGER (int) + */ + String CALL_TYPE = "call_type"; + String[] ALL_COMMON_COLUMNS = new String[] { _ID, @@ -165,7 +172,8 @@ public class AnnotatedCallLogContract { PHONE_ACCOUNT_COLOR, FEATURES, IS_BUSINESS, - IS_VOICEMAIL + IS_VOICEMAIL, + CALL_TYPE }; } @@ -196,13 +204,6 @@ public class AnnotatedCallLogContract { * <p>Type: BLOB */ public static final String NUMBER = "number"; - - /** - * Copied from {@link android.provider.CallLog.Calls#TYPE}. - * - * <p>Type: INTEGER (int) - */ - public static final String TYPE = "type"; } /** @@ -233,18 +234,10 @@ public class AnnotatedCallLogContract { public static final String NUMBER_CALLS = "number_calls"; /** - * The call types of the most recent 3 calls, encoded as a CallTypes proto. - * - * <p>TYPE: BLOB - */ - public static final String CALL_TYPES = "call_types"; - - /** * Columns that are only in the {@link CoalescedAnnotatedCallLog} but not the {@link * AnnotatedCallLog}. */ - private static final String[] COLUMNS_ONLY_IN_COALESCED_CALL_LOG = - new String[] {NUMBER_CALLS, CALL_TYPES}; + private static final String[] COLUMNS_ONLY_IN_COALESCED_CALL_LOG = new String[] {NUMBER_CALLS}; /** All columns in the {@link CoalescedAnnotatedCallLog}. */ public static final String[] ALL_COLUMNS = diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java index 1bdbb8a1b..d6ad618b3 100644 --- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java @@ -38,9 +38,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; import android.util.ArraySet; -import com.android.dialer.CallTypes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog; -import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.CallLogMutations; import com.android.dialer.calllog.datasources.util.RowCombiner; @@ -153,30 +151,20 @@ public class SystemCallLogDataSource implements CallLogDataSource { @Override public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) { // TODO(zachh): Complete implementation. - ContentValues coalescedValues = - new RowCombiner(individualRowsSortedByTimestampDesc) - .useMostRecentLong(AnnotatedCallLog.TIMESTAMP) - .useMostRecentLong(AnnotatedCallLog.NEW) - .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) - .useMostRecentString(AnnotatedCallLog.NAME) - .useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER) - .useMostRecentString(AnnotatedCallLog.PHOTO_URI) - .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) - .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) - .useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION) - .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL) - .useSingleValueLong(AnnotatedCallLog.PHONE_ACCOUNT_COLOR) - .combine(); - - CallTypes.Builder callTypes = CallTypes.newBuilder(); - // Store a maximum of 3 call types since that's all we show to users via icons. - for (int i = 0; i < 3 && i < individualRowsSortedByTimestampDesc.size(); i++) { - callTypes.addType( - individualRowsSortedByTimestampDesc.get(i).getAsInteger(AnnotatedCallLog.TYPE)); - } - coalescedValues.put(CoalescedAnnotatedCallLog.CALL_TYPES, callTypes.build().toByteArray()); - - return coalescedValues; + return new RowCombiner(individualRowsSortedByTimestampDesc) + .useMostRecentLong(AnnotatedCallLog.TIMESTAMP) + .useMostRecentLong(AnnotatedCallLog.NEW) + .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) + .useMostRecentString(AnnotatedCallLog.NAME) + .useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER) + .useMostRecentString(AnnotatedCallLog.PHOTO_URI) + .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) + .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) + .useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION) + .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL) + .useSingleValueLong(AnnotatedCallLog.PHONE_ACCOUNT_COLOR) + .useMostRecentLong(AnnotatedCallLog.CALL_TYPE) + .combine(); } @TargetApi(Build.VERSION_CODES.M) // Uses try-with-resources @@ -286,7 +274,7 @@ public class SystemCallLogDataSource implements CallLogDataSource { contentValues.put(AnnotatedCallLog.NUMBER, numberAsProtoBytes); } - contentValues.put(AnnotatedCallLog.TYPE, type); + contentValues.put(AnnotatedCallLog.CALL_TYPE, type); contentValues.put(AnnotatedCallLog.NAME, cachedName); contentValues.put(AnnotatedCallLog.FORMATTED_NUMBER, formattedNumber); contentValues.put(AnnotatedCallLog.PHOTO_URI, cachedPhotoUri); diff --git a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java index d89338350..13a801ac8 100644 --- a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java +++ b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java @@ -19,12 +19,8 @@ package com.android.dialer.calllog.ui; import android.content.Context; import android.database.Cursor; import android.support.annotation.ColorInt; -import android.support.annotation.NonNull; import android.support.v4.content.CursorLoader; -import com.android.dialer.CallTypes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; -import com.android.dialer.common.Assert; -import com.google.protobuf.InvalidProtocolBufferException; /** CursorLoader for the coalesced annotated call log. */ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { @@ -47,8 +43,8 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { private static final int FEATURES = 13; private static final int IS_BUSINESS = 14; private static final int IS_VOICEMAIL = 15; - private static final int NUMBER_CALLS = 16; - private static final int CALL_TYPES = 17; + private static final int TYPE = 16; + private static final int NUMBER_CALLS = 17; /** Convenience class for accessing values using an abbreviated syntax. */ static final class Row { @@ -127,13 +123,8 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { return cursor.getInt(NUMBER_CALLS); } - @NonNull - CallTypes callTypes() { - try { - return CallTypes.parseFrom(cursor.getBlob(CALL_TYPES)); - } catch (InvalidProtocolBufferException e) { - throw Assert.createAssertionFailException("Couldn't parse call types", e); - } + int callType() { + return cursor.getInt(TYPE); } } diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index e198a38e8..8ac419e56 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -66,8 +66,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { primaryTextView.setText(buildPrimaryText(row)); secondaryTextView.setText(buildSecondaryText(row)); - if (row.isNew()) { - // TODO(zachh): Figure out correct styling for new/missed/unread calls. + if (isNewMissedCall(row)) { primaryTextView.setTextAppearance(R.style.primary_textview_new_call); // TODO(zachh): Styling for call type icons when the call is new. secondaryTextView.setTextAppearance(R.style.secondary_textview_new_call); @@ -95,6 +94,12 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { return primaryText.toString(); } + private boolean isNewMissedCall(CoalescedAnnotatedCallLogCursorLoader.Row row) { + // Show missed call styling if the most recent call in the group was missed and it is still + // marked as NEW. It is not clear what IS_READ should be used for and it is currently not used. + return row.callType() == Calls.MISSED_TYPE && row.isNew(); + } + private String buildSecondaryText(CoalescedAnnotatedCallLogCursorLoader.Row row) { /* * Rules: (Duo video, )?$Label|$Location • Date @@ -158,10 +163,9 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setSecondaryCallTypes(Row row) { - // Only call type icons are shown before the secondary text. - for (int callType : row.callTypes().getTypeList()) { - secondaryCallTypeIconsView.add(callType); - } + // Only call type icon is shown before the secondary text. + secondaryCallTypeIconsView.add(row.callType()); + // TODO(zachh): Per new mocks, may need to add method to CallTypeIconsView to disable coloring. } 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>(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<String> 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); diff --git a/java/com/android/dialer/notification/NotificationChannelManager.java b/java/com/android/dialer/notification/NotificationChannelManager.java index 790aac36f..93caed503 100644 --- a/java/com/android/dialer/notification/NotificationChannelManager.java +++ b/java/com/android/dialer/notification/NotificationChannelManager.java @@ -133,7 +133,7 @@ public final class NotificationChannelManager { new NotificationChannel( NotificationChannelId.ONGOING_CALL, context.getText(R.string.notification_channel_ongoing_call), - NotificationManager.IMPORTANCE_DEFAULT); + NotificationManager.IMPORTANCE_MAX); channel.setShowBadge(false); channel.enableLights(false); channel.enableVibration(false); |