Allow FGS started from MediaButtonReceiver to have while-in-use
permissions.
1. Create a generic FgsTempAllowList class, mFgsStartTempAllowList and
mFgsWhileInUseTempAllowList are instantiated from FgsTempAllowList.
2. For mFgsWhileInUseTempAllowList, the uid on this list is allowed to
have while-in-use permission when the FGS is started from background for
a duration of time.
3. When media button is pressed, the targetUid is added to
mFgsWhileInUseTempAllowList, for the duration of 10 seconds, this way the
targetUid can start FGS from background and have while-in-use permission.
4. When checking for ProcessRecord.
mAllowBackgroundActivityStartsTokens, it is the caller app's
ProcessRecord should be checked instead of the service's ProcessRecord.
Bug: 182481312
Test: use b/167998084 reproduce steps, make a voip call, the
receiver side screen is unlocked, the receiver side uses bluetooth
headset button to pick up the call, "dumpsys activity -a" shows the FGS
has "allowWhileInUsePermissionInFgs=true" and "isForeground=true".
Change-Id: Ic80aefe4202fe2210881bb8eea24b6e34cb1e7d0
14 files changed