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
This commit is contained in:
Shivam Agrawal
2021-12-07 13:45:23 -05:00
parent b344d33561
commit f382049442

View File

@@ -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<Exception> failureCallback) {
@Nullable Consumer<Exception> failureCallback) {
try {
mPresenter.startActivityToSide(launchingActivity, intent, options, sideRule);
} catch (Exception e) {
failureCallback.accept(e);
if (failureCallback != null) {
failureCallback.accept(e);
}
}
}