OSDN Git Service

Merge tag 'android-8.1.0_r76' into oreo-x86
[android-x86/frameworks-base.git] / services / core / java / com / android / server / am / ActivityManagerService.java
index a2126a2..87bad5c 100644 (file)
@@ -8032,6 +8032,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) {