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

Commit f0f566ec authored by Wink Saville's avatar Wink Saville
Browse files

Ignore instead of throw errors in QuittingState and reorder some parameters.

Since there could be an arbitrary number of messages in
the queue but Handler/Looper/MessageQueue do not provide
any mechanism for removing "all" messages the best we can
do is ignore. Throwing an error is probably too heavy.

Change-Id: I13c81ac5786484f5b3218885b010de596d943975
parent 1b8b98b3
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -550,7 +550,8 @@ public class HierarchicalStateMachine {
        private class QuittingState extends HierarchicalState {
            @Override
            public boolean processMessage(Message msg) {
                throw new RuntimeException("QuitingState: processMessage called should not happen");
                // Ignore
                return false;
            }
        }

@@ -960,7 +961,7 @@ public class HierarchicalStateMachine {
     * @param looper for this state machine
     * @param name of the state machine
     */
    private void initStateMachine(Looper looper, String name) {
    private void initStateMachine(String name, Looper looper) {
        mName = name;
        mHsmHandler = new HsmHandler(looper, this);
    }
@@ -975,7 +976,7 @@ public class HierarchicalStateMachine {
        mHsmThread.start();
        Looper looper = mHsmThread.getLooper();

        initStateMachine(looper, name);
        initStateMachine(name, looper);
    }

    /**
@@ -983,8 +984,8 @@ public class HierarchicalStateMachine {
     *
     * @param name of the state machine
     */
    protected HierarchicalStateMachine(Looper looper, String name) {
        initStateMachine(looper, name);
    protected HierarchicalStateMachine(String name, Looper looper) {
        initStateMachine(name, looper);
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -1204,8 +1204,8 @@ public class HierarchicalStateMachineTest extends TestCase {
     * complete.
     */
    class StateMachineSharedThread extends HierarchicalStateMachine {
        StateMachineSharedThread(Looper looper, String name, int maxCount) {
            super(looper, name);
        StateMachineSharedThread(String name, Looper looper, int maxCount) {
            super(name, looper);
            mMaxCount = maxCount;
            setDbg(DBG);

@@ -1254,7 +1254,7 @@ public class HierarchicalStateMachineTest extends TestCase {
        // Create the state machines
        StateMachineSharedThread sms[] = new StateMachineSharedThread[10];
        for (int i = 0; i < sms.length; i++) {
            sms[i] = new StateMachineSharedThread(smThread.getLooper(), "sm", sms.length);
            sms[i] = new StateMachineSharedThread("sm", smThread.getLooper(), sms.length);
            sms[i].start();
        }