diff options
author | twyen <twyen@google.com> | 2018-03-26 11:05:29 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-26 22:23:04 -0700 |
commit | e652cbf3991aad4a46ad811f370a54c1051089e0 (patch) | |
tree | 1a84176c631cccc87c584fa41e54ada1e3af36d6 /java/com/android/voicemail/impl/scheduling/Tasks.java | |
parent | 07d6d00a5cc6c1aeb1befaccc1e832b3d5b398d8 (diff) |
Catch BadParcelableException
This happens when an old dialer submitted a job and the newer dialer is trying to handle it. The class fingerprint changed so it can no longer be unparceled.
In this CL, such tasks will be dropped.
Bug: 64225192
Test: N/A
PiperOrigin-RevId: 190491751
Change-Id: I90fe2d24a435201cfae09970387e9b1c3a58b094
Diffstat (limited to 'java/com/android/voicemail/impl/scheduling/Tasks.java')
-rw-r--r-- | java/com/android/voicemail/impl/scheduling/Tasks.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/java/com/android/voicemail/impl/scheduling/Tasks.java b/java/com/android/voicemail/impl/scheduling/Tasks.java index 76da3d7f6..0333e1686 100644 --- a/java/com/android/voicemail/impl/scheduling/Tasks.java +++ b/java/com/android/voicemail/impl/scheduling/Tasks.java @@ -18,6 +18,7 @@ package com.android.voicemail.impl.scheduling; import android.content.Context; import android.content.Intent; +import android.os.BadParcelableException; import android.os.Bundle; import android.support.annotation.NonNull; import com.android.voicemail.impl.VvmLog; @@ -29,16 +30,30 @@ final class Tasks { static final String EXTRA_CLASS_NAME = "extra_class_name"; + /** The task cannot be created. */ + static final class TaskCreationException extends Exception { + TaskCreationException(Throwable throwable) { + super(throwable); + } + } + /** * Create a task from a bundle. The bundle is created either with {@link #toBundle(Task)} or * {@link #createIntent(Context, Class)} from the target {@link Task} */ @NonNull - public static Task createTask(Context context, Bundle extras) { + public static Task createTask(Context context, Bundle extras) throws TaskCreationException { // The extra contains custom parcelables which cannot be unmarshalled by the framework class // loader. extras.setClassLoader(context.getClassLoader()); - String className = extras.getString(EXTRA_CLASS_NAME); + String className; + try { + className = extras.getString(EXTRA_CLASS_NAME); + } catch (BadParcelableException e) { + // BadParcelableException:Parcelable protocol requires that the class implements Parcelable + // This happens when the task is submitted before an update, and can no longer be unparceled. + throw new TaskCreationException(e); + } VvmLog.i("Task.createTask", "create task:" + className); if (className == null) { throw new IllegalArgumentException("EXTRA_CLASS_NAME expected"); |