diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-08-31 16:17:04 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-31 16:17:04 +0000 |
commit | c39ea3c55fac807c0b98aabdf56c70dc8a49036c (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/dialer/callintent/CallIntentBuilder.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) | |
parent | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (diff) |
Merge "Update Dialer source to latest internal Google revision."
Diffstat (limited to 'java/com/android/dialer/callintent/CallIntentBuilder.java')
-rw-r--r-- | java/com/android/dialer/callintent/CallIntentBuilder.java | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/java/com/android/dialer/callintent/CallIntentBuilder.java b/java/com/android/dialer/callintent/CallIntentBuilder.java index 6066f6654..b5b680e48 100644 --- a/java/com/android/dialer/callintent/CallIntentBuilder.java +++ b/java/com/android/dialer/callintent/CallIntentBuilder.java @@ -22,11 +22,14 @@ import android.os.Bundle; import android.os.SystemClock; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.text.TextUtils; import com.android.dialer.common.Assert; +import com.android.dialer.compat.telephony.TelephonyManagerCompat; +import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.util.CallUtil; /** Creates an intent to start a new outgoing call. */ @@ -36,12 +39,41 @@ public class CallIntentBuilder { @Nullable private PhoneAccountHandle phoneAccountHandle; private boolean isVideoCall; private String callSubject; + private boolean allowAssistedDial; + + private static int lightbringerButtonAppearInExpandedCallLogItemCount = 0; + private static int lightbringerButtonAppearInCollapsedCallLogItemCount = 0; + private static int lightbringerButtonAppearInSearchCount = 0; public CallIntentBuilder(@NonNull Uri uri, @NonNull CallSpecificAppData callSpecificAppData) { this.uri = Assert.isNotNull(uri); - this.callSpecificAppData = Assert.isNotNull(callSpecificAppData); + Assert.isNotNull(callSpecificAppData); Assert.checkArgument( callSpecificAppData.getCallInitiationType() != CallInitiationType.Type.UNKNOWN_INITIATION); + + CallSpecificAppData.Builder builder = + CallSpecificAppData.newBuilder(callSpecificAppData) + .setLightbringerButtonAppearInExpandedCallLogItemCount( + lightbringerButtonAppearInExpandedCallLogItemCount) + .setLightbringerButtonAppearInCollapsedCallLogItemCount( + lightbringerButtonAppearInCollapsedCallLogItemCount) + .setLightbringerButtonAppearInSearchCount(lightbringerButtonAppearInSearchCount); + lightbringerButtonAppearInExpandedCallLogItemCount = 0; + lightbringerButtonAppearInCollapsedCallLogItemCount = 0; + lightbringerButtonAppearInSearchCount = 0; + + if (PerformanceReport.isRecording()) { + builder + .setTimeSinceAppLaunch(PerformanceReport.getTimeSinceAppLaunch()) + .setTimeSinceFirstClick(PerformanceReport.getTimeSinceFirstClick()) + .addAllUiActionsSinceAppLaunch(PerformanceReport.getActions()) + .addAllUiActionTimestampsSinceAppLaunch(PerformanceReport.getActionTimestamps()) + .setStartingTabIndex(PerformanceReport.getStartingTabIndex()) + .build(); + PerformanceReport.stopRecording(); + } + + this.callSpecificAppData = builder.build(); } public CallIntentBuilder(@NonNull Uri uri, CallInitiationType.Type callInitiationType) { @@ -71,6 +103,11 @@ public class CallIntentBuilder { return this; } + public CallIntentBuilder setAllowAssistedDial(boolean allowAssistedDial) { + this.allowAssistedDial = allowAssistedDial; + return this; + } + public CallIntentBuilder setCallSubject(String callSubject) { this.callSubject = callSubject; return this; @@ -85,6 +122,11 @@ public class CallIntentBuilder { Bundle extras = new Bundle(); extras.putLong(Constants.EXTRA_CALL_CREATED_TIME_MILLIS, SystemClock.elapsedRealtime()); CallIntentParser.putCallSpecificAppData(extras, callSpecificAppData); + + if (allowAssistedDial) { + extras.putBoolean(TelephonyManagerCompat.ALLOW_ASSISTED_DIAL, true); + } + intent.putExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras); if (phoneAccountHandle != null) { @@ -104,4 +146,38 @@ public class CallIntentBuilder { CallSpecificAppData.newBuilder().setCallInitiationType(callInitiationType).build(); return callSpecificAppData; } + + public static void increaseLightbringerCallButtonAppearInExpandedCallLogItemCount() { + CallIntentBuilder.lightbringerButtonAppearInExpandedCallLogItemCount++; + } + + public static void increaseLightbringerCallButtonAppearInCollapsedCallLogItemCount() { + CallIntentBuilder.lightbringerButtonAppearInCollapsedCallLogItemCount++; + } + + public static void increaseLightbringerCallButtonAppearInSearchCount() { + CallIntentBuilder.lightbringerButtonAppearInSearchCount++; + } + + @VisibleForTesting + public static int getLightbringerButtonAppearInExpandedCallLogItemCount() { + return lightbringerButtonAppearInExpandedCallLogItemCount; + } + + @VisibleForTesting + public static int getLightbringerButtonAppearInCollapsedCallLogItemCount() { + return lightbringerButtonAppearInCollapsedCallLogItemCount; + } + + @VisibleForTesting + public static int getLightbringerButtonAppearInSearchCount() { + return lightbringerButtonAppearInSearchCount; + } + + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + public static void clearLightbringerCounts() { + lightbringerButtonAppearInCollapsedCallLogItemCount = 0; + lightbringerButtonAppearInExpandedCallLogItemCount = 0; + lightbringerButtonAppearInSearchCount = 0; + } } |