From c3a9008e3d8d45c754a4ad6733984d95fd1c4e2b Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Thu, 16 Jun 2016 10:03:27 -0700 Subject: [PATCH] Add non-parcelable extras to notification to make sure it does not crash the app. BUG: 29402928 Change-Id: I4fc47535ae14e71c50b25285b2fe5375abdb4f11 --- .../cts/net/hostside/app2/MyBroadcastReceiver.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyBroadcastReceiver.java b/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyBroadcastReceiver.java index 96e9d2bab4..60e5de1b9a 100644 --- a/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyBroadcastReceiver.java +++ b/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyBroadcastReceiver.java @@ -31,6 +31,7 @@ import static com.android.cts.net.hostside.app2.Common.TAG; import static com.android.cts.net.hostside.app2.Common.getUid; import android.app.Notification; +import android.app.Notification.Action; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -39,6 +40,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Bundle; import android.util.Log; import java.net.HttpURLConnection; @@ -230,12 +232,18 @@ public class MyBroadcastReceiver extends BroadcastReceiver { final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); final Intent serviceIntent = new Intent(context, MyService.class); final PendingIntent pendingIntent = PendingIntent.getService(context, 0, serviceIntent, 0); + final Bundle badBundle = new Bundle(); + badBundle.putCharSequence("parcelable", "I am not"); + final Action action = new Action.Builder( + R.drawable.ic_notification, "ACTION", pendingIntent) + .addExtras(badBundle) + .build(); final Notification notification = new Notification.Builder(context) .setSmallIcon(R.drawable.ic_notification) .setContentTitle("Light, Cameras...") .setContentIntent(pendingIntent) - .addAction(R.drawable.ic_notification, "ACTION", pendingIntent) + .addAction(action) .build(); ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(notificationId, notification);