summaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/com')
-rw-r--r--java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java3
-rw-r--r--java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java10
-rw-r--r--java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java4
-rw-r--r--java/com/android/dialer/calllog/datasources/util/RowCombiner.java7
-rw-r--r--java/com/android/dialer/calllog/model/CoalescedRow.java5
-rw-r--r--java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java4
-rw-r--r--java/com/android/dialer/phonelookup/PhoneLookupSelector.java23
7 files changed, 53 insertions, 3 deletions
diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
index 8c6d58634..68d4b95df 100644
--- a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
+++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
@@ -59,7 +59,8 @@ class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
+ (AnnotatedCallLog.IS_VOICEMAIL + " integer, ")
+ (AnnotatedCallLog.TRANSCRIPTION + " integer, ")
+ (AnnotatedCallLog.VOICEMAIL_URI + " text, ")
- + (AnnotatedCallLog.CALL_TYPE + " integer")
+ + (AnnotatedCallLog.CALL_TYPE + " integer, ")
+ + (AnnotatedCallLog.CAN_REPORT_AS_INVALID_NUMBER + " integer")
+ ");";
/** Deletes all but the first maxRows rows (by timestamp) to keep the table a manageable size. */
diff --git a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
index 7071ab5c1..1b3e09095 100644
--- a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
+++ b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
@@ -178,6 +178,13 @@ public class AnnotatedCallLogContract {
*/
String CALL_TYPE = "call_type";
+ /**
+ * True if the number can be reported as invalid.
+ *
+ * <p>TYPE: INTEGER (boolean)
+ */
+ String CAN_REPORT_AS_INVALID_NUMBER = "can_report_as_invalid_number";
+
String[] ALL_COMMON_COLUMNS =
new String[] {
_ID,
@@ -199,7 +206,8 @@ public class AnnotatedCallLogContract {
FEATURES,
IS_BUSINESS,
IS_VOICEMAIL,
- CALL_TYPE
+ CALL_TYPE,
+ CAN_REPORT_AS_INVALID_NUMBER
};
}
diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
index 56e909e84..214862793 100644
--- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
@@ -268,6 +268,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource {
.useMostRecentString(AnnotatedCallLog.PHOTO_URI)
.useMostRecentLong(AnnotatedCallLog.PHOTO_ID)
.useMostRecentString(AnnotatedCallLog.LOOKUP_URI)
+ .useMostRecentInt(AnnotatedCallLog.CAN_REPORT_AS_INVALID_NUMBER)
.combine();
}
@@ -564,6 +565,9 @@ public final class PhoneLookupDataSource implements CallLogDataSource {
AnnotatedCallLog.LOOKUP_URI, PhoneLookupSelector.selectLookupUri(phoneLookupInfo));
contentValues.put(
AnnotatedCallLog.NUMBER_TYPE_LABEL, PhoneLookupSelector.selectNumberLabel(phoneLookupInfo));
+ contentValues.put(
+ AnnotatedCallLog.CAN_REPORT_AS_INVALID_NUMBER,
+ PhoneLookupSelector.canReportAsInvalidNumber(phoneLookupInfo));
}
private static Uri numberUri(String number) {
diff --git a/java/com/android/dialer/calllog/datasources/util/RowCombiner.java b/java/com/android/dialer/calllog/datasources/util/RowCombiner.java
index ebb1ba665..6e33db51e 100644
--- a/java/com/android/dialer/calllog/datasources/util/RowCombiner.java
+++ b/java/com/android/dialer/calllog/datasources/util/RowCombiner.java
@@ -32,6 +32,13 @@ public class RowCombiner {
}
/** Use the most recent value for the specified column. */
+ public RowCombiner useMostRecentInt(String columnName) {
+ combinedRow.put(
+ columnName, individualRowsSortedByTimestampDesc.get(0).getAsInteger(columnName));
+ return this;
+ }
+
+ /** Use the most recent value for the specified column. */
public RowCombiner useMostRecentLong(String columnName) {
combinedRow.put(columnName, individualRowsSortedByTimestampDesc.get(0).getAsLong(columnName));
return this;
diff --git a/java/com/android/dialer/calllog/model/CoalescedRow.java b/java/com/android/dialer/calllog/model/CoalescedRow.java
index 5cc056872..1824ba146 100644
--- a/java/com/android/dialer/calllog/model/CoalescedRow.java
+++ b/java/com/android/dialer/calllog/model/CoalescedRow.java
@@ -39,6 +39,7 @@ public abstract class CoalescedRow {
.setIsBusiness(false)
.setIsVoicemail(false)
.setCallType(0)
+ .setCanReportAsInvalidNumber(false)
.setCoalescedIds(CoalescedIds.getDefaultInstance());
}
@@ -92,6 +93,8 @@ public abstract class CoalescedRow {
public abstract int callType();
+ public abstract boolean canReportAsInvalidNumber();
+
public abstract CoalescedIds coalescedIds();
/** Builder for {@link CoalescedRow}. */
@@ -139,6 +142,8 @@ public abstract class CoalescedRow {
public abstract Builder setCallType(int callType);
+ public abstract Builder setCanReportAsInvalidNumber(boolean canReportAsInvalidNumber);
+
public abstract Builder setCoalescedIds(CoalescedIds coalescedIds);
public abstract CoalescedRow build();
diff --git a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java
index 8aefb1a74..6d60bdda4 100644
--- a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java
+++ b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java
@@ -49,7 +49,8 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader {
private static final int IS_BUSINESS = 17;
private static final int IS_VOICEMAIL = 18;
private static final int CALL_TYPE = 19;
- private static final int COALESCED_IDS = 20;
+ private static final int CAN_REPORT_AS_INVALID_NUMBER = 20;
+ private static final int COALESCED_IDS = 21;
CoalescedAnnotatedCallLogCursorLoader(Context context) {
// CoalescedAnnotatedCallLog requires that PROJECTION be ALL_COLUMNS and the following params be
@@ -100,6 +101,7 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader {
.setIsBusiness(cursor.getInt(IS_BUSINESS) == 1)
.setIsVoicemail(cursor.getInt(IS_VOICEMAIL) == 1)
.setCallType(cursor.getInt(CALL_TYPE))
+ .setCanReportAsInvalidNumber(cursor.getInt(CAN_REPORT_AS_INVALID_NUMBER) == 1)
.setCoalescedIds(coalescedIds)
.build();
}
diff --git a/java/com/android/dialer/phonelookup/PhoneLookupSelector.java b/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
index 0fe989332..c933af728 100644
--- a/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
+++ b/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
@@ -18,6 +18,8 @@ package com.android.dialer.phonelookup;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.android.dialer.phonelookup.PhoneLookupInfo.Cp2Info.Cp2ContactInfo;
+import com.android.dialer.phonelookup.PhoneLookupInfo.PeopleApiInfo;
+import com.android.dialer.phonelookup.PhoneLookupInfo.PeopleApiInfo.InfoType;
/**
* Prioritizes information from a {@link PhoneLookupInfo}.
@@ -107,6 +109,27 @@ public final class PhoneLookupSelector {
}
/**
+ * Returns true if the number associated with the given {@link PhoneLookupInfo} can be reported as
+ * invalid.
+ *
+ * <p>As we currently report invalid numbers via the People API, only numbers from the People API
+ * can be reported as invalid.
+ */
+ public static boolean canReportAsInvalidNumber(PhoneLookupInfo phoneLookupInfo) {
+ // The presence of Cp2ContactInfo means the number associated with the given PhoneLookupInfo
+ // matches that of a Cp2 (local) contact, and PeopleApiInfo will not be used to display
+ // information like name, photo, etc. We should not allow the user to report the number in this
+ // case as the info displayed is not from the People API.
+ if (phoneLookupInfo.getCp2Info().getCp2ContactInfoCount() > 0) {
+ return false;
+ }
+
+ PeopleApiInfo peopleApiInfo = phoneLookupInfo.getPeopleApiInfo();
+ return peopleApiInfo.getInfoType() != InfoType.UNKNOWN
+ && !peopleApiInfo.getPersonId().isEmpty();
+ }
+
+ /**
* Arbitrarily select the first contact. In the future, it may make sense to display contact
* information from all contacts with the same number (for example show the name as "Mom, Dad" or
* show a synthesized photo containing photos of both "Mom" and "Dad").