From d8f2a8c619cadf50875b47f499f972c5494d9e5a Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 6 Jun 2018 12:26:26 -0700 Subject: Update call log cache when annotated call log is updated. If the NumberAttribute has changed the new data will be cached back to the call log. Also updated TestCallLogProvider to support selection with ID based URI. Note: currently the write will trigger an extra refresh, the next CL will address that. TEST=TAP Bug: 77292040 Test: TAP PiperOrigin-RevId: 199509348 Change-Id: I49c43adb5bcec96128d5ec36676c4569bf536490 --- java/com/android/dialer/protos/ProtoParsers.java | 35 +++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'java/com/android/dialer/protos') diff --git a/java/com/android/dialer/protos/ProtoParsers.java b/java/com/android/dialer/protos/ProtoParsers.java index e5292061b..00d5a26d2 100644 --- a/java/com/android/dialer/protos/ProtoParsers.java +++ b/java/com/android/dialer/protos/ProtoParsers.java @@ -16,6 +16,7 @@ package com.android.dialer.protos; +import android.content.ContentValues; import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; @@ -42,10 +43,27 @@ public final class ProtoParsers { return (T) mergeFrom(bytes, defaultInstance.getDefaultInstanceForType()); } + /** + * Retrieve a proto from a ContentValues which was not created within the current + * executable/version. + */ + @SuppressWarnings("unchecked") // We want to eventually optimize away parser classes, so cast + public static T get( + @NonNull ContentValues contentValues, @NonNull String key, @NonNull T defaultInstance) + throws InvalidProtocolBufferException { + + Assert.isNotNull(contentValues); + Assert.isNotNull(key); + Assert.isNotNull(defaultInstance); + + byte[] bytes = contentValues.getAsByteArray(key); + return (T) mergeFrom(bytes, defaultInstance.getDefaultInstanceForType()); + } + /** * Retrieve a proto from a trusted bundle which was created within the current executable/version. * - * @throws RuntimeException if the proto cannot be parsed + * @throws IllegalStateException if the proto cannot be parsed */ public static T getTrusted( @NonNull Bundle bundle, @NonNull String key, @NonNull T defaultInstance) { @@ -56,6 +74,21 @@ public final class ProtoParsers { } } + /** + * Retrieve a proto from a trusted ContentValues which was created within the current + * executable/version. + * + * @throws IllegalStateException if the proto cannot be parsed + */ + public static T getTrusted( + @NonNull ContentValues contentValues, @NonNull String key, @NonNull T defaultInstance) { + try { + return get(contentValues, key, defaultInstance); + } catch (InvalidProtocolBufferException e) { + throw Assert.createIllegalStateFailException(e.toString()); + } + } + /** * Retrieve a proto from a trusted bundle which was created within the current executable/version. * -- cgit v1.2.3