Skip to content

Commit d2a8df9

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #7097984 java.lang.SecurityException: Permission Denial:" into jb-mr1-dev
2 parents 34a75df + b8839dd commit d2a8df9

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
import java.util.List;
154154
import java.util.Locale;
155155
import java.util.Map;
156-
import java.util.Map.Entry;
157156
import java.util.Set;
158157
import java.util.concurrent.atomic.AtomicBoolean;
159158
import java.util.concurrent.atomic.AtomicLong;
@@ -3571,15 +3570,32 @@ public void killApplicationWithUid(String pkg, int uid) {
35713570
public void closeSystemDialogs(String reason) {
35723571
enforceNotIsolatedCaller("closeSystemDialogs");
35733572

3573+
final int pid = Binder.getCallingPid();
35743574
final int uid = Binder.getCallingUid();
35753575
final long origId = Binder.clearCallingIdentity();
3576-
synchronized (this) {
3577-
closeSystemDialogsLocked(uid, reason);
3576+
try {
3577+
synchronized (this) {
3578+
// Only allow this from foreground processes, so that background
3579+
// applications can't abuse it to prevent system UI from being shown.
3580+
if (uid >= Process.FIRST_APPLICATION_UID) {
3581+
ProcessRecord proc;
3582+
synchronized (mPidsSelfLocked) {
3583+
proc = mPidsSelfLocked.get(pid);
3584+
}
3585+
if (proc.curRawAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
3586+
Slog.w(TAG, "Ignoring closeSystemDialogs " + reason
3587+
+ " from background process " + proc);
3588+
return;
3589+
}
3590+
}
3591+
closeSystemDialogsLocked(reason);
3592+
}
3593+
} finally {
3594+
Binder.restoreCallingIdentity(origId);
35783595
}
3579-
Binder.restoreCallingIdentity(origId);
35803596
}
35813597

3582-
void closeSystemDialogsLocked(int callingUid, String reason) {
3598+
void closeSystemDialogsLocked(String reason) {
35833599
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
35843600
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
35853601
if (reason != null) {
@@ -3595,14 +3611,9 @@ void closeSystemDialogsLocked(int callingUid, String reason) {
35953611
}
35963612
}
35973613

3598-
final long origId = Binder.clearCallingIdentity();
3599-
try {
3600-
broadcastIntentLocked(null, null, intent, null,
3601-
null, 0, null, null, null, false, false, -1,
3602-
callingUid, UserHandle.USER_ALL);
3603-
} finally {
3604-
Binder.restoreCallingIdentity(origId);
3605-
}
3614+
broadcastIntentLocked(null, null, intent, null,
3615+
null, 0, null, null, null, false, false, -1,
3616+
Process.SYSTEM_UID, UserHandle.USER_ALL);
36063617
}
36073618

36083619
public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)

0 commit comments

Comments
 (0)