From df36d8f1c6ef91646fdbf169ec2c6cc9edcc8e3c Mon Sep 17 00:00:00 2001 From: zachh Date: Fri, 30 Mar 2018 12:16:43 -0700 Subject: Added logging for popping in new call log. Bug: 70989667 Test: unit PiperOrigin-RevId: 191099351 Change-Id: I47f1e487e2a0cc23af7b39ae89e20abf993933ea --- .../android/dialer/calllog/ui/NewCallLogAdapter.java | 20 +++++++++++++++++++- .../dialer/calllog/ui/NewCallLogFragment.java | 9 +++++++++ .../dialer/calllog/ui/NewCallLogViewHolder.java | 10 +++++++++- .../dialer/calllog/ui/RealtimeRowProcessor.java | 8 +++++++- java/com/android/dialer/logging/LoggingBindings.java | 3 +++ .../android/dialer/logging/LoggingBindingsStub.java | 3 +++ 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java index 05a339978..839ba332f 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java @@ -25,6 +25,7 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import com.android.dialer.calllogutils.CallLogDates; import com.android.dialer.common.Assert; +import com.android.dialer.logging.Logger; import com.android.dialer.time.Clock; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -53,6 +54,7 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { private final Clock clock; private final RealtimeRowProcessor realtimeRowProcessor; + private final PopCounts popCounts = new PopCounts(); private Cursor cursor; @@ -76,6 +78,7 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { void updateCursor(Cursor updatedCursor) { this.cursor = updatedCursor; this.realtimeRowProcessor.clearCache(); + this.popCounts.reset(); setHeaderPositions(); notifyDataSetChanged(); @@ -85,6 +88,10 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { this.realtimeRowProcessor.clearCache(); } + void logMetrics(Context context) { + Logger.get(context).logAnnotatedCallLogMetrics(popCounts.popped, popCounts.didNotPop); + } + private void setHeaderPositions() { // If there are no rows to display, set all header positions to null. if (!cursor.moveToFirst()) { @@ -138,7 +145,8 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.new_call_log_entry, viewGroup, false), clock, - realtimeRowProcessor); + realtimeRowProcessor, + popCounts); default: throw Assert.createUnsupportedOperationFailException("Unsupported view type: " + viewType); } @@ -207,4 +215,14 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { } return cursor.getCount() + numberOfHeaders; } + + static class PopCounts { + int popped; + int didNotPop; + + private void reset() { + popped = 0; + didNotPop = 0; + } + } } diff --git a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java index bb1a7303e..0f1c2510a 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java @@ -88,6 +88,15 @@ public final class NewCallLogFragment extends Fragment implements LoaderCallback } } + @Override + public void onStop() { + super.onStop(); + + if (recyclerView.getAdapter() != null) { + ((NewCallLogAdapter) recyclerView.getAdapter()).logMetrics(getContext()); + } + } + @Override public void onPause() { super.onPause(); diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index f322b562b..1f84ebfdf 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -27,6 +27,7 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.android.dialer.calllog.model.CoalescedRow; +import com.android.dialer.calllog.ui.NewCallLogAdapter.PopCounts; import com.android.dialer.calllog.ui.menu.NewCallLogMenu; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; @@ -60,10 +61,12 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { private final Clock clock; private final RealtimeRowProcessor realtimeRowProcessor; private final ExecutorService uiExecutorService; + private final PopCounts popCounts; private long currentRowId; - NewCallLogViewHolder(View view, Clock clock, RealtimeRowProcessor realtimeRowProcessor) { + NewCallLogViewHolder( + View view, Clock clock, RealtimeRowProcessor realtimeRowProcessor, PopCounts popCounts) { super(view); this.context = view.getContext(); contactPhotoView = view.findViewById(R.id.contact_photo_view); @@ -79,6 +82,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { this.clock = clock; this.realtimeRowProcessor = realtimeRowProcessor; + this.popCounts = popCounts; uiExecutorService = DialerExecutorComponent.get(context).uiExecutor(); } @@ -258,13 +262,17 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { // If the user scrolled then this ViewHolder may not correspond to the completed task and // there's nothing to do. if (originalRow.getId() != currentRowId) { + popCounts.didNotPop++; return; } // Only update the UI if the updated row differs from the original row (which has already // been displayed). if (!updatedRow.equals(originalRow)) { displayRow(updatedRow); + popCounts.popped++; + return; } + popCounts.didNotPop++; } @Override diff --git a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java index b955e029b..c5148d93e 100644 --- a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java +++ b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java @@ -198,8 +198,14 @@ public final class RealtimeRowProcessor { private CoalescedRow applyPhoneLookupInfoToRow( PhoneLookupInfo phoneLookupInfo, CoalescedRow row) { + // Force the "cp2_info_incomplete" value to the original value so that it is not used when + // comparing the original row to the updated row. + // TODO(linyuh): Improve the comparison instead. return row.toBuilder() - .setNumberAttributes(NumberAttributesConverter.fromPhoneLookupInfo(phoneLookupInfo).build()) + .setNumberAttributes( + NumberAttributesConverter.fromPhoneLookupInfo(phoneLookupInfo) + .setIsCp2InfoIncomplete(row.getNumberAttributes().getIsCp2InfoIncomplete()) + .build()) .build(); } } diff --git a/java/com/android/dialer/logging/LoggingBindings.java b/java/com/android/dialer/logging/LoggingBindings.java index 27cedf6da..7c580cb77 100644 --- a/java/com/android/dialer/logging/LoggingBindings.java +++ b/java/com/android/dialer/logging/LoggingBindings.java @@ -93,4 +93,7 @@ public interface LoggingBindings { /** Logs annotated call log metrics. */ void logAnnotatedCallLogMetrics(int invalidNumbersInCallLog); + + /** Logs annotated call log metrics. */ + void logAnnotatedCallLogMetrics(int numberRowsThatDidPop, int numberRowsThatDidNotPop); } diff --git a/java/com/android/dialer/logging/LoggingBindingsStub.java b/java/com/android/dialer/logging/LoggingBindingsStub.java index 76f22803d..65ebd1a52 100644 --- a/java/com/android/dialer/logging/LoggingBindingsStub.java +++ b/java/com/android/dialer/logging/LoggingBindingsStub.java @@ -67,4 +67,7 @@ public class LoggingBindingsStub implements LoggingBindings { @Override public void logAnnotatedCallLogMetrics(int invalidNumbersInCallLog) {} + + @Override + public void logAnnotatedCallLogMetrics(int numberRowsThatDidPop, int numberRowsThatDidNotPop) {} } -- cgit v1.2.3