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

Commit 765f7310 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Change Bluetooth stack code not to use the hidden API for Mainline"

parents 2de77572 846d3b43
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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" />
+0 −8
Original line number Diff line number Diff line
@@ -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() {
@@ -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;
    }

+1 −0
Original line number Diff line number Diff line
@@ -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);
    }
+1 −0
Original line number Diff line number Diff line
@@ -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"/>

+24 −58
Original line number Diff line number Diff line
@@ -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));
    }

    /**
@@ -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);
    }

    /**
@@ -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);
    }

    /**
@@ -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);
    }

    /**
@@ -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