diff options
author | twyen <twyen@google.com> | 2018-06-06 12:26:26 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-06 14:02:32 -0700 |
commit | d8f2a8c619cadf50875b47f499f972c5494d9e5a (patch) | |
tree | f003de388990154f153b99220f6d1fc71215fc0a /java/com/android/dialer/protos | |
parent | 6b41e3a0c6024b4afb7cef10973d95d6d0daf294 (diff) |
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
Diffstat (limited to 'java/com/android/dialer/protos')
-rw-r--r-- | java/com/android/dialer/protos/ProtoParsers.java | 35 |
1 files changed, 34 insertions, 1 deletions
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; @@ -43,9 +44,26 @@ public final class ProtoParsers { } /** + * 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 extends MessageLite> 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 extends MessageLite> T getTrusted( @NonNull Bundle bundle, @NonNull String key, @NonNull T defaultInstance) { @@ -57,6 +75,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 extends MessageLite> 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. * * @throws RuntimeException if the proto cannot be parsed |