public void closeSystemDialogs(String reason) { enforceNotIsolatedCaller("closeSystemDialogs"); final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); final long origId = Binder.clearCallingIdentity(); try { synchronized (mGlobalLock) { Log.d(TAG, "hyj 6811 activitytaskmanagerservice ") // Only allow this from foreground processes, so that background // applications can't abuse it to prevent system UI from being shown. if (uid >= FIRST_APPLICATION_UID) { final WindowProcessController proc = mProcessMap.getProcess(pid); Log.d(TAG, "hyj 6817 activitytaskmanagerservice ") if (!proc.isPerceptible()) { Log.d(TAG, "hyj 6818 activitytaskmanagerservice ") Slog.w(TAG, "Ignoring closeSystemDialogs " + reason + " from background process " + proc); return; } } mWindowManager.closeSystemDialogs(reason); Log.d(TAG, "hyj 6825 activitytaskmanagerservice ") mRootWindowContainer.closeSystemDialogActivities(reason); } // Call into AM outside the synchronized block. Log.d(TAG, "hyj 6829 activitytaskmanagerservice") mAmInternal.broadcastCloseSystemDialogs(reason); } finally { Binder.restoreCallingIdentity(origId); } } 这段代码是什么作用
时间: 2024-02-10 21:18:14 浏览: 174
这段代码是 Android 系统中 ActivityTaskManagerService 类中的 closeSystemDialogs 方法的实现。它的作用是关闭系统对话框,如对话框、通知等。在执行过程中,它会检查调用者的权限,并且只允许前台进程调用该方法。如果调用者是后台进程,则会记录一条警告,并且不执行关闭操作。最后,它会调用 ActivityManagerService 中的 broadcastCloseSystemDialogs 方法,通知系统关闭对话框。
相关问题
public void broadcastCloseSystemDialogs(String reason) { synchronized (ActivityManagerService.this) { final Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); Slog.v(TAG_SERVICE,"hyj 19651 startServiceInPackage:"); if (reason != null) { Slog.v(TAG_SERVICE,"hyj 19653 startServiceInPackage:"); intent.putExtra("reason", reason); } broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null, OP_NONE, null, false, false, -1, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL); } } 这段代码是做什么用
的?
这段代码是用来发送一个名为"Intent.ACTION_CLOSE_SYSTEM_DIALOGS"的广播,用于关闭系统对话框,例如弹出框、菜单等。其中,如果reason不为空,则会在intent中添加一个名为"reason"的额外数据。这个方法运行在ActivityManagerService的上下文中,并且在同步块中执行。
阅读全文
相关推荐













