Add the mutability flag to BluetoothDevicesSlice.

Starting Android S, all PendingIntent has to have a explicit mutability
flag set.

Fixes: 172207505
Fixes: 172811893
Test: Enable BluetoothDevicesSlice and play on it.
Play on the volume panel.

Change-Id: I618455de683d619fe300309e31864b3c64f12ad1
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 19de403..bfdd13a 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -206,7 +206,7 @@
         return PendingIntent
                 .getActivity(mContext, device.hashCode() /* requestCode */,
                         subSettingLauncher.toIntent(),
-                        0  /* flags */);
+                        PendingIntent.FLAG_IMMUTABLE);
     }
 
     @VisibleForTesting
@@ -236,7 +236,8 @@
                 .setClass(mContext, SliceBroadcastReceiver.class)
                 .putExtra(EXTRA_ENABLE_BLUETOOTH, true);
         final SliceAction action = SliceAction.create(PendingIntent.getBroadcast(mContext,
-                0 /* requestCode */, intent, 0 /* flags */), icon, ListBuilder.ICON_IMAGE, title);
+                0 /* requestCode */, intent, PendingIntent.FLAG_IMMUTABLE), icon,
+                ListBuilder.ICON_IMAGE, title);
 
         return new ListBuilder.RowBuilder()
                 .setTitleItem(icon, ListBuilder.ICON_IMAGE)
@@ -252,7 +253,7 @@
         final IconCompat icon = Utils.createIconWithDrawable(drawable);
         final CharSequence title = mContext.getText(R.string.bluetooth_devices);
         final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext,
-                0 /* requestCode */, getIntent(), 0 /* flags */);
+                0 /* requestCode */, getIntent(), PendingIntent.FLAG_IMMUTABLE);
         final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryActionIntent, icon,
                 ListBuilder.ICON_IMAGE, title);
 
@@ -274,7 +275,7 @@
                 .setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING)
                 .toIntent();
         final PendingIntent pi = PendingIntent.getActivity(mContext, intent.hashCode(), intent,
-                0 /* flags */);
+                PendingIntent.FLAG_IMMUTABLE);
         return SliceAction.createDeeplink(pi, icon, ListBuilder.ICON_IMAGE, title);
     }
 
@@ -341,7 +342,8 @@
                 .putExtra(BLUETOOTH_DEVICE_HASH_CODE, bluetoothDevice.hashCode());
 
         return SliceAction.create(
-                PendingIntent.getBroadcast(mContext, bluetoothDevice.hashCode(), intent, 0),
+                PendingIntent.getBroadcast(mContext, bluetoothDevice.hashCode(), intent,
+                        PendingIntent.FLAG_IMMUTABLE),
                 getBluetoothDeviceIcon(bluetoothDevice),
                 ListBuilder.ICON_IMAGE,
                 bluetoothDevice.getName());
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index e139469..cbd4390 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -97,7 +97,8 @@
         // Mock the icon and detail intent of Bluetooth.
         mIcon = IconCompat.createWithResource(mContext,
                 com.android.internal.R.drawable.ic_settings_bluetooth);
-        mDetailIntent = PendingIntent.getActivity(mContext, 0, new Intent("test action"), 0);
+        mDetailIntent = PendingIntent.getActivity(mContext, 0, new Intent("test action"),
+                PendingIntent.FLAG_IMMUTABLE);
         doReturn(mIcon).when(mBluetoothDevicesSlice).getBluetoothDeviceIcon(any());
         doReturn(mDetailIntent).when(mBluetoothDevicesSlice).getBluetoothDetailIntent(any());