Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32e71181 authored by Yi-Ling Chuang's avatar Yi-Ling Chuang
Browse files

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
parent c0f50f59
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ public class BluetoothDevicesSlice implements CustomSliceable {
        return PendingIntent
                .getActivity(mContext, device.hashCode() /* requestCode */,
                        subSettingLauncher.toIntent(),
                        0  /* flags */);
                        PendingIntent.FLAG_IMMUTABLE);
    }

    @VisibleForTesting
@@ -236,7 +236,8 @@ public class BluetoothDevicesSlice implements CustomSliceable {
                .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 @@ public class BluetoothDevicesSlice implements CustomSliceable {
        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 @@ public class BluetoothDevicesSlice implements CustomSliceable {
                .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 @@ public class BluetoothDevicesSlice implements CustomSliceable {
                .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());
+2 −1
Original line number Diff line number Diff line
@@ -97,7 +97,8 @@ public class BluetoothDevicesSliceTest {
        // 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());