Allow FGS started from MediaButtonReceiver to have while-in-use
permissions.

1. Create FgsWhileInUseTempAllowList, 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.
2. When media button is pressed, the targetUid is added to
FgsWhileInUseTempAllowList for the duration of 10 seconds, this way the
targetUid can start FGS from background and have while-in-use permission.
3. 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, use Line app to 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
"com.linecorp.voip.core.common.notification.VoipNotificationCommand" has
"allowWhileInUsePermissionInFgs=true" and "isForeground=true".

Change-Id: Ic80aefe4202fe2210881bb8eea24b6e34cb1e7d0
Merged-In: I32a14d675550cd262976bb8e16a48a070387d318
8 files changed