Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abe10b3e authored by Quang Luong's avatar Quang Luong
Browse files

Catch ArrayIndexOutOfBoundsException in StateMachine.toString()

StateMachine.toString() calls mSmHandler.getCurrentState(). In the
rare case when mStateStackTopIndex is -1 due to the StateMachine being
not yet initalized, this results in an ArrayIndexOutOfBoundsException.

Bug: 124858416
Test: none

Change-Id: Id558be95b6e12d8a923d325bca5f6f6d7f942b22
parent dd07ae57
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.internal.annotations.VisibleForTesting;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
@@ -2102,7 +2101,7 @@ public class StateMachine {
        try {
            name = mName.toString();
            state = mSmHandler.getCurrentState().getName().toString();
        } catch (NullPointerException npe) {
        } catch (NullPointerException | ArrayIndexOutOfBoundsException e) {
            // Will use default(s) initialized above.
        }
        return "name=" + name + " state=" + state;