RESTRICT AUTOMERGE: Added an app id security check in isAppForeground.

ActivityManagerService#isAppForeground now checks if the caller has the
permission to view if an app is in the foreground.

Bug: 115384617
Test: cts-tradefed run cts -m CtsSecurityTestCases -t android.security.cts.ActivityManagerTest#testIsAppInForegroundNormal
Test: cts-tradefed run cts -m CtsSecurityTestCases -t android.security.cts.ActivityManagerTest#testIsAppInForegroundMalicious
Change-Id: I9602c89b2d40036e525c38960a08326dc74c6682
(cherry picked from commit 273eb0918a)
This commit is contained in:
Varun Shah
2018-10-26 17:03:23 -07:00
committed by android-build-team Robot
parent 77d3f39925
commit 5239804b28

View File

@@ -8768,6 +8768,14 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public boolean isAppForeground(int uid) {
int callerUid = Binder.getCallingUid();
if (UserHandle.isCore(callerUid) || callerUid == uid) {
return isAppForegroundInternal(uid);
}
return false;
}
private boolean isAppForegroundInternal(int uid) {
synchronized (this) {
UidRecord uidRec = mActiveUids.get(uid);
if (uidRec == null || uidRec.idle) {