Merge "Exempt callingUid that has START_ACTIVITIES_FROM_BACKGROUND permission." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
44a56296cb
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.am;
|
package com.android.server.am;
|
||||||
|
|
||||||
|
import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND;
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION;
|
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION;
|
||||||
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
|
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
|
||||||
@@ -692,8 +693,8 @@ public final class ActiveServices {
|
|||||||
|
|
||||||
if (!r.mAllowWhileInUsePermissionInFgs) {
|
if (!r.mAllowWhileInUsePermissionInFgs) {
|
||||||
r.mAllowWhileInUsePermissionInFgs =
|
r.mAllowWhileInUsePermissionInFgs =
|
||||||
shouldAllowWhileInUsePermissionInFgsLocked(callingPackage, callingUid,
|
shouldAllowWhileInUsePermissionInFgsLocked(callingPackage, callingPid,
|
||||||
service, r, allowBackgroundActivityStarts);
|
callingUid, service, r, allowBackgroundActivityStarts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmp;
|
return cmp;
|
||||||
@@ -2077,9 +2078,9 @@ public final class ActiveServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!s.mAllowWhileInUsePermissionInFgs) {
|
if (!s.mAllowWhileInUsePermissionInFgs) {
|
||||||
final int callingUid = Binder.getCallingUid();
|
|
||||||
s.mAllowWhileInUsePermissionInFgs =
|
s.mAllowWhileInUsePermissionInFgs =
|
||||||
shouldAllowWhileInUsePermissionInFgsLocked(callingPackage, callingUid,
|
shouldAllowWhileInUsePermissionInFgsLocked(callingPackage,
|
||||||
|
Binder.getCallingPid(), Binder.getCallingUid(),
|
||||||
service, s, false);
|
service, s, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4839,7 +4840,8 @@ public final class ActiveServices {
|
|||||||
* @return true if allow, false otherwise.
|
* @return true if allow, false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean shouldAllowWhileInUsePermissionInFgsLocked(String callingPackage,
|
private boolean shouldAllowWhileInUsePermissionInFgsLocked(String callingPackage,
|
||||||
int callingUid, Intent intent, ServiceRecord r, boolean allowBackgroundActivityStarts) {
|
int callingPid, int callingUid, Intent intent, ServiceRecord r,
|
||||||
|
boolean allowBackgroundActivityStarts) {
|
||||||
// Is the background FGS start restriction turned on?
|
// Is the background FGS start restriction turned on?
|
||||||
if (!mAm.mConstants.mFlagBackgroundFgsStartRestrictionEnabled) {
|
if (!mAm.mConstants.mFlagBackgroundFgsStartRestrictionEnabled) {
|
||||||
return true;
|
return true;
|
||||||
@@ -4849,13 +4851,6 @@ public final class ActiveServices {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the service in a whitelist?
|
|
||||||
final boolean hasAllowBackgroundActivityStartsToken = r.app != null
|
|
||||||
? r.app.mAllowBackgroundActivityStartsTokens.contains(r) : false;
|
|
||||||
if (hasAllowBackgroundActivityStartsToken) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isCallerSystem = false;
|
boolean isCallerSystem = false;
|
||||||
final int callingAppId = UserHandle.getAppId(callingUid);
|
final int callingAppId = UserHandle.getAppId(callingUid);
|
||||||
switch (callingAppId) {
|
switch (callingAppId) {
|
||||||
@@ -4874,6 +4869,11 @@ public final class ActiveServices {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mAm.checkPermission(START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid)
|
||||||
|
== PERMISSION_GRANTED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Is the calling UID at PROCESS_STATE_TOP or above?
|
// Is the calling UID at PROCESS_STATE_TOP or above?
|
||||||
final boolean isCallingUidTopApp = appIsTopLocked(callingUid);
|
final boolean isCallingUidTopApp = appIsTopLocked(callingUid);
|
||||||
if (isCallingUidTopApp) {
|
if (isCallingUidTopApp) {
|
||||||
|
|||||||
Reference in New Issue
Block a user