diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-02-22 17:54:05 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-02-22 17:54:05 +0000 |
commit | b3772ecffe9901d9a55c3f3284cc652057b43f8b (patch) | |
tree | 7146a3f81ae20729260191d294e4baca01e8e3ce /java/com/android/dialer | |
parent | c54ce2658988ca36ca3dfab00daefca4dcfed3b2 (diff) | |
parent | a9776efc28f13671fe01c7a2ca5513d462e00b3c (diff) |
Merge changes Idbaca1df,Ie7824ce2,Id24b2318,Ib40632fe,I292f23ea, ...
* changes:
Do no preload dialpad fragment when opening search through search bar.
Add logging to NUI.
Implemented hangouts connection into GoogleMainActivity.
Created a "Metrics" interface.
Fix the icon & the label for blocked spam numbers in the new call log.
Move RttChatBot to simulator.
Update RTT call with real name/number and timer.
Include both PHOTO_URI and PHOTO_THUMBNAIL_URI in Cp2Info.
Add simulator RTT call.
Diffstat (limited to 'java/com/android/dialer')
33 files changed, 760 insertions, 128 deletions
diff --git a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java index 0f00a5d82..35f854010 100644 --- a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java +++ b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java @@ -26,6 +26,7 @@ import com.android.dialer.enrichedcall.stub.StubEnrichedCallModule; import com.android.dialer.feedback.stub.StubFeedbackModule; import com.android.dialer.glidephotomanager.GlidePhotoManagerModule; import com.android.dialer.inject.ContextModule; +import com.android.dialer.metrics.StubMetricsModule; import com.android.dialer.phonelookup.PhoneLookupModule; import com.android.dialer.phonenumbergeoutil.impl.PhoneNumberGeoUtilModule; import com.android.dialer.precall.impl.PreCallModule; @@ -63,6 +64,7 @@ import javax.inject.Singleton; StubDuoModule.class, StubEnrichedCallModule.class, StubNewBubbleModule.class, + StubMetricsModule.class, StubFeedbackModule.class, StubMapsModule.class, StubSimSuggestionModule.class, diff --git a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java index 3e7db9d8a..cd95c3ee7 100644 --- a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java +++ b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java @@ -27,6 +27,7 @@ import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.feedback.FeedbackComponent; import com.android.dialer.glidephotomanager.GlidePhotoManagerComponent; import com.android.dialer.main.MainComponent; +import com.android.dialer.metrics.MetricsComponent; import com.android.dialer.phonelookup.PhoneLookupComponent; import com.android.dialer.phonenumbergeoutil.PhoneNumberGeoUtilComponent; import com.android.dialer.precall.PreCallComponent; @@ -59,6 +60,7 @@ public interface BaseDialerRootComponent GlidePhotoManagerComponent.HasComponent, MainComponent.HasComponent, MapsComponent.HasComponent, + MetricsComponent.HasComponent, NewBubbleComponent.HasComponent, PhoneLookupComponent.HasComponent, PhoneNumberGeoUtilComponent.HasComponent, diff --git a/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java b/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java index d4520f33e..497d97724 100644 --- a/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java +++ b/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java @@ -26,6 +26,7 @@ import com.android.dialer.enrichedcall.stub.StubEnrichedCallModule; import com.android.dialer.feedback.stub.StubFeedbackModule; import com.android.dialer.glidephotomanager.GlidePhotoManagerModule; import com.android.dialer.inject.ContextModule; +import com.android.dialer.metrics.StubMetricsModule; import com.android.dialer.phonelookup.PhoneLookupModule; import com.android.dialer.phonenumbergeoutil.impl.PhoneNumberGeoUtilModule; import com.android.dialer.precall.impl.PreCallModule; @@ -67,6 +68,7 @@ import javax.inject.Singleton; StubDuoModule.class, StubEnrichedCallModule.class, StubFeedbackModule.class, + StubMetricsModule.class, StubNewBubbleModule.class, StubSimSuggestionModule.class, StubSpamModule.class, diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index 52570c05e..8dec43759 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -28,18 +28,17 @@ import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import com.android.dialer.DialerPhoneNumber; -import com.android.dialer.NumberAttributes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog; import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.CallLogMutations; import com.android.dialer.calllog.datasources.util.RowCombiner; +import com.android.dialer.calllogutils.NumberAttributesConverter; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.common.concurrent.Annotations.LightweightExecutor; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; -import com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract.PhoneLookupHistory; import com.google.common.collect.ImmutableMap; @@ -573,23 +572,8 @@ public final class PhoneLookupDataSource } private void updateContentValues(ContentValues contentValues, PhoneLookupInfo phoneLookupInfo) { - PhoneLookupInfoConsolidator phoneLookupInfoConsolidator = - new PhoneLookupInfoConsolidator(phoneLookupInfo); contentValues.put( AnnotatedCallLog.NUMBER_ATTRIBUTES, - NumberAttributes.newBuilder() - .setName(phoneLookupInfoConsolidator.getName()) - .setPhotoUri(phoneLookupInfoConsolidator.getPhotoUri()) - .setPhotoId(phoneLookupInfoConsolidator.getPhotoId()) - .setLookupUri(phoneLookupInfoConsolidator.getLookupUri()) - .setNumberTypeLabel(phoneLookupInfoConsolidator.getNumberLabel()) - .setIsBusiness(phoneLookupInfoConsolidator.isBusiness()) - .setIsVoicemail(phoneLookupInfoConsolidator.isVoicemail()) - .setIsBlocked(phoneLookupInfoConsolidator.isBlocked()) - .setIsSpam(phoneLookupInfoConsolidator.isSpam()) - .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) - .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isCp2LocalInfoIncomplete()) - .build() - .toByteArray()); + NumberAttributesConverter.fromPhoneLookupInfo(phoneLookupInfo).build().toByteArray()); } } diff --git a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java index 5083a95c5..69c431953 100644 --- a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java +++ b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java @@ -23,8 +23,8 @@ import android.support.annotation.MainThread; import android.support.annotation.VisibleForTesting; import android.util.ArrayMap; import com.android.dialer.DialerPhoneNumber; -import com.android.dialer.NumberAttributes; import com.android.dialer.calllog.model.CoalescedRow; +import com.android.dialer.calllogutils.NumberAttributesConverter; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; @@ -33,7 +33,6 @@ import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.inject.ApplicationContext; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; -import com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract.PhoneLookupHistory; import com.google.common.collect.ImmutableMap; @@ -198,23 +197,8 @@ public final class RealtimeRowProcessor { private CoalescedRow applyPhoneLookupInfoToRow( PhoneLookupInfo phoneLookupInfo, CoalescedRow row) { - PhoneLookupInfoConsolidator phoneLookupInfoConsolidator = - new PhoneLookupInfoConsolidator(phoneLookupInfo); return row.toBuilder() - .setNumberAttributes( - // TODO(zachh): Put this in a common location. - NumberAttributes.newBuilder() - .setName(phoneLookupInfoConsolidator.getName()) - .setPhotoUri(phoneLookupInfoConsolidator.getPhotoUri()) - .setPhotoId(phoneLookupInfoConsolidator.getPhotoId()) - .setLookupUri(phoneLookupInfoConsolidator.getLookupUri()) - .setNumberTypeLabel(phoneLookupInfoConsolidator.getNumberLabel()) - .setIsBusiness(phoneLookupInfoConsolidator.isBusiness()) - .setIsVoicemail(phoneLookupInfoConsolidator.isVoicemail()) - .setIsBlocked(phoneLookupInfoConsolidator.isBlocked()) - .setIsSpam(phoneLookupInfoConsolidator.isSpam()) - .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) - .build()) + .setNumberAttributes(NumberAttributesConverter.fromPhoneLookupInfo(phoneLookupInfo).build()) .build(); } } diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java index 737b1d30f..ab851cbbd 100644 --- a/java/com/android/dialer/calllogutils/CallLogEntryText.java +++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java @@ -70,7 +70,8 @@ public final class CallLogEntryText { * <ul> * <li>For numbers that are not spam or blocked: (Duo video, )?$Label|$Location • Date * <li>For blocked non-spam numbers: Blocked • (Duo video, )?$Label|$Location • Date - * <li>For spam numbers: Spam • (Duo video, )?$Label • Date + * <li>For spam but not blocked numbers: Spam • (Duo video, )?$Label • Date + * <li>For blocked spam numbers: Blocked • Spam • (Duo video, )?$Label • Date * </ul> * * <p>Examples: @@ -84,6 +85,7 @@ public final class CallLogEntryText { * <li>Blocked • Brooklyn, NJ • 10 min ago * <li>Spam • Mobile • Now * <li>Spam • Now + * <li>Blocked • Spam • Mobile • Now * <li>Brooklyn, NJ • Jan 15 * </ul> * @@ -93,11 +95,11 @@ public final class CallLogEntryText { Context context, Clock clock, CoalescedRow row) { List<CharSequence> components = new ArrayList<>(); - // If a number is both spam and blocked, only show "Spam". + if (row.numberAttributes().getIsBlocked()) { + components.add(context.getText(R.string.new_call_log_secondary_blocked)); + } if (row.numberAttributes().getIsSpam()) { components.add(context.getText(R.string.new_call_log_secondary_spam)); - } else if (row.numberAttributes().getIsBlocked()) { - components.add(context.getText(R.string.new_call_log_secondary_blocked)); } components.add(getNumberTypeLabel(context, row)); @@ -121,8 +123,10 @@ public final class CallLogEntryText { * (Duo video, )?$Label|$Location [• NumberIfNoName]? * For blocked non-spam numbers: * Blocked • (Duo video, )?$Label|$Location [• NumberIfNoName]? - * For spam numbers: + * For spam but not blocked numbers: * Spam • (Duo video, )?$Label [• NumberIfNoName]? + * For blocked spam numbers: + * Blocked • Spam • (Duo video, )?$Label [• NumberIfNoName]? * * The number is shown at the end if there is no name for the entry. (It is shown in primary * text otherwise.) @@ -139,11 +143,11 @@ public final class CallLogEntryText { */ List<CharSequence> components = new ArrayList<>(); - // If a number is both spam and blocked, only show "Spam". + if (row.numberAttributes().getIsBlocked()) { + components.add(context.getText(R.string.new_call_log_secondary_blocked)); + } if (row.numberAttributes().getIsSpam()) { components.add(context.getText(R.string.new_call_log_secondary_spam)); - } else if (row.numberAttributes().getIsBlocked()) { - components.add(context.getText(R.string.new_call_log_secondary_blocked)); } components.add(getNumberTypeLabel(context, row)); diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java index bed1edd06..efd1d72c2 100644 --- a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java +++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java @@ -16,13 +16,16 @@ package com.android.dialer.calllogutils; +import android.text.TextUtils; import com.android.dialer.NumberAttributes; import com.android.dialer.glidephotomanager.PhotoInfo; +import com.android.dialer.phonelookup.PhoneLookupInfo; +import com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator; /** Converts {@link NumberAttributes} to {@link PhotoInfo} */ public final class NumberAttributesConverter { - /** Converts to {@link PhotoInfo.Builder} */ + /** Converts {@link NumberAttributes} to {@link PhotoInfo.Builder} */ public static PhotoInfo.Builder toPhotoInfoBuilder(NumberAttributes numberAttributes) { return PhotoInfo.builder() .setName(numberAttributes.getName()) @@ -34,4 +37,25 @@ public final class NumberAttributesConverter { .setIsVoicemail(numberAttributes.getIsVoicemail()) .setIsBlocked(numberAttributes.getIsBlocked()); } + + /** Converts {@link PhoneLookupInfo} to {@link NumberAttributes.Builder} */ + public static NumberAttributes.Builder fromPhoneLookupInfo(PhoneLookupInfo phoneLookupInfo) { + PhoneLookupInfoConsolidator phoneLookupInfoConsolidator = + new PhoneLookupInfoConsolidator(phoneLookupInfo); + return NumberAttributes.newBuilder() + .setName(phoneLookupInfoConsolidator.getName()) + .setPhotoUri( + !TextUtils.isEmpty(phoneLookupInfoConsolidator.getPhotoThumbnailUri()) + ? phoneLookupInfoConsolidator.getPhotoThumbnailUri() + : phoneLookupInfoConsolidator.getPhotoUri()) + .setPhotoId(phoneLookupInfoConsolidator.getPhotoId()) + .setLookupUri(phoneLookupInfoConsolidator.getLookupUri()) + .setNumberTypeLabel(phoneLookupInfoConsolidator.getNumberLabel()) + .setIsBusiness(phoneLookupInfoConsolidator.isBusiness()) + .setIsVoicemail(phoneLookupInfoConsolidator.isVoicemail()) + .setIsBlocked(phoneLookupInfoConsolidator.isBlocked()) + .setIsSpam(phoneLookupInfoConsolidator.isSpam()) + .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) + .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isCp2LocalInfoIncomplete()); + } } diff --git a/java/com/android/dialer/common/res/values/strings.xml b/java/com/android/dialer/common/res/values/strings.xml index 770f42f37..53a2b56d7 100644 --- a/java/com/android/dialer/common/res/values/strings.xml +++ b/java/com/android/dialer/common/res/values/strings.xml @@ -17,4 +17,6 @@ <resources> <string name="network_name_wifi">Wifi</string> <string name="network_name_mobile">Mobile</string> + <!-- Content description for the overflow menu button. [CHAR LIMIT=NONE] --> + <string name="content_description_overflow">More options</string> </resources> diff --git a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java index c6d92057d..10c4dfb4c 100644 --- a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java +++ b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java @@ -68,13 +68,13 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { // Warning: Glide ignores extra attributes on BitmapDrawable such as tint and draw the bitmap // directly so be sure not to set tint in the XML of any drawable referenced below. - // The spam status takes precedence over whether the number is blocked. - if (photoInfo.isSpam()) { - return requestManager.load(R.drawable.ic_report_red_48dp); - } + // Whether the number is blocked takes precedence over the spam status. if (photoInfo.isBlocked()) { return requestManager.load(R.drawable.ic_block_grey_48dp); } + if (photoInfo.isSpam()) { + return requestManager.load(R.drawable.ic_report_red_48dp); + } if (!TextUtils.isEmpty(photoInfo.photoUri())) { return requestManager.load(parseUri(photoInfo.photoUri())); } diff --git a/java/com/android/dialer/logging/dialer_impression.proto b/java/com/android/dialer/logging/dialer_impression.proto index f839b1399..635d8fd02 100644 --- a/java/com/android/dialer/logging/dialer_impression.proto +++ b/java/com/android/dialer/logging/dialer_impression.proto @@ -12,7 +12,7 @@ message DialerImpression { // Event enums to be used for Impression Logging in Dialer. // It's perfectly acceptable for this enum to be large // Values should be from 1000 to 100000. - // Next Tag: 1327 + // Next Tag: 1341 enum Type { UNKNOWN_AOSP_EVENT_TYPE = 1000; @@ -657,5 +657,23 @@ message DialerImpression { DUO_CALL_LOG_SET_UP_INSTALL_SHOWN = 1324; DUO_CALL_LOG_SET_UP_ACTIVATE_SHOWN = 1325; DUO_CALL_LOG_INVITE_SHOWN = 1326; + + // NUI bottom navigation bar + NUI_SWITCH_TAB_TO_FAVORITE = 1327; + NUI_SWITCH_TAB_TO_CALL_LOG = 1328; + NUI_SWITCH_TAB_TO_CONTACTS = 1329; + NUI_SWITCH_TAB_TO_VOICEMAIL = 1330; + // NUI search + NUI_TOUCH_DIALPAD_SEARCH_LIST_TO_CLOSE_SEARCH_AND_DIALPAD = 1331; + NUI_TOUCH_DIALPAD_SEARCH_LIST_TO_HIDE_DIALPAD = 1332; + NUI_TOUCH_SEARCH_LIST_TO_CLOSE_SEARCH = 1333; + NUI_TOUCH_SEARCH_LIST_TO_HIDE_KEYBOARD = 1334; + NUI_PRESS_BACK_BUTTON_TO_CLOSE_SEARCH = 1335; + NUI_PRESS_BACK_BUTTON_TO_CLOSE_SEARCH_AND_DIALPAD = 1336; + NUI_PRESS_BACK_BUTTON_TO_HIDE_DIALPAD = 1337; + NUI_CLICK_SEARCH_BAR = 1338; + NUI_CLICK_SEARCH_BAR_VOICE_BUTTON = 1339; + // NUI FAB + NUI_CLICK_FAB_TO_OPEN_DIALPAD = 1340; } } diff --git a/java/com/android/dialer/main/MainActivityPeer.java b/java/com/android/dialer/main/MainActivityPeer.java index 6457b607b..c1a328a65 100644 --- a/java/com/android/dialer/main/MainActivityPeer.java +++ b/java/com/android/dialer/main/MainActivityPeer.java @@ -28,6 +28,8 @@ public interface MainActivityPeer { void onActivityStop(); + void onActivityDestroyed(); + void onNewIntent(Intent intent); void onActivityResult(int requestCode, int resultCode, Intent data); diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 7098f8844..9b734f40c 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -40,6 +40,7 @@ import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.dialpadview.DialpadFragment; import com.android.dialer.dialpadview.DialpadFragment.DialpadListener; import com.android.dialer.dialpadview.DialpadFragment.OnDialpadQueryChangedListener; +import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.dialer.main.impl.bottomnav.BottomNavBar; @@ -204,14 +205,23 @@ public class MainSearchController implements SearchBarListener { public void onSearchListTouch() { if (isDialpadVisible()) { if (TextUtils.isEmpty(getDialpadFragment().getQuery())) { + Logger.get(mainActivity) + .logImpression( + DialerImpression.Type.NUI_TOUCH_DIALPAD_SEARCH_LIST_TO_CLOSE_SEARCH_AND_DIALPAD); closeSearch(true); } else { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_TOUCH_DIALPAD_SEARCH_LIST_TO_HIDE_DIALPAD); hideDialpad(/* animate=*/ true, /* bottomNavVisible=*/ false); } } else if (isSearchVisible()) { if (TextUtils.isEmpty(toolbar.getQuery())) { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_TOUCH_SEARCH_LIST_TO_CLOSE_SEARCH); closeSearch(true); } else { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_TOUCH_SEARCH_LIST_TO_HIDE_KEYBOARD); toolbar.hideKeyboard(); } } @@ -225,10 +235,17 @@ public class MainSearchController implements SearchBarListener { public boolean onBackPressed() { if (isDialpadVisible() && !TextUtils.isEmpty(getDialpadFragment().getQuery())) { LogUtil.i("MainSearchController#onBackPressed", "Dialpad visible with query"); + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_PRESS_BACK_BUTTON_TO_HIDE_DIALPAD); hideDialpad(/* animate=*/ true, /* bottomNavVisible=*/ false); return true; } else if (isSearchVisible()) { LogUtil.i("MainSearchController#onBackPressed", "Search is visible"); + Logger.get(mainActivity) + .logImpression( + isDialpadVisible() + ? DialerImpression.Type.NUI_PRESS_BACK_BUTTON_TO_CLOSE_SEARCH_AND_DIALPAD + : DialerImpression.Type.NUI_PRESS_BACK_BUTTON_TO_CLOSE_SEARCH); closeSearch(true); return true; } else { @@ -252,16 +269,13 @@ public class MainSearchController implements SearchBarListener { mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit(); // Clear the dialpad so the phone number isn't persisted between search sessions. - getDialpadFragment().clearDialpad(); + if (getDialpadFragment() != null) { + getDialpadFragment().clearDialpad(); + } } - /** - * Returns {@link DialpadFragment}. - * - * <p>Unless this method is being called for the first time in {@link #openSearch(Optional)} or - * {@link #showDialpad(boolean)}, it should never return null. - */ - private DialpadFragment getDialpadFragment() { + @Nullable + protected DialpadFragment getDialpadFragment() { return (DialpadFragment) mainActivity.getFragmentManager().findFragmentByTag(DIALPAD_FRAGMENT_TAG); } @@ -297,6 +311,7 @@ public class MainSearchController implements SearchBarListener { */ @Override public void onSearchBarClicked() { + Logger.get(mainActivity).logImpression(DialerImpression.Type.NUI_CLICK_SEARCH_BAR); openSearch(Optional.absent()); } @@ -316,14 +331,6 @@ public class MainSearchController implements SearchBarListener { transaction.show(getSearchFragment()); } - // Add the dialpad fragment but keep it hidden - if (getDialpadFragment() == null) { - DialpadFragment dialpadFragment = new DialpadFragment(); - transaction - .add(R.id.dialpad_fragment_container, dialpadFragment, DIALPAD_FRAGMENT_TAG) - .hide(dialpadFragment); - } - transaction.commit(); } @@ -350,6 +357,7 @@ public class MainSearchController implements SearchBarListener { @Override public void onVoiceButtonClicked(VoiceSearchResultCallback voiceSearchResultCallback) { + Logger.get(mainActivity).logImpression(DialerImpression.Type.NUI_CLICK_SEARCH_BAR_VOICE_BUTTON); try { Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mainActivity.startActivityForResult(voiceIntent, ActivityRequestCodes.DIALTACTS_VOICE_SEARCH); diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index 0a85667a1..ed67df936 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -60,6 +60,9 @@ public class NewMainActivityPeer implements MainActivityPeer { public void onActivityStop() {} @Override + public void onActivityDestroyed() {} + + @Override public void onNewIntent(Intent intent) {} @Override diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index c46e61bd0..07c7185ae 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -66,6 +66,8 @@ import com.android.dialer.dialpadview.DialpadFragment.DialpadListener; import com.android.dialer.dialpadview.DialpadFragment.LastOutgoingCallCallback; import com.android.dialer.dialpadview.DialpadFragment.OnDialpadQueryChangedListener; import com.android.dialer.interactions.PhoneNumberInteraction; +import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.Logger; import com.android.dialer.main.MainActivityPeer; import com.android.dialer.main.impl.bottomnav.BottomNavBar; import com.android.dialer.main.impl.bottomnav.BottomNavBar.OnBottomNavTabSelectedListener; @@ -154,6 +156,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onActivityCreate(Bundle savedInstanceState) { + LogUtil.enterBlock("OldMainActivityPeer.onActivityCreate"); mainActivity.setContentView(R.layout.main_activity); initUiListeners(); initLayout(savedInstanceState); @@ -173,14 +176,19 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen snackbarContainer = mainActivity.findViewById(R.id.coordinator_layout); FloatingActionButton fab = mainActivity.findViewById(R.id.fab); - fab.setOnClickListener(v -> searchController.showDialpad(true)); + fab.setOnClickListener( + v -> { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_CLICK_FAB_TO_OPEN_DIALPAD); + searchController.showDialpad(true); + }); MainToolbar toolbar = mainActivity.findViewById(R.id.toolbar); mainActivity.setSupportActionBar(mainActivity.findViewById(R.id.toolbar)); bottomNav = mainActivity.findViewById(R.id.bottom_nav_bar); MainBottomNavBarBottomNavTabListener bottomNavTabListener = - new MainBottomNavBarBottomNavTabListener(mainActivity.getFragmentManager()); + new MainBottomNavBarBottomNavTabListener(mainActivity, mainActivity.getFragmentManager()); bottomNav.addOnTabSelectedListener(bottomNavTabListener); callLogFragmentListener = @@ -191,7 +199,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen searchController = getNewMainSearchController(bottomNav, fab, toolbar); toolbar.setSearchBarListener(searchController); - onDialpadQueryChangedListener = new MainOnDialpadQueryChangedListener(searchController); + onDialpadQueryChangedListener = getNewOnDialpadQueryChangedListener(searchController); dialpadListener = new MainDialpadListener(mainActivity, searchController, getLastOutgoingCallListener); searchFragmentListener = new MainSearchFragmentListener(searchController); @@ -222,6 +230,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onNewIntent(Intent intent) { + LogUtil.enterBlock("OldMainActivityPeer.onNewIntent"); showTabOnIntent(intent); } @@ -285,6 +294,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen mainActivity.getSystemService(KeyguardManager.class).isKeyguardLocked()); } + @Override + public void onActivityDestroyed() {} + private void showPostCallPrompt() { if (TelecomUtil.isInManagedCall(mainActivity)) { // No prompt to show if the user is in a call @@ -309,10 +321,15 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { + LogUtil.i( + "OldMainActivityPeer.onActivityResult", + "requestCode:%d, resultCode:%d", + requestCode, + resultCode); if (requestCode == ActivityRequestCodes.DIALTACTS_VOICE_SEARCH) { searchController.onVoiceResults(resultCode, data); } else { - LogUtil.e("MainActivity.onActivityResult", "Unknown request code: " + requestCode); + LogUtil.e("OldMainActivityPeer.onActivityResult", "Unknown request code: " + requestCode); } } @@ -350,6 +367,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen return (T) onPhoneNumberPickerActionListener; } else if (callbackInterface.isInstance(oldSpeedDialFragmentHost)) { return (T) oldSpeedDialFragmentHost; + } else if (callbackInterface.isInstance(searchController)) { + return (T) searchController; } else { return null; } @@ -360,6 +379,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar); } + public MainOnDialpadQueryChangedListener getNewOnDialpadQueryChangedListener( + MainSearchController mainSearchController) { + return new MainOnDialpadQueryChangedListener(mainSearchController); + } + /** @see OnContactSelectedListener */ private static final class MainOnContactSelectedListener implements OnContactSelectedListener { @@ -378,12 +402,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } /** @see OnDialpadQueryChangedListener */ - private static final class MainOnDialpadQueryChangedListener + protected static class MainOnDialpadQueryChangedListener implements OnDialpadQueryChangedListener { private final MainSearchController searchController; - MainOnDialpadQueryChangedListener(MainSearchController searchController) { + protected MainOnDialpadQueryChangedListener(MainSearchController searchController) { this.searchController = searchController; } @@ -794,13 +818,20 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private static final String VOICEMAIL_TAG = "voicemail"; private final FragmentManager fragmentManager; + private final Context context; + @TabIndex private int selectedTab = -1; - private MainBottomNavBarBottomNavTabListener(FragmentManager fragmentManager) { + private MainBottomNavBarBottomNavTabListener(Context context, FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; + this.context = context; } @Override public void onSpeedDialSelected() { + if (selectedTab != TabIndex.SPEED_DIAL) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_FAVORITE); + selectedTab = TabIndex.SPEED_DIAL; + } hideAllFragments(); Fragment fragment = fragmentManager.findFragmentByTag(SPEED_DIAL_TAG); if (fragment == null) { @@ -815,6 +846,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onCallLogSelected() { + if (selectedTab != TabIndex.CALL_LOG) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_CALL_LOG); + selectedTab = TabIndex.CALL_LOG; + } hideAllFragments(); CallLogFragment fragment = (CallLogFragment) fragmentManager.findFragmentByTag(CALL_LOG_TAG); if (fragment == null) { @@ -829,6 +864,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onContactsSelected() { + if (selectedTab != TabIndex.CONTACTS) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_CONTACTS); + selectedTab = TabIndex.CONTACTS; + } hideAllFragments(); ContactsFragment fragment = (ContactsFragment) fragmentManager.findFragmentByTag(CONTACTS_TAG); @@ -847,6 +886,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onVoicemailSelected() { + if (selectedTab != TabIndex.VOICEMAIL) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_VOICEMAIL); + selectedTab = TabIndex.VOICEMAIL; + } hideAllFragments(); VisualVoicemailCallLogFragment fragment = (VisualVoicemailCallLogFragment) fragmentManager.findFragmentByTag(VOICEMAIL_TAG); diff --git a/java/com/android/dialer/metrics/Metrics.java b/java/com/android/dialer/metrics/Metrics.java new file mode 100644 index 000000000..3922a8cfa --- /dev/null +++ b/java/com/android/dialer/metrics/Metrics.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.metrics; + +import android.app.Application; +import android.content.Context; + +/** Logs metrics. */ +public interface Metrics { + + /** Start a timer. */ + void startTimer(Context context, String timerEventName); + + /** Stop a timer. */ + void stopTimer(String timerEventName); + + /** Record memory. */ + void recordMemory(String memoryEventName); + + /** Initiazer for metrics. */ + interface Initializer { + /** Initialize metrics for the application . */ + void initialize(Application application); + } +} diff --git a/java/com/android/dialer/metrics/MetricsComponent.java b/java/com/android/dialer/metrics/MetricsComponent.java new file mode 100644 index 000000000..f37129791 --- /dev/null +++ b/java/com/android/dialer/metrics/MetricsComponent.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.metrics; + +import android.content.Context; +import com.android.dialer.inject.HasRootComponent; +import dagger.Subcomponent; + +/** Component for metrics. */ +@Subcomponent +public abstract class MetricsComponent { + + public abstract Metrics metrics(); + + public abstract Metrics.Initializer metricsInitializer(); + + public static MetricsComponent get(Context context) { + return ((MetricsComponent.HasComponent) + ((HasRootComponent) context.getApplicationContext()).component()) + .metricsComponent(); + } + + /** Used to refer to the root application component. */ + public interface HasComponent { + MetricsComponent metricsComponent(); + } +} diff --git a/java/com/android/dialer/metrics/StubMetrics.java b/java/com/android/dialer/metrics/StubMetrics.java new file mode 100644 index 000000000..114eb4308 --- /dev/null +++ b/java/com/android/dialer/metrics/StubMetrics.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.metrics; + +import android.content.Context; +import javax.inject.Inject; + +/** Stub {@link Metrics}. */ +public final class StubMetrics implements Metrics { + + @Inject + StubMetrics() {} + + @Override + public void startTimer(Context context, String timerEventName) {} + + @Override + public void stopTimer(String timerEventName) {} + + @Override + public void recordMemory(String memoryEventName) {} +} diff --git a/java/com/android/dialer/metrics/StubMetricsInitializer.java b/java/com/android/dialer/metrics/StubMetricsInitializer.java new file mode 100644 index 000000000..cea408737 --- /dev/null +++ b/java/com/android/dialer/metrics/StubMetricsInitializer.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.metrics; + +import android.app.Application; +import javax.inject.Inject; + +/** Stub for {@link Metrics.Initializer}. */ +public class StubMetricsInitializer implements Metrics.Initializer { + + @Inject + StubMetricsInitializer() {} + + @Override + public void initialize(Application application) {} +} diff --git a/java/com/android/dialer/metrics/StubMetricsModule.java b/java/com/android/dialer/metrics/StubMetricsModule.java new file mode 100644 index 000000000..a2d9ebfe2 --- /dev/null +++ b/java/com/android/dialer/metrics/StubMetricsModule.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.metrics; + +import dagger.Binds; +import dagger.Module; + +/** Binds stub {@link Metrics}. */ +@Module +public interface StubMetricsModule { + + @Binds + Metrics bindMetrics(StubMetrics stub); + + @Binds + Metrics.Initializer bindMetricsInitializer(StubMetricsInitializer stub); +} diff --git a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java index ce4030d70..9c5411081 100644 --- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java +++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java @@ -108,6 +108,28 @@ public final class PhoneLookupInfoConsolidator { /** * The {@link PhoneLookupInfo} passed to the constructor is associated with a number. This method + * returns the photo thumbnail URI associated with that number. + * + * <p>If no photo thumbnail URI can be obtained from the {@link PhoneLookupInfo}, an empty string + * will be returned. + */ + public String getPhotoThumbnailUri() { + switch (nameSource) { + case NameSource.CP2_LOCAL: + return Assert.isNotNull(firstCp2LocalContact).getPhotoThumbnailUri(); + case NameSource.CP2_REMOTE: + return Assert.isNotNull(firstCp2RemoteContact).getPhotoThumbnailUri(); + case NameSource.PEOPLE_API: + case NameSource.NONE: + return ""; + default: + throw Assert.createUnsupportedOperationFailException( + String.format("Unsupported name source: %s", nameSource)); + } + } + + /** + * The {@link PhoneLookupInfo} passed to the constructor is associated with a number. This method * returns the photo URI associated with that number. * * <p>If no photo URI can be obtained from the {@link PhoneLookupInfo}, an empty string will be diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java b/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java index e3929990e..5a211eddc 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java @@ -35,12 +35,13 @@ final class Cp2Projections { new String[] { Phone.DISPLAY_NAME_PRIMARY, // 0 Phone.PHOTO_THUMBNAIL_URI, // 1 - Phone.PHOTO_ID, // 2 - Phone.TYPE, // 3 - Phone.LABEL, // 4 - Phone.NORMALIZED_NUMBER, // 5 - Phone.CONTACT_ID, // 6 - Phone.LOOKUP_KEY // 7 + Phone.PHOTO_URI, // 2 + Phone.PHOTO_ID, // 3 + Phone.TYPE, // 4 + Phone.LABEL, // 5 + Phone.NORMALIZED_NUMBER, // 6 + Phone.CONTACT_ID, // 7 + Phone.LOOKUP_KEY // 8 }; // Projection for performing lookups using the PHONE_LOOKUP table @@ -48,23 +49,25 @@ final class Cp2Projections { new String[] { PhoneLookup.DISPLAY_NAME_PRIMARY, // 0 PhoneLookup.PHOTO_THUMBNAIL_URI, // 1 - PhoneLookup.PHOTO_ID, // 2 - PhoneLookup.TYPE, // 3 - PhoneLookup.LABEL, // 4 - PhoneLookup.NORMALIZED_NUMBER, // 5 - PhoneLookup.CONTACT_ID, // 6 - PhoneLookup.LOOKUP_KEY // 7 + PhoneLookup.PHOTO_URI, // 2 + PhoneLookup.PHOTO_ID, // 3 + PhoneLookup.TYPE, // 4 + PhoneLookup.LABEL, // 5 + PhoneLookup.NORMALIZED_NUMBER, // 6 + PhoneLookup.CONTACT_ID, // 7 + PhoneLookup.LOOKUP_KEY // 8 }; // The following indexes should match both PHONE_PROJECTION and PHONE_LOOKUP_PROJECTION above. private static final int CP2_INFO_NAME_INDEX = 0; - private static final int CP2_INFO_PHOTO_URI_INDEX = 1; - private static final int CP2_INFO_PHOTO_ID_INDEX = 2; - private static final int CP2_INFO_TYPE_INDEX = 3; - private static final int CP2_INFO_LABEL_INDEX = 4; - private static final int CP2_INFO_NORMALIZED_NUMBER_INDEX = 5; - private static final int CP2_INFO_CONTACT_ID_INDEX = 6; - private static final int CP2_INFO_LOOKUP_KEY_INDEX = 7; + private static final int CP2_INFO_PHOTO_THUMBNAIL_URI_INDEX = 1; + private static final int CP2_INFO_PHOTO_URI_INDEX = 2; + private static final int CP2_INFO_PHOTO_ID_INDEX = 3; + private static final int CP2_INFO_TYPE_INDEX = 4; + private static final int CP2_INFO_LABEL_INDEX = 5; + private static final int CP2_INFO_NORMALIZED_NUMBER_INDEX = 6; + private static final int CP2_INFO_CONTACT_ID_INDEX = 7; + private static final int CP2_INFO_LOOKUP_KEY_INDEX = 8; private Cp2Projections() {} @@ -82,6 +85,7 @@ final class Cp2Projections { */ static Cp2ContactInfo buildCp2ContactInfoFromCursor(Context appContext, Cursor cursor) { String displayName = cursor.getString(CP2_INFO_NAME_INDEX); + String photoThumbnailUri = cursor.getString(CP2_INFO_PHOTO_THUMBNAIL_URI_INDEX); String photoUri = cursor.getString(CP2_INFO_PHOTO_URI_INDEX); int photoId = cursor.getInt(CP2_INFO_PHOTO_ID_INDEX); int type = cursor.getInt(CP2_INFO_TYPE_INDEX); @@ -93,6 +97,9 @@ final class Cp2Projections { if (!TextUtils.isEmpty(displayName)) { infoBuilder.setName(displayName); } + if (!TextUtils.isEmpty(photoThumbnailUri)) { + infoBuilder.setPhotoThumbnailUri(photoThumbnailUri); + } if (!TextUtils.isEmpty(photoUri)) { infoBuilder.setPhotoUri(photoUri); } diff --git a/java/com/android/dialer/phonelookup/phone_lookup_info.proto b/java/com/android/dialer/phonelookup/phone_lookup_info.proto index e9cb9f8ad..dd6bf664c 100644 --- a/java/com/android/dialer/phonelookup/phone_lookup_info.proto +++ b/java/com/android/dialer/phonelookup/phone_lookup_info.proto @@ -19,6 +19,7 @@ message PhoneLookupInfo { message Cp2Info { // Information about a single contact, which can be a local contact or a // remote one. + // Next ID: 8 message Cp2ContactInfo { // For a local contact: // android.provider.ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY @@ -30,13 +31,19 @@ message PhoneLookupInfo { // android.provider.ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI // For a remote contact: // android.provider.ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI - optional string photo_uri = 2; + optional string photo_thumbnail_uri = 2; + + // For a local contact: + // android.provider.ContactsContract.CommonDataKinds.Phone.PHOTO_URI + // For a remote contact: + // android.provider.ContactsContract.PhoneLookup.PHOTO_URI + optional string photo_uri = 3; // For a local contact: // android.provider.ContactsContract.CommonDataKinds.Phone.PHOTO_ID // For a remote contact: // android.provider.ContactsContract.PhoneLookup.PHOTO_ID - optional fixed64 photo_id = 3; + optional fixed64 photo_id = 4; // For a local contact: // android.provider.ContactsContract.CommonDataKinds.Phone.LABEL @@ -44,13 +51,13 @@ message PhoneLookupInfo { // android.provider.ContactsContract.PhoneLookup.LABEL // // The value can be "Home", "Mobile", ect. - optional string label = 4; + optional string label = 5; // For a local contact: // android.provider.ContactsContract.CommonDataKinds.Phone.CONTACT_ID // For a remote contact: // android.provider.ContactsContract.PhoneLookup.CONTACT_ID - optional fixed64 contact_id = 5; + optional fixed64 contact_id = 6; // For a local contact: // constructed based on @@ -58,7 +65,7 @@ message PhoneLookupInfo { // For a remote contact: // constructed based on // android.provider.ContactsContract.PhoneLookup.LOOKUP_KEY - optional string lookup_uri = 6; + optional string lookup_uri = 7; } // Repeated because one phone number can be associated with multiple CP2 // contacts. diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index c62d40e59..2d45457d2 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -488,7 +488,9 @@ public final class NewSearchFragment extends Fragment if (event.getAction() == MotionEvent.ACTION_UP) { v.performClick(); } - FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class).onSearchListTouch(); + if (event.getAction() == MotionEvent.ACTION_DOWN) { + FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class).onSearchListTouch(); + } return false; } diff --git a/java/com/android/dialer/simulator/Simulator.java b/java/com/android/dialer/simulator/Simulator.java index 3c2526be7..11a07d974 100644 --- a/java/com/android/dialer/simulator/Simulator.java +++ b/java/com/android/dialer/simulator/Simulator.java @@ -101,6 +101,9 @@ public interface Simulator { MERGE, SEPARATE, SWAP, + START_RTT, + STOP_RTT, + HANDLE_RTT_UPGRADE_RESPONSE, }) public @interface Type {} @@ -118,6 +121,9 @@ public interface Simulator { public static final int MERGE = 11; public static final int SEPARATE = 12; public static final int SWAP = 13; + public static final int START_RTT = 14; + public static final int STOP_RTT = 15; + public static final int HANDLE_RTT_UPGRADE_RESPONSE = 16; @Type public final int type; /** Holds event specific information. For example, for DTMF this could be the keycode. */ diff --git a/java/com/android/dialer/simulator/impl/RttChatBot.java b/java/com/android/dialer/simulator/impl/RttChatBot.java new file mode 100644 index 000000000..9c2989a07 --- /dev/null +++ b/java/com/android/dialer/simulator/impl/RttChatBot.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.simulator.impl; + +import android.os.Handler; +import android.os.HandlerThread; +import android.os.Looper; +import android.support.annotation.MainThread; +import android.telecom.Connection.RttTextStream; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.incallui.rtt.protocol.Constants; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** Chat bot to generate remote RTT chat messages. */ +public class RttChatBot { + + interface Callback { + void type(String text); + } + + private static final int START_SENDING = 1; + private static final int SEND_MESSAGE = 2; + + private static final String[] CANDIDATE_MESSAGES = + new String[] { + "To RTT or not to RTT, that is the question...", + "Making TTY great again!", + "I would be more comfortable with real \"Thyme\" chatting." + + " I don't know how to end this pun", + "お疲れ様でした", + "The FCC has mandated that I respond... I will do so begrudgingly", + "😂😂😂💯" + }; + + private final MessageHandler messageHandler; + private final HandlerThread handlerThread; + + RttChatBot(RttTextStream rttTextStream) { + handlerThread = new HandlerThread("RttChatBot"); + handlerThread.start(); + messageHandler = new MessageHandler(handlerThread.getLooper(), rttTextStream); + } + + @MainThread + public void start() { + Assert.isMainThread(); + LogUtil.enterBlock("RttChatBot.start"); + messageHandler.sendEmptyMessage(START_SENDING); + } + + @MainThread + public void stop() { + Assert.isMainThread(); + LogUtil.enterBlock("RttChatBot.stop"); + if (handlerThread != null && handlerThread.isAlive()) { + handlerThread.quit(); + } + } + + private static class MessageHandler extends Handler { + private final RttTextStream rttTextStream; + private final Random random = new Random(); + private final List<String> messageQueue = new ArrayList<>(); + private int currentTypingPosition = -1; + private String currentTypingMessage = null; + + MessageHandler(Looper looper, RttTextStream rttTextStream) { + super(looper); + this.rttTextStream = rttTextStream; + } + + @Override + public void handleMessage(android.os.Message msg) { + switch (msg.what) { + case START_SENDING: + sendMessage(obtainMessage(SEND_MESSAGE, nextTyping())); + break; + case SEND_MESSAGE: + String message = (String) msg.obj; + LogUtil.w("test", "type: %s, to stream: %s", message, rttTextStream); + try { + rttTextStream.write(message); + } catch (IOException e) { + LogUtil.e("RttChatBot.MessageHandler", "write message", e); + } + if (Constants.BUBBLE_BREAKER.equals(message)) { + // Wait 1-11s between two messages. + sendMessageDelayed( + obtainMessage(SEND_MESSAGE, nextTyping()), 1000 * (1 + random.nextInt(10))); + } else { + // Wait up to 2s between typing. + sendMessageDelayed(obtainMessage(SEND_MESSAGE, nextTyping()), 200 * random.nextInt(10)); + } + break; + default: // fall out + } + } + + private String nextTyping() { + if (currentTypingPosition < 0 || currentTypingMessage == null) { + if (messageQueue.isEmpty()) { + String text = CANDIDATE_MESSAGES[random.nextInt(CANDIDATE_MESSAGES.length)]; + messageQueue.add(text); + } + currentTypingMessage = messageQueue.remove(0); + currentTypingPosition = 0; + } + if (currentTypingPosition < currentTypingMessage.length()) { + int size = random.nextInt(currentTypingMessage.length() - currentTypingPosition + 1); + String messageToType = + currentTypingMessage.substring(currentTypingPosition, currentTypingPosition + size); + currentTypingPosition = currentTypingPosition + size; + return messageToType; + } else { + currentTypingPosition = -1; + currentTypingMessage = null; + return Constants.BUBBLE_BREAKER; + } + } + } +} diff --git a/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java b/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java index 2bfa98247..81a3d30de 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java +++ b/java/com/android/dialer/simulator/impl/SimulatorConferenceCreator.java @@ -97,7 +97,8 @@ final class SimulatorConferenceCreator default: break; } - SimulatorSimCallManager.addNewIncomingCall(context, number, false /* isVideo */, extras); + SimulatorSimCallManager.addNewIncomingCall( + context, number, SimulatorSimCallManager.CALL_TYPE_VOICE, extras); } @Override diff --git a/java/com/android/dialer/simulator/impl/SimulatorConnection.java b/java/com/android/dialer/simulator/impl/SimulatorConnection.java index d7427dd12..c832a5051 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorConnection.java +++ b/java/com/android/dialer/simulator/impl/SimulatorConnection.java @@ -121,6 +121,24 @@ public final class SimulatorConnection extends Connection { onEvent(new Event(Event.DTMF, Character.toString(c), null)); } + @Override + public void onStartRtt(@NonNull RttTextStream rttTextStream) { + LogUtil.enterBlock("SimulatorConnection.onStartRtt"); + onEvent(new Event(Event.START_RTT)); + } + + @Override + public void onStopRtt() { + LogUtil.enterBlock("SimulatorConnection.onStopRtt"); + onEvent(new Event(Event.STOP_RTT)); + } + + @Override + public void handleRttUpgradeResponse(RttTextStream rttTextStream) { + LogUtil.enterBlock("SimulatorConnection.handleRttUpgradeResponse"); + onEvent(new Event(Event.HANDLE_RTT_UPGRADE_RESPONSE)); + } + void onEvent(@NonNull Event event) { events.add(Assert.isNotNull(event)); for (Listener listener : new ArrayList<>(listeners)) { diff --git a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java index 0bd1c0f22..1bf4b2a00 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java +++ b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java @@ -33,7 +33,6 @@ import com.android.dialer.enrichedcall.simulator.EnrichedCallSimulatorActivity; import com.android.dialer.persistentlog.PersistentLogger; import com.android.dialer.preferredsim.PreferredSimFallbackContract; import com.android.dialer.simulator.SimulatorComponent; -import com.android.incallui.rtt.impl.RttChatActivity; /** Implements the top level simulator menu. */ final class SimulatorMainMenu { @@ -42,9 +41,9 @@ final class SimulatorMainMenu { SimulatorSubMenu simulatorSubMenu = new SimulatorSubMenu(activity.getApplicationContext()); simulatorSubMenu .addItem("Voice call", SimulatorVoiceCall.getActionProvider(activity)) + .addItem("Rtt call", SimulatorRttCall.getActionProvider(activity.getApplicationContext())) .addItem( "IMS video", SimulatorVideoCall.getActionProvider(activity.getApplicationContext())) - .addItem("Rtt call mock", () -> simulateRttCallMock(activity.getApplicationContext())) .addItem( "Notifications", SimulatorNotifications.getActionProvider(activity.getApplicationContext())) @@ -79,10 +78,6 @@ final class SimulatorMainMenu { return simulatorSubMenu; } - private static void simulateRttCallMock(@NonNull Context context) { - context.startActivity(new Intent(context, RttChatActivity.class)); - } - private static void populateDatabase(@NonNull Context context) { DialerExecutorComponent.get(context) .dialerExecutorFactory() diff --git a/java/com/android/dialer/simulator/impl/SimulatorMissedCallCreator.java b/java/com/android/dialer/simulator/impl/SimulatorMissedCallCreator.java index 6d4a26278..b8556156b 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorMissedCallCreator.java +++ b/java/com/android/dialer/simulator/impl/SimulatorMissedCallCreator.java @@ -78,7 +78,8 @@ final class SimulatorMissedCallCreator implements SimulatorConnectionService.Lis extras.putInt(EXTRA_CALL_COUNT, callCount - 1); extras.putBoolean(EXTRA_IS_MISSED_CALL_CONNECTION, true); - SimulatorSimCallManager.addNewIncomingCall(context, callerId, false /* isVideo */, extras); + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE, extras); } private static boolean isMissedCallConnection(@NonNull Connection connection) { diff --git a/java/com/android/dialer/simulator/impl/SimulatorRttCall.java b/java/com/android/dialer/simulator/impl/SimulatorRttCall.java new file mode 100644 index 000000000..7b0066719 --- /dev/null +++ b/java/com/android/dialer/simulator/impl/SimulatorRttCall.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.simulator.impl; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.telecom.Connection; +import android.telecom.DisconnectCause; +import android.view.ActionProvider; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.ThreadUtil; +import com.android.dialer.simulator.Simulator; +import com.android.dialer.simulator.Simulator.Event; + +/** Entry point in the simulator to create voice calls. */ +final class SimulatorRttCall + implements SimulatorConnectionService.Listener, SimulatorConnection.Listener { + + @NonNull private final Context context; + @Nullable private String connectionTag; + + static ActionProvider getActionProvider(@NonNull Context context) { + return new SimulatorSubMenu(context) + .addItem("Incoming call", () -> new SimulatorRttCall(context).addNewIncomingCall(false)) + .addItem("Outgoing call", () -> new SimulatorRttCall(context).addNewOutgoingCall()) + .addItem("Emergency call", () -> new SimulatorRttCall(context).addNewEmergencyCall()); + } + + private SimulatorRttCall(@NonNull Context context) { + this.context = Assert.isNotNull(context); + SimulatorConnectionService.addListener(this); + SimulatorConnectionService.addListener( + new SimulatorConferenceCreator(context, Simulator.CONFERENCE_TYPE_GSM)); + } + + private void addNewIncomingCall(boolean isSpam) { + String callerId = + isSpam + ? "+1-661-778-3020" /* Blacklisted custom spam number */ + : "+44 (0) 20 7031 3000" /* Google London office */; + connectionTag = + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_RTT); + } + + private void addNewOutgoingCall() { + String callerId = "+55-31-2128-6800"; // Brazil office. + connectionTag = + SimulatorSimCallManager.addNewOutgoingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_RTT); + } + + private void addNewEmergencyCall() { + String callerId = "911"; + connectionTag = + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_RTT); + } + + @Override + public void onNewOutgoingConnection(@NonNull SimulatorConnection connection) { + if (isMyConnection(connection)) { + LogUtil.i("SimulatorRttCall.onNewOutgoingConnection", "connection created"); + handleNewConnection(connection); + + // Telecom will force the connection to switch to Dialing when we return it. Wait until after + // we're returned it before changing call state. + ThreadUtil.postOnUiThread(connection::setActive); + } + } + + @Override + public void onNewIncomingConnection(@NonNull SimulatorConnection connection) { + if (isMyConnection(connection)) { + LogUtil.i("SimulatorRttCall.onNewIncomingConnection", "connection created"); + handleNewConnection(connection); + } + } + + @Override + public void onConference( + @NonNull SimulatorConnection connection1, @NonNull SimulatorConnection connection2) {} + + private void handleNewConnection(@NonNull SimulatorConnection connection) { + connection.addListener(this); + connection.setConnectionProperties( + connection.getConnectionProperties() | Connection.PROPERTY_IS_RTT); + } + + private boolean isMyConnection(@NonNull Connection connection) { + return connection.getExtras().getBoolean(connectionTag); + } + + @Override + public void onEvent(@NonNull SimulatorConnection connection, @NonNull Event event) { + switch (event.type) { + case Event.NONE: + throw Assert.createIllegalStateFailException(); + case Event.ANSWER: + connection.setActive(); + break; + case Event.REJECT: + connection.setDisconnected(new DisconnectCause(DisconnectCause.REJECTED)); + break; + case Event.HOLD: + connection.setOnHold(); + break; + case Event.UNHOLD: + connection.setActive(); + break; + case Event.DISCONNECT: + connection.setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); + break; + case Event.SESSION_MODIFY_REQUEST: + ThreadUtil.postDelayedOnUiThread(() -> connection.handleSessionModifyRequest(event), 2000); + break; + default: + LogUtil.i("SimulatorRttCall.onEvent", "unexpected event: " + event.type); + break; + } + } +} diff --git a/java/com/android/dialer/simulator/impl/SimulatorSimCallManager.java b/java/com/android/dialer/simulator/impl/SimulatorSimCallManager.java index f28393c0c..d51e06816 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorSimCallManager.java +++ b/java/com/android/dialer/simulator/impl/SimulatorSimCallManager.java @@ -20,6 +20,7 @@ import android.content.ComponentName; import android.content.Context; import android.net.Uri; import android.os.Bundle; +import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.telecom.Connection; import android.telecom.ConnectionRequest; @@ -30,6 +31,8 @@ import android.telephony.TelephonyManager; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.strictmode.StrictModeUtils; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.List; import java.util.Random; @@ -46,10 +49,20 @@ import java.util.Random; */ public class SimulatorSimCallManager { + public static final int CALL_TYPE_VOICE = 1; + public static final int CALL_TYPE_VIDEO = 2; + public static final int CALL_TYPE_RTT = 3; + + /** Call type of a simulator call. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({CALL_TYPE_VOICE, CALL_TYPE_VIDEO, CALL_TYPE_RTT}) + public @interface CallType {} + private static final String SIM_CALL_MANAGER_ACCOUNT_ID = "SIMULATOR_ACCOUNT_ID"; private static final String VIDEO_PROVIDER_ACCOUNT_ID = "SIMULATOR_VIDEO_ACCOUNT_ID"; private static final String EXTRA_IS_SIMULATOR_CONNECTION = "is_simulator_connection"; private static final String EXTRA_CONNECTION_TAG = "connection_tag"; + private static final String EXTRA_CONNECTION_CALL_TYPE = "connection_call_type"; static void register(@NonNull Context context) { LogUtil.enterBlock("SimulatorSimCallManager.register"); @@ -75,15 +88,15 @@ public class SimulatorSimCallManager { @NonNull public static String addNewOutgoingCall( - @NonNull Context context, @NonNull String phoneNumber, boolean isVideo) { - return addNewOutgoingCall(context, phoneNumber, isVideo, new Bundle()); + @NonNull Context context, @NonNull String phoneNumber, @CallType int callType) { + return addNewOutgoingCall(context, phoneNumber, callType, new Bundle()); } @NonNull public static String addNewOutgoingCall( @NonNull Context context, @NonNull String phoneNumber, - boolean isVideo, + @CallType int callType, @NonNull Bundle extras) { LogUtil.enterBlock("SimulatorSimCallManager.addNewOutgoingCall"); Assert.isNotNull(context); @@ -94,13 +107,18 @@ public class SimulatorSimCallManager { register(context); extras = new Bundle(extras); - extras.putAll(createSimulatorConnectionExtras()); + extras.putAll(createSimulatorConnectionExtras(callType)); Bundle outgoingCallExtras = new Bundle(); outgoingCallExtras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras); outgoingCallExtras.putParcelable( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, - isVideo ? getVideoProviderHandle(context) : getSystemPhoneAccountHandle(context)); + callType == CALL_TYPE_VIDEO + ? getVideoProviderHandle(context) + : getSystemPhoneAccountHandle(context)); + if (callType == CALL_TYPE_RTT) { + outgoingCallExtras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, true); + } TelecomManager telecomManager = context.getSystemService(TelecomManager.class); try { @@ -114,13 +132,16 @@ public class SimulatorSimCallManager { @NonNull public static String addNewIncomingCall( - @NonNull Context context, @NonNull String callerId, boolean isVideo) { - return addNewIncomingCall(context, callerId, isVideo, new Bundle()); + @NonNull Context context, @NonNull String callerId, @CallType int callType) { + return addNewIncomingCall(context, callerId, callType, new Bundle()); } @NonNull public static String addNewIncomingCall( - @NonNull Context context, @NonNull String callerId, boolean isVideo, @NonNull Bundle extras) { + @NonNull Context context, + @NonNull String callerId, + @CallType int callType, + @NonNull Bundle extras) { LogUtil.enterBlock("SimulatorSimCallManager.addNewIncomingCall"); Assert.isNotNull(context); Assert.isNotNull(callerId); @@ -130,18 +151,21 @@ public class SimulatorSimCallManager { extras = new Bundle(extras); extras.putString(TelephonyManager.EXTRA_INCOMING_NUMBER, callerId); - extras.putAll(createSimulatorConnectionExtras()); + extras.putAll(createSimulatorConnectionExtras(callType)); TelecomManager telecomManager = context.getSystemService(TelecomManager.class); telecomManager.addNewIncomingCall( - isVideo ? getVideoProviderHandle(context) : getSystemPhoneAccountHandle(context), extras); + callType == CALL_TYPE_VIDEO + ? getVideoProviderHandle(context) + : getSystemPhoneAccountHandle(context), + extras); return extras.getString(EXTRA_CONNECTION_TAG); } @NonNull private static PhoneAccount buildSimCallManagerAccount(Context context) { return new PhoneAccount.Builder(getSimCallManagerHandle(context), "Simulator SIM call manager") - .setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER) + .setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER | PhoneAccount.CAPABILITY_RTT) .setShortDescription("Simulator SIM call manager") .setSupportedUriSchemes(Arrays.asList(PhoneAccount.SCHEME_TEL)) .build(); @@ -218,12 +242,16 @@ public class SimulatorSimCallManager { } @NonNull - static Bundle createSimulatorConnectionExtras() { + static Bundle createSimulatorConnectionExtras(@CallType int callType) { Bundle extras = new Bundle(); extras.putBoolean(EXTRA_IS_SIMULATOR_CONNECTION, true); String connectionTag = createUniqueConnectionTag(); extras.putString(EXTRA_CONNECTION_TAG, connectionTag); extras.putBoolean(connectionTag, true); + extras.putInt(EXTRA_CONNECTION_CALL_TYPE, callType); + if (callType == CALL_TYPE_RTT) { + extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, true); + } return extras; } diff --git a/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java b/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java index f7256a11c..0bb56f1f9 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java +++ b/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java @@ -77,7 +77,8 @@ final class SimulatorVideoCall } String callerId = "+44 (0) 20 7031 3000"; // Google London office connectionTag = - SimulatorSimCallManager.addNewIncomingCall(context, callerId, true /* isVideo */); + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_VIDEO); } private void addNewOutgoingCall() { @@ -87,7 +88,8 @@ final class SimulatorVideoCall } String phoneNumber = "+44 (0) 20 7031 3000"; // Google London office connectionTag = - SimulatorSimCallManager.addNewOutgoingCall(context, phoneNumber, true /* isVideo */); + SimulatorSimCallManager.addNewOutgoingCall( + context, phoneNumber, SimulatorSimCallManager.CALL_TYPE_VIDEO); } @Override diff --git a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java index 67a2db804..d4c7ee458 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java +++ b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java @@ -104,7 +104,10 @@ final class SimulatorVoiceCall extras.putBoolean(Simulator.IS_ENRICHED_CALL, true); connectionTag = SimulatorSimCallManager.addNewIncomingCall( - context, Simulator.ENRICHED_CALL_INCOMING_NUMBER, false, extras); + context, + Simulator.ENRICHED_CALL_INCOMING_NUMBER, + SimulatorSimCallManager.CALL_TYPE_VOICE, + extras); }, DialerExecutorComponent.get(context).uiExecutor()); } @@ -119,7 +122,10 @@ final class SimulatorVoiceCall extras.putBoolean(Simulator.IS_ENRICHED_CALL, true); connectionTag = SimulatorSimCallManager.addNewOutgoingCall( - context, Simulator.ENRICHED_CALL_OUTGOING_NUMBER, false, extras); + context, + Simulator.ENRICHED_CALL_OUTGOING_NUMBER, + SimulatorSimCallManager.CALL_TYPE_VOICE, + extras); }, DialerExecutorComponent.get(context).uiExecutor()); } @@ -127,7 +133,8 @@ final class SimulatorVoiceCall private void addNewIncomingCall() { String callerId = "+44 (0) 20 7031 3000" /* Google London office */; connectionTag = - SimulatorSimCallManager.addNewIncomingCall(context, callerId, false /* isVideo */); + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE); } private void addNewIncomingCall(AppCompatActivity activity) { @@ -137,7 +144,7 @@ final class SimulatorVoiceCall extras.putInt(Simulator.PRESENTATION_CHOICE, callerIdPresentation); connectionTag = SimulatorSimCallManager.addNewIncomingCall( - context, callerId, false /* isVideo */, extras); + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE, extras); }) .show(activity.getSupportFragmentManager(), "SimulatorDialog"); } @@ -145,7 +152,8 @@ final class SimulatorVoiceCall private void addNewOutgoingCall() { String callerId = "+55-31-2128-6800"; // Brazil office. connectionTag = - SimulatorSimCallManager.addNewOutgoingCall(context, callerId, false /* isVideo */); + SimulatorSimCallManager.addNewOutgoingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE); } private void addNewOutgoingCall(AppCompatActivity activity) { @@ -155,7 +163,7 @@ final class SimulatorVoiceCall extras.putInt(Simulator.PRESENTATION_CHOICE, callerIdPresentation); connectionTag = SimulatorSimCallManager.addNewOutgoingCall( - context, callerId, false /* isVideo */, extras); + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE, extras); }) .show(activity.getSupportFragmentManager(), "SimulatorDialog"); } @@ -163,12 +171,15 @@ final class SimulatorVoiceCall private void addSpamIncomingCall() { String callerId = "+1-661-778-3020"; /* Blacklisted custom spam number */ connectionTag = - SimulatorSimCallManager.addNewIncomingCall(context, callerId, false /* isVideo */); + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE); } private void addNewEmergencyCallBack() { String callerId = "911"; - connectionTag = SimulatorSimCallManager.addNewIncomingCall(context, callerId, false); + connectionTag = + SimulatorSimCallManager.addNewIncomingCall( + context, callerId, SimulatorSimCallManager.CALL_TYPE_VOICE); } @Override |