Loading android/app/src/com/android/bluetooth/hfp/HeadsetPhoneState.java +8 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,11 @@ public class HeadsetPhoneState { mPhoneStateListener = new HeadsetPhoneStateListener(subId, mHeadsetService.getStateMachinesThreadLooper()); mTelephonyManager.listen(mPhoneStateListener, events); if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { mTelephonyManager.setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); } } private void stopListenForPhoneState() { Loading @@ -173,6 +178,9 @@ public class HeadsetPhoneState { Log.i(TAG, "stopListenForPhoneState(), stopping listener, enabled_events=" + getTelephonyEventsToListen()); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); mTelephonyManager.setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); mPhoneStateListener = null; } Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetPhoneStateTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,9 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -140,8 +143,14 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE)); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -156,8 +165,14 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -175,6 +190,9 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); // Enabling updates from second device should not trigger the same subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SERVICE_STATE Loading @@ -186,6 +204,9 @@ public class HeadsetPhoneStateTest { // Disabling updates from second device should cancel subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -205,17 +226,32 @@ public class HeadsetPhoneStateTest { // Partially enabling updates from second device should trigger partial subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); // Partially disabling updates from first device should not cancel all subscription mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager, times(2)).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager, times(2)).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager, times(2)).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); // Partially disabling updates from second device should cancel subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager, times(3)).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager, times(3)).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verifyNoMoreInteractions(mTelephonyManager); } } Loading
android/app/src/com/android/bluetooth/hfp/HeadsetPhoneState.java +8 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,11 @@ public class HeadsetPhoneState { mPhoneStateListener = new HeadsetPhoneStateListener(subId, mHeadsetService.getStateMachinesThreadLooper()); mTelephonyManager.listen(mPhoneStateListener, events); if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { mTelephonyManager.setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); } } private void stopListenForPhoneState() { Loading @@ -173,6 +178,9 @@ public class HeadsetPhoneState { Log.i(TAG, "stopListenForPhoneState(), stopping listener, enabled_events=" + getTelephonyEventsToListen()); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); mTelephonyManager.setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); mPhoneStateListener = null; } Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetPhoneStateTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,9 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -140,8 +143,14 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE)); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -156,8 +165,14 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -175,6 +190,9 @@ public class HeadsetPhoneStateTest { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); // Enabling updates from second device should not trigger the same subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SERVICE_STATE Loading @@ -186,6 +204,9 @@ public class HeadsetPhoneStateTest { // Disabling updates from second device should cancel subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verifyNoMoreInteractions(mTelephonyManager); } Loading @@ -205,17 +226,32 @@ public class HeadsetPhoneStateTest { // Partially enabling updates from second device should trigger partial subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); // Partially disabling updates from first device should not cancel all subscription mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager, times(2)).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager, times(2)).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SIGNAL_STRENGTHS)); verify(mTelephonyManager, times(2)).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF); verifyNoMoreInteractions(mTelephonyManager); // Partially disabling updates from second device should cancel subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE); verify(mTelephonyManager, times(3)).listen(any(), eq(PhoneStateListener.LISTEN_NONE)); verify(mTelephonyManager, times(3)).setRadioIndicationUpdateMode( TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, TelephonyManager.INDICATION_UPDATE_MODE_NORMAL); verifyNoMoreInteractions(mTelephonyManager); } }