diff options
Diffstat (limited to 'java/com/android/dialer/callintent')
5 files changed, 141 insertions, 11 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; + } } diff --git a/java/com/android/dialer/callintent/CallIntentParser.java b/java/com/android/dialer/callintent/CallIntentParser.java index 01afce06d..336adb66b 100644 --- a/java/com/android/dialer/callintent/CallIntentParser.java +++ b/java/com/android/dialer/callintent/CallIntentParser.java @@ -19,12 +19,13 @@ package com.android.dialer.callintent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import com.android.dialer.common.LogUtil; import com.android.dialer.protos.ProtoParsers; /** Parses data for a call extra to get any dialer specific app data. */ public class CallIntentParser { - static final String EXTRA_CALL_SPECIFIC_APP_DATA_WRAPPER = - "com.android.dialer.callintent.CALL_SPECIFIC_APP_DATA_WRAPPER"; + + @Nullable public static CallSpecificAppData getCallSpecificAppData(@Nullable Bundle extras) { if (extras == null) { @@ -35,19 +36,20 @@ public class CallIntentParser { return null; } + if (extras.getByteArray(Constants.EXTRA_CALL_SPECIFIC_APP_DATA) == null) { + LogUtil.i( + "CallIntentParser.getCallSpecificAppData", + "unexpected null byte array for call specific app data proto"); + return null; + } + return ProtoParsers.getTrusted( - extras.getBundle(Constants.EXTRA_CALL_SPECIFIC_APP_DATA), - EXTRA_CALL_SPECIFIC_APP_DATA_WRAPPER, - CallSpecificAppData.getDefaultInstance()); + extras, Constants.EXTRA_CALL_SPECIFIC_APP_DATA, CallSpecificAppData.getDefaultInstance()); } public static void putCallSpecificAppData( @NonNull Bundle extras, @NonNull CallSpecificAppData callSpecificAppData) { - // We wrap our bundle for consumers that may not have access to ProtoParsers in their class - // loader. This is necessary to prevent ClassNotFoundException's - Bundle wrapperBundle = new Bundle(); - ProtoParsers.put(wrapperBundle, EXTRA_CALL_SPECIFIC_APP_DATA_WRAPPER, callSpecificAppData); - extras.putBundle(Constants.EXTRA_CALL_SPECIFIC_APP_DATA, wrapperBundle); + ProtoParsers.put(extras, Constants.EXTRA_CALL_SPECIFIC_APP_DATA, callSpecificAppData); } private CallIntentParser() {} diff --git a/java/com/android/dialer/callintent/call_initiation_type.proto b/java/com/android/dialer/callintent/call_initiation_type.proto index 994399fd9..32e4e49fc 100644 --- a/java/com/android/dialer/callintent/call_initiation_type.proto +++ b/java/com/android/dialer/callintent/call_initiation_type.proto @@ -4,9 +4,11 @@ option java_package = "com.android.dialer.callintent"; option java_multiple_files = true; option optimize_for = LITE_RUNTIME; + package com.android.dialer.callintent; + // Different ways a call can be initiated. message CallInitiationType { enum Type { @@ -56,5 +58,7 @@ message CallInitiationType { MISSED_CALL_NOTIFICATION = 15; CALL_SUBJECT_DIALOG = 16; + + IMS_VIDEO_BLOCKED_FALLBACK_TO_VOICE = 17; } } diff --git a/java/com/android/dialer/callintent/call_specific_app_data.proto b/java/com/android/dialer/callintent/call_specific_app_data.proto index 20ffc1ff4..065a7aba7 100644 --- a/java/com/android/dialer/callintent/call_specific_app_data.proto +++ b/java/com/android/dialer/callintent/call_specific_app_data.proto @@ -4,17 +4,44 @@ option java_package = "com.android.dialer.callintent"; option java_multiple_files = true; option optimize_for = LITE_RUNTIME; + package com.android.dialer.callintent; import "java/com/android/dialer/callintent/call_initiation_type.proto"; +import "java/com/android/dialer/callintent/speed_dial_contact_type.proto"; +import "java/com/android/dialer/logging/ui_action.proto"; // Miscellaneous data that's included in a new outgoing call initiated by // Dialer. The system will pass this data to the InCallUi which can use it // for logging or for something else. +// Next tag: 15 message CallSpecificAppData { optional CallInitiationType.Type call_initiation_type = 1; optional int32 position_of_selected_search_result = 2; optional int32 characters_in_search_string = 3; + + repeated SpeedDialContactType.Type speed_dial_contact_type = 4; + optional int32 speed_dial_contact_position = 5; + + optional int64 time_since_app_launch = 6; + optional int64 time_since_first_click = 7; + // The following two list should be of the same length + // (adding another message is not allowed here) + repeated com.android.dialer.logging.UiAction.Type + ui_actions_since_app_launch = 8; + repeated int64 ui_action_timestamps_since_app_launch = 9; + + optional int32 starting_tab_index = 10; + + // For recording the appearance of video call button + optional int32 lightbringer_button_appear_in_expanded_call_log_item_count = + 11; + optional int32 lightbringer_button_appear_in_collapsed_call_log_item_count = + 12; + optional int32 lightbringer_button_appear_in_search_count = 13; + + // Indicates that the call is open to modification from assisted dialing. + optional bool allow_assisted_dialing = 14; } diff --git a/java/com/android/dialer/callintent/speed_dial_contact_type.proto b/java/com/android/dialer/callintent/speed_dial_contact_type.proto new file mode 100644 index 000000000..ecb1c3f28 --- /dev/null +++ b/java/com/android/dialer/callintent/speed_dial_contact_type.proto @@ -0,0 +1,21 @@ +syntax = "proto2"; + +option java_package = "com.android.dialer.callintent"; +option java_multiple_files = true; +option optimize_for = LITE_RUNTIME; + + +package com.android.dialer.callintent; + + + +// The type of speed call contact (favorites). Applies to initiation type +// SPEED_DIAL only. +message SpeedDialContactType { + enum Type { + UNDEFINED = 0; + PINNED_CONTACT = 1; + STARRED_CONTACT = 2; + FREQUENT_CONTACT = 3; + } +} |