Loading android/app/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ <uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.WRITE_CALL_LOG" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <uses-permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.NFC_HANDOVER_STATUS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> Loading android/app/src/com/android/bluetooth/hfp/HeadsetPhoneState.java +0 −8 Original line number Diff line number Diff line Loading @@ -163,11 +163,6 @@ public class HeadsetPhoneState { Log.i(TAG, "startListenForPhoneState(), subId=" + subId + ", enabled_events=" + events); mPhoneStateListener = new HeadsetPhoneStateListener(command -> mHandler.post(command)); 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 @@ -178,9 +173,6 @@ 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/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +1 −0 Original line number Diff line number Diff line Loading @@ -2023,6 +2023,7 @@ public class HeadsetStateMachine extends StateMachine { } if (mAgIndicatorEnableState != null && mAgIndicatorEnableState.signal) { events |= PhoneStateListener.LISTEN_SIGNAL_STRENGTHS; events |= PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH; } mSystemInterface.getHeadsetPhoneState().listenForPhoneState(mDevice, events); } Loading android/app/tests/unit/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ <uses-permission android:name="android.permission.BLUETOOTH_STACK" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/> <uses-permission android:name="android.permission.MANAGE_USERS"/> <uses-permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH"/> <uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER"/> <uses-permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER"/> Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetPhoneStateTest.java +24 −58 Original line number Diff line number Diff line Loading @@ -125,13 +125,11 @@ public class HeadsetPhoneStateTest { public void testListenForPhoneState_ServiceAndSignalStrength() { BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); } /** Loading @@ -142,19 +140,14 @@ public class HeadsetPhoneStateTest { public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffSignalStrengh() { BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); 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 @@ -164,18 +157,13 @@ public class HeadsetPhoneStateTest { public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffAll() { BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); 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 @@ -189,27 +177,20 @@ public class HeadsetPhoneStateTest { BluetoothDevice device2 = TestUtils.getTestDevice(mAdapter, 2); // Enabling updates from first device should trigger subscription mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); // Enabling updates from second device should not trigger the same subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verifyNoMoreInteractions(mTelephonyManager); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); // Disabling updates from first device should not cancel subscription mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE); verifyNoMoreInteractions(mTelephonyManager); // 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 @@ -226,34 +207,19 @@ public class HeadsetPhoneStateTest { verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE)); verifyNoMoreInteractions(mTelephonyManager); // Partially enabling updates from second device should trigger partial subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); // 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); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); // 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/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ <uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.WRITE_CALL_LOG" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <uses-permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.NFC_HANDOVER_STATUS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> Loading
android/app/src/com/android/bluetooth/hfp/HeadsetPhoneState.java +0 −8 Original line number Diff line number Diff line Loading @@ -163,11 +163,6 @@ public class HeadsetPhoneState { Log.i(TAG, "startListenForPhoneState(), subId=" + subId + ", enabled_events=" + events); mPhoneStateListener = new HeadsetPhoneStateListener(command -> mHandler.post(command)); 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 @@ -178,9 +173,6 @@ 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/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +1 −0 Original line number Diff line number Diff line Loading @@ -2023,6 +2023,7 @@ public class HeadsetStateMachine extends StateMachine { } if (mAgIndicatorEnableState != null && mAgIndicatorEnableState.signal) { events |= PhoneStateListener.LISTEN_SIGNAL_STRENGTHS; events |= PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH; } mSystemInterface.getHeadsetPhoneState().listenForPhoneState(mDevice, events); } Loading
android/app/tests/unit/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ <uses-permission android:name="android.permission.BLUETOOTH_STACK" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/> <uses-permission android:name="android.permission.MANAGE_USERS"/> <uses-permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH"/> <uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER"/> <uses-permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER"/> Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetPhoneStateTest.java +24 −58 Original line number Diff line number Diff line Loading @@ -125,13 +125,11 @@ public class HeadsetPhoneStateTest { public void testListenForPhoneState_ServiceAndSignalStrength() { BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); } /** Loading @@ -142,19 +140,14 @@ public class HeadsetPhoneStateTest { public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffSignalStrengh() { BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); 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 @@ -164,18 +157,13 @@ public class HeadsetPhoneStateTest { public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffAll() { BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1); mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); 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 @@ -189,27 +177,20 @@ public class HeadsetPhoneStateTest { BluetoothDevice device2 = TestUtils.getTestDevice(mAdapter, 2); // Enabling updates from first device should trigger subscription mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); // Enabling updates from second device should not trigger the same subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); verifyNoMoreInteractions(mTelephonyManager); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); // Disabling updates from first device should not cancel subscription mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE); verifyNoMoreInteractions(mTelephonyManager); // 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 @@ -226,34 +207,19 @@ public class HeadsetPhoneStateTest { verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE)); verifyNoMoreInteractions(mTelephonyManager); // Partially enabling updates from second device should trigger partial subscription mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH); 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); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); // 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); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)); // 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); } }