Add non-parcelable extras to notification to make sure it does not crash
the app.
BUG: 29402928
Change-Id: I4fc47535ae14e71c50b25285b2fe5375abdb4f11
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 96e9d2b..60e5de1 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.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.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 @@
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);