From b6746eb926b95c51cac718d89c9ca9bbcbb4998c Mon Sep 17 00:00:00 2001 From: roldenburg Date: Thu, 14 Dec 2017 13:15:10 -0800 Subject: Add impressions for Duo related events (install, activate and invite) Bug: 70034799 Test: GoogleCallLogAdapterTest PiperOrigin-RevId: 179085188 Change-Id: I7546cf7e35bbdd3788b03d19627d9a04f612335f --- .../app/calllog/CallLogListItemViewHolder.java | 119 +++++++++++++-------- .../android/dialer/app/calllog/IntentProvider.java | 7 +- 2 files changed, 80 insertions(+), 46 deletions(-) (limited to 'java/com/android/dialer/app/calllog') diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index a6489cdd3..922a086bd 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -922,7 +922,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder Logger.get(mContext).logImpression(DialerImpression.Type.VOICEMAIL_PLAY_AUDIO_DIRECTLY); mVoicemailPrimaryActionButtonClicked = true; mExpandCollapseListener.onClick(primaryActionView); - } else if (view.getId() == R.id.call_with_note_action) { + return; + } + + if (view.getId() == R.id.call_with_note_action) { CallSubjectDialog.start( (Activity) mContext, info.photoId, @@ -935,7 +938,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder numberType, /* phone number type (e.g. mobile) in second line of contact view */ getContactType(), accountHandle); - } else if (view.getId() == R.id.block_report_action) { + return; + } + + if (view.getId() == R.id.block_report_action) { Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_REPORT_SPAM); maybeShowBlockNumberMigrationDialog( new BlockedNumbersMigrator.Listener() { @@ -945,7 +951,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder displayNumber, number, countryIso, callType, info.sourceType); } }); - } else if (view.getId() == R.id.block_action) { + return; + } + + if (view.getId() == R.id.block_action) { Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_NUMBER); maybeShowBlockNumberMigrationDialog( new BlockedNumbersMigrator.Listener() { @@ -955,63 +964,72 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder displayNumber, number, countryIso, callType, info.sourceType); } }); - } else if (view.getId() == R.id.unblock_action) { + return; + } + + if (view.getId() == R.id.unblock_action) { Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_UNBLOCK_NUMBER); mBlockReportListener.onUnblock( displayNumber, number, countryIso, callType, info.sourceType, isSpam, blockId); - } else if (view.getId() == R.id.report_not_spam_action) { + return; + } + + if (view.getId() == R.id.report_not_spam_action) { Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_REPORT_AS_NOT_SPAM); mBlockReportListener.onReportNotSpam( displayNumber, number, countryIso, callType, info.sourceType); - } else if (view.getId() == R.id.call_compose_action) { + return; + } + + if (view.getId() == R.id.call_compose_action) { LogUtil.i("CallLogListItemViewHolder.onClick", "share and call pressed"); Logger.get(mContext).logImpression(DialerImpression.Type.CALL_LOG_SHARE_AND_CALL); Activity activity = (Activity) mContext; activity.startActivityForResult( CallComposerActivity.newIntent(activity, buildContact()), ActivityRequestCodes.DIALTACTS_CALL_COMPOSER); - } else if (view.getId() == R.id.share_voicemail) { + return; + } + + if (view.getId() == R.id.share_voicemail) { Logger.get(mContext).logImpression(DialerImpression.Type.VVM_SHARE_PRESSED); mVoicemailPlaybackPresenter.shareVoicemail(); - } else { - logCallLogAction(view.getId()); + return; + } - final IntentProvider intentProvider = (IntentProvider) view.getTag(); - if (intentProvider == null) { - return; - } + logCallLogAction(view.getId()); - final Intent intent = intentProvider.getIntent(mContext); - // See IntentProvider.getCallDetailIntentProvider() for why this may be null. - if (intent == null) { - return; - } + final IntentProvider intentProvider = (IntentProvider) view.getTag(); + if (intentProvider == null) { + return; + } - // We check to see if we are starting a Duo intent. The reason is Duo - // intents need to be started using startActivityForResult instead of the usual startActivity - String packageName = intent.getPackage(); - if (DuoConstants.PACKAGE_NAME.equals(packageName)) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_CALL_LOG); - if (isNonContactEntry(info)) { - Logger.get(mContext) - .logImpression( - DialerImpression.Type.LIGHTBRINGER_NON_CONTACT_VIDEO_REQUESTED_FROM_CALL_LOG); - } - startDuoActivity(intent); - } else if (CallDetailsActivity.isLaunchIntent(intent)) { - PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_DETAIL); - ((Activity) mContext) - .startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_CALL_DETAILS); - } else { - if (Intent.ACTION_CALL.equals(intent.getAction()) - && intent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, -1) - == VideoProfile.STATE_BIDIRECTIONAL) { - Logger.get(mContext) - .logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_CALL_LOG); - } - DialerUtils.startActivityWithErrorToast(mContext, intent); + final Intent intent = intentProvider.getIntent(mContext); + // See IntentProvider.getCallDetailIntentProvider() for why this may be null. + if (intent == null) { + return; + } + + // We check to see if we are starting a Duo intent. The reason is Duo + // intents need to be started using startActivityForResult instead of the usual startActivity + String packageName = intent.getPackage(); + if (DuoConstants.PACKAGE_NAME.equals(packageName)) { + startDuoActivity(intent); + } else if (CallDetailsActivity.isLaunchIntent(intent)) { + PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_DETAIL); + ((Activity) mContext) + .startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_CALL_DETAILS); + } else { + if (Intent.ACTION_CALL.equals(intent.getAction()) + && intent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, -1) + == VideoProfile.STATE_BIDIRECTIONAL) { + Logger.get(mContext).logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_CALL_LOG); } + if (intent.getDataString().contains(DuoConstants.PACKAGE_NAME)) { + Logger.get(mContext).logImpression(DialerImpression.Type.DUO_CALL_LOG_SET_UP_INSTALL); + } + + DialerUtils.startActivityWithErrorToast(mContext, intent); } } @@ -1023,6 +1041,23 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } private void startDuoActivity(Intent intent) { + if (DuoConstants.DUO_ACTIVATE_ACTION.equals(intent.getAction())) { + Logger.get(mContext).logImpression(DialerImpression.Type.DUO_CALL_LOG_SET_UP_ACTIVATE); + } else if (DuoConstants.DUO_INVITE_ACTION.equals(intent.getAction())) { + Logger.get(mContext).logImpression(DialerImpression.Type.DUO_CALL_LOG_INVITE); + } else if (DuoConstants.DUO_CALL_ACTION.equals(intent.getAction())) { + Logger.get(mContext) + .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_CALL_LOG); + if (isNonContactEntry(info)) { + Logger.get(mContext) + .logImpression( + DialerImpression.Type.LIGHTBRINGER_NON_CONTACT_VIDEO_REQUESTED_FROM_CALL_LOG); + } + } else { + throw Assert.createIllegalStateFailException( + "Duo intent with invalid action" + intent.getAction()); + } + try { Activity activity = (Activity) mContext; activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); diff --git a/java/com/android/dialer/app/calllog/IntentProvider.java b/java/com/android/dialer/app/calllog/IntentProvider.java index c86a2603d..3a07a6fa0 100644 --- a/java/com/android/dialer/app/calllog/IntentProvider.java +++ b/java/com/android/dialer/app/calllog/IntentProvider.java @@ -114,7 +114,7 @@ public abstract class IntentProvider { .scheme("https") .authority("play.google.com") .appendEncodedPath("store/apps/details") - .appendQueryParameter("id", "com.google.android.apps.tachyon") + .appendQueryParameter("id", DuoConstants.PACKAGE_NAME) .appendQueryParameter( "referrer", "utm_source=dialer&utm_medium=text&utm_campaign=product") // This string is from @@ -128,8 +128,7 @@ public abstract class IntentProvider { return new IntentProvider() { @Override public Intent getIntent(Context context) { - return new Intent("com.google.android.apps.tachyon.action.REGISTER") - .setPackage(DuoConstants.PACKAGE_NAME); + return new Intent(DuoConstants.DUO_ACTIVATE_ACTION).setPackage(DuoConstants.PACKAGE_NAME); } }; } @@ -139,7 +138,7 @@ public abstract class IntentProvider { @Override public Intent getIntent(Context context) { Intent intent = - new Intent("com.google.android.apps.tachyon.action.INVITE") + new Intent(DuoConstants.DUO_INVITE_ACTION) .setPackage(DuoConstants.PACKAGE_NAME) .setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null /* fragment */)); return intent; -- cgit v1.2.3