Loading packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +10 −5 Original line number Diff line number Diff line Loading @@ -124,8 +124,9 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { final boolean transientEnabling = arg == ARG_SHOW_TRANSIENT_ENABLING; final boolean enabled = transientEnabling || mController.isBluetoothEnabled(); final boolean connected = mController.isBluetoothConnected(); state.isTransient = transientEnabling || mController.isBluetoothConnecting() || mController.getBluetoothState() == BluetoothAdapter.STATE_TURNING_ON; final boolean connecting = mController.isBluetoothConnecting(); state.isTransient = transientEnabling || connecting || mController.getBluetoothState() == BluetoothAdapter.STATE_TURNING_ON; state.dualTarget = true; state.value = enabled; if (state.slash == null) { Loading @@ -134,7 +135,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { state.slash.isSlashed = !enabled; state.label = mContext.getString(R.string.quick_settings_bluetooth_label); state.secondaryLabel = TextUtils.emptyIfNull( getSecondaryLabel(enabled, connected, state.isTransient)); getSecondaryLabel(enabled, connecting, connected, state.isTransient)); if (enabled) { if (connected) { state.icon = new BluetoothConnectedTileIcon(); Loading Loading @@ -170,13 +171,17 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { * Returns the secondary label to use for the given bluetooth connection in the form of the * battery level or bluetooth profile name. If the bluetooth is disabled, there's no connected * devices, or we can't map the bluetooth class to a profile, this instead returns {@code null}. * * @param enabled whether bluetooth is enabled * @param connecting whether bluetooth is connecting to a device * @param connected whether there's a device connected via bluetooth * @param isTransient whether bluetooth is currently in a transient state turning on */ @Nullable private String getSecondaryLabel(boolean enabled, boolean connected, boolean isTransient) { private String getSecondaryLabel(boolean enabled, boolean connecting, boolean connected, boolean isTransient) { if (connecting) { return mContext.getString(R.string.quick_settings_connecting); } if (isTransient) { return mContext.getString(R.string.quick_settings_bluetooth_secondary_label_transient); } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +1 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa mEnabled = bluetoothState == BluetoothAdapter.STATE_ON || bluetoothState == BluetoothAdapter.STATE_TURNING_ON; mState = bluetoothState; updateConnected(); mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BluetoothControllerImplTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.policy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -162,4 +163,38 @@ public class BluetoothControllerImplTest extends SysuiTestCase { mainLooper.destroy(); } } @Test public void testOnServiceConnected_updatesConnectionState() { when(mMockAdapter.getConnectionState()).thenReturn(BluetoothAdapter.STATE_CONNECTING); mBluetoothControllerImpl.onServiceConnected(); assertTrue(mBluetoothControllerImpl.isBluetoothConnecting()); assertFalse(mBluetoothControllerImpl.isBluetoothConnected()); } @Test public void testOnBluetoothStateChange_updatesBluetoothState() { mBluetoothControllerImpl.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF); assertEquals(BluetoothAdapter.STATE_OFF, mBluetoothControllerImpl.getBluetoothState()); mBluetoothControllerImpl.onBluetoothStateChanged(BluetoothAdapter.STATE_ON); assertEquals(BluetoothAdapter.STATE_ON, mBluetoothControllerImpl.getBluetoothState()); } @Test public void testOnBluetoothStateChange_updatesConnectionState() { when(mMockAdapter.getConnectionState()).thenReturn( BluetoothAdapter.STATE_CONNECTING, BluetoothAdapter.STATE_DISCONNECTED); mBluetoothControllerImpl.onServiceConnected(); mBluetoothControllerImpl.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF); assertFalse(mBluetoothControllerImpl.isBluetoothConnecting()); assertFalse(mBluetoothControllerImpl.isBluetoothConnected()); } } Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +10 −5 Original line number Diff line number Diff line Loading @@ -124,8 +124,9 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { final boolean transientEnabling = arg == ARG_SHOW_TRANSIENT_ENABLING; final boolean enabled = transientEnabling || mController.isBluetoothEnabled(); final boolean connected = mController.isBluetoothConnected(); state.isTransient = transientEnabling || mController.isBluetoothConnecting() || mController.getBluetoothState() == BluetoothAdapter.STATE_TURNING_ON; final boolean connecting = mController.isBluetoothConnecting(); state.isTransient = transientEnabling || connecting || mController.getBluetoothState() == BluetoothAdapter.STATE_TURNING_ON; state.dualTarget = true; state.value = enabled; if (state.slash == null) { Loading @@ -134,7 +135,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { state.slash.isSlashed = !enabled; state.label = mContext.getString(R.string.quick_settings_bluetooth_label); state.secondaryLabel = TextUtils.emptyIfNull( getSecondaryLabel(enabled, connected, state.isTransient)); getSecondaryLabel(enabled, connecting, connected, state.isTransient)); if (enabled) { if (connected) { state.icon = new BluetoothConnectedTileIcon(); Loading Loading @@ -170,13 +171,17 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { * Returns the secondary label to use for the given bluetooth connection in the form of the * battery level or bluetooth profile name. If the bluetooth is disabled, there's no connected * devices, or we can't map the bluetooth class to a profile, this instead returns {@code null}. * * @param enabled whether bluetooth is enabled * @param connecting whether bluetooth is connecting to a device * @param connected whether there's a device connected via bluetooth * @param isTransient whether bluetooth is currently in a transient state turning on */ @Nullable private String getSecondaryLabel(boolean enabled, boolean connected, boolean isTransient) { private String getSecondaryLabel(boolean enabled, boolean connecting, boolean connected, boolean isTransient) { if (connecting) { return mContext.getString(R.string.quick_settings_connecting); } if (isTransient) { return mContext.getString(R.string.quick_settings_bluetooth_secondary_label_transient); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +1 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa mEnabled = bluetoothState == BluetoothAdapter.STATE_ON || bluetoothState == BluetoothAdapter.STATE_TURNING_ON; mState = bluetoothState; updateConnected(); mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BluetoothControllerImplTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.policy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -162,4 +163,38 @@ public class BluetoothControllerImplTest extends SysuiTestCase { mainLooper.destroy(); } } @Test public void testOnServiceConnected_updatesConnectionState() { when(mMockAdapter.getConnectionState()).thenReturn(BluetoothAdapter.STATE_CONNECTING); mBluetoothControllerImpl.onServiceConnected(); assertTrue(mBluetoothControllerImpl.isBluetoothConnecting()); assertFalse(mBluetoothControllerImpl.isBluetoothConnected()); } @Test public void testOnBluetoothStateChange_updatesBluetoothState() { mBluetoothControllerImpl.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF); assertEquals(BluetoothAdapter.STATE_OFF, mBluetoothControllerImpl.getBluetoothState()); mBluetoothControllerImpl.onBluetoothStateChanged(BluetoothAdapter.STATE_ON); assertEquals(BluetoothAdapter.STATE_ON, mBluetoothControllerImpl.getBluetoothState()); } @Test public void testOnBluetoothStateChange_updatesConnectionState() { when(mMockAdapter.getConnectionState()).thenReturn( BluetoothAdapter.STATE_CONNECTING, BluetoothAdapter.STATE_DISCONNECTED); mBluetoothControllerImpl.onServiceConnected(); mBluetoothControllerImpl.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF); assertFalse(mBluetoothControllerImpl.isBluetoothConnecting()); assertFalse(mBluetoothControllerImpl.isBluetoothConnected()); } }