From f382049442af524b4dbfb6f0761fad910347d405 Mon Sep 17 00:00:00 2001 From: Shivam Agrawal Date: Tue, 7 Dec 2021 13:45:23 -0500 Subject: [PATCH] Fix NPE in SplitController#startActivityToSide SplitController#startActivityToSide is called from SplitController#launchPlaceholderIfNecessary with a null value for the failure callback. If the activity launch to side fails, then startActivityToSide tries to pass the failure to the failure callback, which is null. This CL fixes this bug by checking if the failure callback is null. Bug: b/209296363 Test: existing tests pass Test: launch settings app from overview and observe no crash Change-Id: I6577d992f48acbaae6b0e9776e65933e779defe3 --- .../window/extensions/embedding/SplitController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java index fe6c7ba3b24c9..dc4e27a4c8d80 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java @@ -91,11 +91,13 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen */ public void startActivityToSide(@NonNull Activity launchingActivity, @NonNull Intent intent, @Nullable Bundle options, @NonNull SplitRule sideRule, - @NonNull Consumer failureCallback) { + @Nullable Consumer failureCallback) { try { mPresenter.startActivityToSide(launchingActivity, intent, options, sideRule); } catch (Exception e) { - failureCallback.accept(e); + if (failureCallback != null) { + failureCallback.accept(e); + } } }