Merge "Fix VR mode handling when the screen blanks and unblanks." into nyc-dev
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c971262..40430b4 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1471,6 +1471,7 @@
static final int NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG = 66;
static final int NOTIFY_FORCED_RESIZABLE_MSG = 67;
static final int NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG = 68;
+ static final int VR_MODE_APPLY_IF_NEEDED_MSG = 69;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -2241,6 +2242,17 @@
}
vrService.setVrMode(vrMode, requestedPackage, userId, callingPackage);
} break;
+ case VR_MODE_APPLY_IF_NEEDED_MSG: {
+ final ActivityRecord r = (ActivityRecord) msg.obj;
+ final boolean needsVrMode = r != null && r.requestedVrComponent != null;
+ if (needsVrMode) {
+ VrManagerInternal vrService =
+ LocalServices.getService(VrManagerInternal.class);
+ boolean enable = msg.arg1 == 1;
+ vrService.setVrMode(enable, r.requestedVrComponent, r.userId,
+ r.info.getComponentName());
+ }
+ } break;
}
}
};
@@ -3021,6 +3033,11 @@
mHandler.obtainMessage(VR_MODE_CHANGE_MSG, 0, 0, r));
}
+ private void applyVrModeIfNeededLocked(ActivityRecord r, boolean enable) {
+ mHandler.sendMessage(
+ mHandler.obtainMessage(VR_MODE_APPLY_IF_NEEDED_MSG, enable ? 1 : 0, 0, r));
+ }
+
final void showAskCompatModeDialogLocked(ActivityRecord r) {
Message msg = Message.obtain();
msg.what = SHOW_COMPAT_MODE_DIALOG_UI_MSG;
@@ -6537,6 +6554,7 @@
// Some stack visibility might change (e.g. docked stack)
mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
+ applyVrModeIfNeededLocked(mFocusedActivity, true);
}
}
} finally {
@@ -20925,6 +20943,7 @@
SleepTokenImpl token = new SleepTokenImpl(tag);
mSleepTokens.add(token);
updateSleepIfNeededLocked();
+ applyVrModeIfNeededLocked(mFocusedActivity, false);
return token;
}
}