Loading android/app/src/com/android/bluetooth/hearingaid/HearingAidStateMachine.java +7 −15 Original line number Original line Diff line number Diff line Loading @@ -81,6 +81,7 @@ final class HearingAidStateMachine extends StateMachine { private Connecting mConnecting; private Connecting mConnecting; private Disconnecting mDisconnecting; private Disconnecting mDisconnecting; private Connected mConnected; private Connected mConnected; private int mConnectionState = BluetoothProfile.STATE_DISCONNECTED; private int mLastConnectionState = -1; private int mLastConnectionState = -1; private HearingAidService mService; private HearingAidService mService; Loading Loading @@ -132,6 +133,7 @@ final class HearingAidStateMachine extends StateMachine { public void enter() { public void enter() { Log.i(TAG, "Enter Disconnected(" + mDevice + "): " + messageWhatToString( Log.i(TAG, "Enter Disconnected(" + mDevice + "): " + messageWhatToString( getCurrentMessage().what)); getCurrentMessage().what)); mConnectionState = BluetoothProfile.STATE_DISCONNECTED; removeDeferredMessages(DISCONNECT); removeDeferredMessages(DISCONNECT); Loading Loading @@ -239,6 +241,7 @@ final class HearingAidStateMachine extends StateMachine { Log.i(TAG, "Enter Connecting(" + mDevice + "): " Log.i(TAG, "Enter Connecting(" + mDevice + "): " + messageWhatToString(getCurrentMessage().what)); + messageWhatToString(getCurrentMessage().what)); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); mConnectionState = BluetoothProfile.STATE_CONNECTING; broadcastConnectionState(BluetoothProfile.STATE_CONNECTING, mLastConnectionState); broadcastConnectionState(BluetoothProfile.STATE_CONNECTING, mLastConnectionState); } } Loading Loading @@ -329,6 +332,7 @@ final class HearingAidStateMachine extends StateMachine { Log.i(TAG, "Enter Disconnecting(" + mDevice + "): " Log.i(TAG, "Enter Disconnecting(" + mDevice + "): " + messageWhatToString(getCurrentMessage().what)); + messageWhatToString(getCurrentMessage().what)); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); mConnectionState = BluetoothProfile.STATE_DISCONNECTING; broadcastConnectionState(BluetoothProfile.STATE_DISCONNECTING, mLastConnectionState); broadcastConnectionState(BluetoothProfile.STATE_DISCONNECTING, mLastConnectionState); } } Loading Loading @@ -426,6 +430,7 @@ final class HearingAidStateMachine extends StateMachine { public void enter() { public void enter() { Log.i(TAG, "Enter Connected(" + mDevice + "): " Log.i(TAG, "Enter Connected(" + mDevice + "): " + messageWhatToString(getCurrentMessage().what)); + messageWhatToString(getCurrentMessage().what)); mConnectionState = BluetoothProfile.STATE_CONNECTED; removeDeferredMessages(CONNECT); removeDeferredMessages(CONNECT); broadcastConnectionState(BluetoothProfile.STATE_CONNECTED, mLastConnectionState); broadcastConnectionState(BluetoothProfile.STATE_CONNECTED, mLastConnectionState); } } Loading Loading @@ -496,20 +501,7 @@ final class HearingAidStateMachine extends StateMachine { } } int getConnectionState() { int getConnectionState() { String currentState = getCurrentState().getName(); return mConnectionState; switch (currentState) { case "Disconnected": return BluetoothProfile.STATE_DISCONNECTED; case "Connecting": return BluetoothProfile.STATE_CONNECTING; case "Connected": return BluetoothProfile.STATE_CONNECTED; case "Disconnecting": return BluetoothProfile.STATE_DISCONNECTING; default: Log.e(TAG, "Bad currentState: " + currentState); return BluetoothProfile.STATE_DISCONNECTED; } } } BluetoothDevice getDevice() { BluetoothDevice getDevice() { Loading @@ -517,7 +509,7 @@ final class HearingAidStateMachine extends StateMachine { } } synchronized boolean isConnected() { synchronized boolean isConnected() { return getCurrentState() == mConnected; return (getConnectionState() == BluetoothProfile.STATE_CONNECTED); } } // This method does not check for error condition (newState == prevState) // This method does not check for error condition (newState == prevState) Loading Loading
android/app/src/com/android/bluetooth/hearingaid/HearingAidStateMachine.java +7 −15 Original line number Original line Diff line number Diff line Loading @@ -81,6 +81,7 @@ final class HearingAidStateMachine extends StateMachine { private Connecting mConnecting; private Connecting mConnecting; private Disconnecting mDisconnecting; private Disconnecting mDisconnecting; private Connected mConnected; private Connected mConnected; private int mConnectionState = BluetoothProfile.STATE_DISCONNECTED; private int mLastConnectionState = -1; private int mLastConnectionState = -1; private HearingAidService mService; private HearingAidService mService; Loading Loading @@ -132,6 +133,7 @@ final class HearingAidStateMachine extends StateMachine { public void enter() { public void enter() { Log.i(TAG, "Enter Disconnected(" + mDevice + "): " + messageWhatToString( Log.i(TAG, "Enter Disconnected(" + mDevice + "): " + messageWhatToString( getCurrentMessage().what)); getCurrentMessage().what)); mConnectionState = BluetoothProfile.STATE_DISCONNECTED; removeDeferredMessages(DISCONNECT); removeDeferredMessages(DISCONNECT); Loading Loading @@ -239,6 +241,7 @@ final class HearingAidStateMachine extends StateMachine { Log.i(TAG, "Enter Connecting(" + mDevice + "): " Log.i(TAG, "Enter Connecting(" + mDevice + "): " + messageWhatToString(getCurrentMessage().what)); + messageWhatToString(getCurrentMessage().what)); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); mConnectionState = BluetoothProfile.STATE_CONNECTING; broadcastConnectionState(BluetoothProfile.STATE_CONNECTING, mLastConnectionState); broadcastConnectionState(BluetoothProfile.STATE_CONNECTING, mLastConnectionState); } } Loading Loading @@ -329,6 +332,7 @@ final class HearingAidStateMachine extends StateMachine { Log.i(TAG, "Enter Disconnecting(" + mDevice + "): " Log.i(TAG, "Enter Disconnecting(" + mDevice + "): " + messageWhatToString(getCurrentMessage().what)); + messageWhatToString(getCurrentMessage().what)); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs); mConnectionState = BluetoothProfile.STATE_DISCONNECTING; broadcastConnectionState(BluetoothProfile.STATE_DISCONNECTING, mLastConnectionState); broadcastConnectionState(BluetoothProfile.STATE_DISCONNECTING, mLastConnectionState); } } Loading Loading @@ -426,6 +430,7 @@ final class HearingAidStateMachine extends StateMachine { public void enter() { public void enter() { Log.i(TAG, "Enter Connected(" + mDevice + "): " Log.i(TAG, "Enter Connected(" + mDevice + "): " + messageWhatToString(getCurrentMessage().what)); + messageWhatToString(getCurrentMessage().what)); mConnectionState = BluetoothProfile.STATE_CONNECTED; removeDeferredMessages(CONNECT); removeDeferredMessages(CONNECT); broadcastConnectionState(BluetoothProfile.STATE_CONNECTED, mLastConnectionState); broadcastConnectionState(BluetoothProfile.STATE_CONNECTED, mLastConnectionState); } } Loading Loading @@ -496,20 +501,7 @@ final class HearingAidStateMachine extends StateMachine { } } int getConnectionState() { int getConnectionState() { String currentState = getCurrentState().getName(); return mConnectionState; switch (currentState) { case "Disconnected": return BluetoothProfile.STATE_DISCONNECTED; case "Connecting": return BluetoothProfile.STATE_CONNECTING; case "Connected": return BluetoothProfile.STATE_CONNECTED; case "Disconnecting": return BluetoothProfile.STATE_DISCONNECTING; default: Log.e(TAG, "Bad currentState: " + currentState); return BluetoothProfile.STATE_DISCONNECTED; } } } BluetoothDevice getDevice() { BluetoothDevice getDevice() { Loading @@ -517,7 +509,7 @@ final class HearingAidStateMachine extends StateMachine { } } synchronized boolean isConnected() { synchronized boolean isConnected() { return getCurrentState() == mConnected; return (getConnectionState() == BluetoothProfile.STATE_CONNECTED); } } // This method does not check for error condition (newState == prevState) // This method does not check for error condition (newState == prevState) Loading