diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:23:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:23:13 +0000 |
commit | 300a8683b9c28424fb0f0c571a0abe128c461f69 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/dialer/callintent/CallIntentParser.java | |
parent | d67f1627521b174f12e0c247f154c7c93c5e408e (diff) | |
parent | 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 (diff) |
Update Dialer to V10 RC16
am: 10b34a5ebf
Change-Id: Iea3e96ccdeaf1fa796ceca702cace82ca20f298c
Diffstat (limited to 'java/com/android/dialer/callintent/CallIntentParser.java')
-rw-r--r-- | java/com/android/dialer/callintent/CallIntentParser.java | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/java/com/android/dialer/callintent/CallIntentParser.java b/java/com/android/dialer/callintent/CallIntentParser.java index b54f7c78b..01afce06d 100644 --- a/java/com/android/dialer/callintent/CallIntentParser.java +++ b/java/com/android/dialer/callintent/CallIntentParser.java @@ -19,32 +19,35 @@ package com.android.dialer.callintent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.android.dialer.common.Assert; -import com.google.protobuf.InvalidProtocolBufferException; +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) { return null; } - byte[] flatArray = extras.getByteArray(Constants.EXTRA_CALL_SPECIFIC_APP_DATA); - if (flatArray == null) { - return null; - } - try { - return CallSpecificAppData.parseFrom(flatArray); - } catch (InvalidProtocolBufferException e) { - Assert.fail("unexpected exception: " + e); + if (!extras.containsKey(Constants.EXTRA_CALL_SPECIFIC_APP_DATA)) { return null; } + + return ProtoParsers.getTrusted( + extras.getBundle(Constants.EXTRA_CALL_SPECIFIC_APP_DATA), + EXTRA_CALL_SPECIFIC_APP_DATA_WRAPPER, + CallSpecificAppData.getDefaultInstance()); } public static void putCallSpecificAppData( @NonNull Bundle extras, @NonNull CallSpecificAppData callSpecificAppData) { - extras.putByteArray(Constants.EXTRA_CALL_SPECIFIC_APP_DATA, callSpecificAppData.toByteArray()); + // 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); } private CallIntentParser() {} |