Merge "RESTRICT AUTOMERGE: Added an app id security check in isAppForeground." into oc-dev am: 546ba589a2
am: 84376cb95a
Change-Id: I096470de6d03ab34591b12bc7172056a1ffe38ed
This commit is contained in:
@@ -131,6 +131,19 @@ public final class UserHandle implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a UID belongs to a system core component or not.
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isCore(int uid) {
|
||||
if (uid >= 0) {
|
||||
final int appId = getAppId(uid);
|
||||
return appId < Process.FIRST_APPLICATION_UID;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user for a given uid.
|
||||
* @param uid A uid for an application running in a particular user.
|
||||
|
||||
@@ -8021,6 +8021,14 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
|
||||
@Override
|
||||
public boolean isAppForeground(int uid) throws RemoteException {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user