From 27b53cfe88df05f015c509259993071d54cdcb36 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Thu, 15 Dec 2016 17:55:40 -0800 Subject: [PATCH] Don't call into VrManagerService with AM lock. Bug: 33655854 Merged-In: If777e0ef40b29bff42722f2aa10cff86a5831bc0 Change-Id: I365d0033cf20172cee57b0ef2a53dd8648640c8d --- .../android/server/am/ActivityManagerService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index d00783e546ae2..b68af438bf18c 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1547,6 +1547,7 @@ public final class ActivityManagerService extends ActivityManagerNative static final int NOTIFY_FORCED_RESIZABLE_MSG = 67; static final int NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG = 68; static final int SHOW_UNSUPPORTED_DISPLAY_SIZE_DIALOG_MSG = 69; + static final int NOTIFY_VR_SLEEPING_MSG = 70; static final int FIRST_ACTIVITY_STACK_MSG = 100; static final int FIRST_BROADCAST_QUEUE_MSG = 200; @@ -2362,6 +2363,8 @@ public final class ActivityManagerService extends ActivityManagerNative } } vrService.setVrMode(vrMode, requestedPackage, userId, callingPackage); + } case NOTIFY_VR_SLEEPING_MSG: { + notifyVrManagerOfSleepState(msg.arg1 != 0); } break; } } @@ -3164,6 +3167,11 @@ public final class ActivityManagerService extends ActivityManagerNative mHandler.obtainMessage(VR_MODE_CHANGE_MSG, 0, 0, r)); } + private void sendNotifyVrManagerOfSleepState(boolean isSleeping) { + mHandler.sendMessage( + mHandler.obtainMessage(NOTIFY_VR_SLEEPING_MSG, isSleeping ? 1 : 0, 0)); + } + private void notifyVrManagerOfSleepState(boolean isSleeping) { final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class); if (vrService == null) { @@ -11690,7 +11698,7 @@ public final class ActivityManagerService extends ActivityManagerNative startTimeTrackingFocusedActivityLocked(); mTopProcessState = ActivityManager.PROCESS_STATE_TOP; mStackSupervisor.comeOutOfSleepIfNeededLocked(); - notifyVrManagerOfSleepState(false); + sendNotifyVrManagerOfSleepState(false); updateOomAdjLocked(); } else if (!mSleeping && shouldSleepLocked()) { mSleeping = true; @@ -11699,7 +11707,7 @@ public final class ActivityManagerService extends ActivityManagerNative } mTopProcessState = ActivityManager.PROCESS_STATE_TOP_SLEEPING; mStackSupervisor.goingToSleepLocked(); - notifyVrManagerOfSleepState(true); + sendNotifyVrManagerOfSleepState(true); updateOomAdjLocked(); // Initialize the wake times of all processes.