Use setIdentifier instead of dynamic categories

Change I27987301ebf393de6f781b17ed7bc789789c01ab introduced the usage of
dynamic categories to prevent the pending intent from being cached. This
is incompatible with the new T explicit intent filter enforcement, as a
dynamic category can never match any intent-filter.

Switch to use the PendingIntent#setIdentifier API introduced in API 29,
specifically designed for this use case.

Bug: 249043995
Test: m + manual
Change-Id: I2bbe4e554ef337299138f2a7691eeffc60e18e9d
This commit is contained in:
John Wu
2022-09-27 17:11:32 +00:00
parent a7a5684201
commit 8afc387eb1

View File

@@ -290,7 +290,7 @@ public class InstantAppNotifier
.setComponent(aiaComponent)
.setAction(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.addCategory("unique:" + System.currentTimeMillis())
.setIdentifier("unique:" + System.currentTimeMillis())
.putExtra(Intent.EXTRA_PACKAGE_NAME, appInfo.packageName)
.putExtra(
Intent.EXTRA_VERSION_CODE,