Add the explicitly mutable flag for creating a PendingIntent

- Android S+ to specify explicitly either FLAG_MUTABLE or FLAG_IMMUTABLE
  when creating a PendingIntent.
- Suggest to use the FLAG_IMMUTABLE as default. Change it to
  FLAG_MUTABLE while errors occur.

Fixes: 172207262
Fixes: 172207195
Fixes: 172205385
Fixes: 172204525
Fixes: 172205897
Test: build pass, manual test to paring blutooth device and doing
seamless transfer

Change-Id: Ic37b37bdbe6de6bdbad741985d3a920334240d80
This commit is contained in:
Hugh Chen
2020-11-03 12:08:45 +08:00
parent 5f5d754af2
commit 40d4e47b05
5 changed files with 21 additions and 12 deletions

View File

@@ -127,10 +127,12 @@ public final class BluetoothPairingService extends Service {
PendingIntent pairIntent = PendingIntent.getActivity(this, 0,
getPairingDialogIntent(this, intent,
BluetoothDevice.EXTRA_PAIRING_INITIATOR_BACKGROUND),
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT
| PendingIntent.FLAG_IMMUTABLE);
PendingIntent dismissIntent = PendingIntent.getBroadcast(this, 0,
new Intent(ACTION_DISMISS_PAIRING), PendingIntent.FLAG_ONE_SHOT);
new Intent(ACTION_DISMISS_PAIRING), PendingIntent.FLAG_ONE_SHOT
| PendingIntent.FLAG_IMMUTABLE);
mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);