summaryrefslogtreecommitdiff
path: root/java/com/android
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-05-07 11:33:03 -0700
committerCopybara-Service <copybara-piper@google.com>2018-05-09 16:51:51 -0700
commit9d1ef8f39daeb4cfc511b6ba47298bc27019b7d0 (patch)
tree945a54cc7738d63c759676920264eede074f51e2 /java/com/android
parent41da94c501a420cb747d7afe3d3b7e30639ba281 (diff)
Use info from EmergencyPhoneLookup to render UI for an emergency number.
Bug: 71719349 Test: CallLogEntryTextTest, HistoryItemActionModulesBuilderTest PiperOrigin-RevId: 195694340 Change-Id: Ib53305c36f7ca062ef798ab3f61585d3c71adef3
Diffstat (limited to 'java/com/android')
-rw-r--r--java/com/android/dialer/calllog/ui/menu/Modules.java1
-rw-r--r--java/com/android/dialer/calllogutils/CallLogEntryText.java7
-rw-r--r--java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java13
-rw-r--r--java/com/android/dialer/historyitemactions/history_item_action_module_info.proto5
-rw-r--r--java/com/android/dialer/voicemail/listui/menu/Modules.java1
5 files changed, 13 insertions, 14 deletions
diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java
index b06e0fb1a..cfeca1059 100644
--- a/java/com/android/dialer/calllog/ui/menu/Modules.java
+++ b/java/com/android/dialer/calllog/ui/menu/Modules.java
@@ -126,6 +126,7 @@ final class Modules {
.setCanSupportAssistedDialing(canSupportAssistedDialing(row))
.setCanSupportCarrierVideoCall(row.getNumberAttributes().getCanSupportCarrierVideoCall())
.setIsBlocked(row.getNumberAttributes().getIsBlocked())
+ .setIsEmergencyNumber(row.getNumberAttributes().getIsEmergencyNumber())
.setIsSpam(row.getNumberAttributes().getIsSpam())
.setIsVoicemailCall(row.getIsVoicemailCall())
.setContactSource(row.getNumberAttributes().getContactSource())
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java
index cd8fb44d9..54b1e195a 100644
--- a/java/com/android/dialer/calllogutils/CallLogEntryText.java
+++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java
@@ -21,7 +21,6 @@ import android.provider.CallLog.Calls;
import android.text.TextUtils;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.duo.DuoComponent;
-import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.time.Clock;
import com.google.common.base.Optional;
import com.google.common.collect.Collections2;
@@ -44,7 +43,7 @@ public final class CallLogEntryText {
*/
public static CharSequence buildPrimaryText(Context context, CoalescedRow row) {
// Calls to emergency services should be shown as "Emergency number".
- if (PhoneNumberHelper.isLocalEmergencyNumber(context, row.getNumber().getNormalizedNumber())) {
+ if (row.getNumberAttributes().getIsEmergencyNumber()) {
return context.getText(R.string.emergency_number);
}
@@ -110,7 +109,7 @@ public final class CallLogEntryText {
public static CharSequence buildSecondaryTextForEntries(
Context context, Clock clock, CoalescedRow row) {
// For emergency numbers, the secondary text should contain only the timestamp.
- if (PhoneNumberHelper.isLocalEmergencyNumber(context, row.getNumber().getNormalizedNumber())) {
+ if (row.getNumberAttributes().getIsEmergencyNumber()) {
return CallLogDates.newCallLogTimestampLabel(
context, clock.currentTimeMillis(), row.getTimestamp());
}
@@ -168,7 +167,7 @@ public final class CallLogEntryText {
*/
// For emergency numbers, the secondary text should contain only the number.
- if (PhoneNumberHelper.isLocalEmergencyNumber(context, row.getNumber().getNormalizedNumber())) {
+ if (row.getNumberAttributes().getIsEmergencyNumber()) {
return !row.getFormattedNumber().isEmpty()
? row.getFormattedNumber()
: row.getNumber().getNormalizedNumber();
diff --git a/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java b/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java
index 86bb79daf..5da56a127 100644
--- a/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java
+++ b/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java
@@ -30,7 +30,6 @@ import com.android.dialer.common.Assert;
import com.android.dialer.duo.Duo;
import com.android.dialer.duo.DuoComponent;
import com.android.dialer.logging.ReportingLocation;
-import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.util.CallUtil;
import com.android.dialer.util.UriUtils;
import java.util.ArrayList;
@@ -140,7 +139,7 @@ public final class HistoryItemActionModulesBuilder {
* capability, and Duo is available, add a Duo video call module.
*/
public HistoryItemActionModulesBuilder addModuleForVideoCall() {
- if (isEmergencyNumber()
+ if (moduleInfo.getIsEmergencyNumber()
|| moduleInfo.getIsVoicemailCall()
|| moduleInfo.getIsBlocked()
|| moduleInfo.getIsSpam()) {
@@ -192,7 +191,7 @@ public final class HistoryItemActionModulesBuilder {
public HistoryItemActionModulesBuilder addModuleForSendingTextMessage() {
// TODO(zachh): There are other conditions where this module should not be shown
// (e.g., business numbers).
- if (isEmergencyNumber()
+ if (moduleInfo.getIsEmergencyNumber()
|| moduleInfo.getIsVoicemailCall()
|| moduleInfo.getIsBlocked()
|| TextUtils.isEmpty(moduleInfo.getNormalizedNumber())) {
@@ -233,7 +232,7 @@ public final class HistoryItemActionModulesBuilder {
* </ul>
*/
public HistoryItemActionModulesBuilder addModuleForAddingToContacts() {
- if (isEmergencyNumber()
+ if (moduleInfo.getIsEmergencyNumber()
|| moduleInfo.getIsVoicemailCall()
|| moduleInfo.getIsBlocked()
|| moduleInfo.getIsSpam()
@@ -281,7 +280,7 @@ public final class HistoryItemActionModulesBuilder {
* <p>If a number is not blocked or marked as spam, add the "Block/Report spam" module.
*/
public HistoryItemActionModulesBuilder addModuleForBlockedOrSpamNumber() {
- if (isEmergencyNumber() || moduleInfo.getIsVoicemailCall()) {
+ if (moduleInfo.getIsEmergencyNumber() || moduleInfo.getIsVoicemailCall()) {
return this;
}
@@ -401,10 +400,6 @@ public final class HistoryItemActionModulesBuilder {
&& !UriUtils.isEncodedContactUri(Uri.parse(moduleInfo.getLookupUri()));
}
- private boolean isEmergencyNumber() {
- return PhoneNumberHelper.isLocalEmergencyNumber(context, moduleInfo.getNormalizedNumber());
- }
-
/**
* Maps the value of {@link HistoryItemActionModuleInfo#getHost()} to {@link
* CallInitiationType.Type}, which is required by {@link CallIntentBuilder} to build a call
diff --git a/java/com/android/dialer/historyitemactions/history_item_action_module_info.proto b/java/com/android/dialer/historyitemactions/history_item_action_module_info.proto
index 99071a7cd..f7022c28c 100644
--- a/java/com/android/dialer/historyitemactions/history_item_action_module_info.proto
+++ b/java/com/android/dialer/historyitemactions/history_item_action_module_info.proto
@@ -10,7 +10,7 @@ package com.android.dialer.historyitemactions;
import "java/com/android/dialer/logging/contact_source.proto";
// Contains information needed to construct items (modules) in a bottom sheet.
-// Next ID: 16
+// Next ID: 17
message HistoryItemActionModuleInfo {
// The dialer-normalized version of a phone number.
// See DialerPhoneNumber.normalized_number.
@@ -66,4 +66,7 @@ message HistoryItemActionModuleInfo {
VOICEMAIL = 2;
}
optional Host host = 15;
+
+ // Whether the number is an emergency number.
+ optional bool is_emergency_number = 16;
}
diff --git a/java/com/android/dialer/voicemail/listui/menu/Modules.java b/java/com/android/dialer/voicemail/listui/menu/Modules.java
index dcd9116e9..5a9a7110c 100644
--- a/java/com/android/dialer/voicemail/listui/menu/Modules.java
+++ b/java/com/android/dialer/voicemail/listui/menu/Modules.java
@@ -58,6 +58,7 @@ final class Modules {
.setCanSupportCarrierVideoCall(
voicemailEntry.getNumberAttributes().getCanSupportCarrierVideoCall())
.setIsBlocked(voicemailEntry.getNumberAttributes().getIsBlocked())
+ .setIsEmergencyNumber(voicemailEntry.getNumberAttributes().getIsEmergencyNumber())
.setIsSpam(voicemailEntry.getNumberAttributes().getIsSpam())
// A voicemail call is an outgoing call to the voicemail box.
// Voicemail entries are not voicemail calls.