Add null check on ActivityOptions before using it

ActivityOptions in calculate() may be null sometimes, which
results in an NPE when trying to get the launchWindowingMode.

Bug: 202194933
Test: m -j128 && atest CompatChangeTests
Change-Id: Icc87278adb66b6ab856c8bb84594933abc71cf60
This commit is contained in:
jorgegil@google.com
2021-10-06 14:18:24 -07:00
parent f23eb51da9
commit d1908d2f72

View File

@@ -261,8 +261,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
if (launchMode == WINDOWING_MODE_PINNED) {
if (DEBUG) appendLog("picture-in-picture");
} else if (!root.isResizeable()) {
if (shouldLaunchUnresizableAppInFreeform(root, suggestedDisplayArea,
options.getLaunchWindowingMode())) {
if (shouldLaunchUnresizableAppInFreeform(root, suggestedDisplayArea, options)) {
launchMode = WINDOWING_MODE_FREEFORM;
if (outParams.mBounds.isEmpty()) {
getTaskBounds(root, suggestedDisplayArea, layout, launchMode,
@@ -618,8 +617,8 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
}
private boolean shouldLaunchUnresizableAppInFreeform(ActivityRecord activity,
TaskDisplayArea displayArea, int launchWindowingMode) {
if (launchWindowingMode == WINDOWING_MODE_FULLSCREEN) {
TaskDisplayArea displayArea, @Nullable ActivityOptions options) {
if (options != null && options.getLaunchWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
// Do not launch the activity in freeform if it explicitly requested fullscreen mode.
return false;
}