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

Commit d4915030 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

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

Merge "Change Bluetooth stack code not to use the hidden API for Mainline" am: 765f7310 am: d49bd8d5

Change-Id: I48dc4870fdaf1f3b7a5f6076a2a58618bbb1bb7c
parents 75d79b8d d49bd8d5
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@
    <uses-permission android:name="android.permission.READ_CALL_LOG" />
    <uses-permission android:name="android.permission.READ_CALL_LOG" />
    <uses-permission android:name="android.permission.WRITE_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.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.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.NFC_HANDOVER_STATUS" />
    <uses-permission android:name="android.permission.NFC_HANDOVER_STATUS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+0 −8
Original line number Original line Diff line number Diff line
@@ -163,11 +163,6 @@ public class HeadsetPhoneState {
        Log.i(TAG, "startListenForPhoneState(), subId=" + subId + ", enabled_events=" + events);
        Log.i(TAG, "startListenForPhoneState(), subId=" + subId + ", enabled_events=" + events);
        mPhoneStateListener = new HeadsetPhoneStateListener(command -> mHandler.post(command));
        mPhoneStateListener = new HeadsetPhoneStateListener(command -> mHandler.post(command));
        mTelephonyManager.listen(mPhoneStateListener, events);
        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() {
    private void stopListenForPhoneState() {
@@ -178,9 +173,6 @@ public class HeadsetPhoneState {
        Log.i(TAG, "stopListenForPhoneState(), stopping listener, enabled_events="
        Log.i(TAG, "stopListenForPhoneState(), stopping listener, enabled_events="
                + getTelephonyEventsToListen());
                + getTelephonyEventsToListen());
        mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
        mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
        mTelephonyManager.setRadioIndicationUpdateMode(
                TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH,
                TelephonyManager.INDICATION_UPDATE_MODE_NORMAL);
        mPhoneStateListener = null;
        mPhoneStateListener = null;
    }
    }


+1 −0
Original line number Original line Diff line number Diff line
@@ -2023,6 +2023,7 @@ public class HeadsetStateMachine extends StateMachine {
        }
        }
        if (mAgIndicatorEnableState != null && mAgIndicatorEnableState.signal) {
        if (mAgIndicatorEnableState != null && mAgIndicatorEnableState.signal) {
            events |= PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;
            events |= PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;
            events |= PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH;
        }
        }
        mSystemInterface.getHeadsetPhoneState().listenForPhoneState(mDevice, events);
        mSystemInterface.getHeadsetPhoneState().listenForPhoneState(mDevice, events);
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
    <uses-permission android:name="android.permission.BLUETOOTH_STACK" />
    <uses-permission android:name="android.permission.BLUETOOTH_STACK" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
    <uses-permission android:name="android.permission.MANAGE_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.google.android.gallery3d.permission.GALLERY_PROVIDER"/>
    <uses-permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER"/>
    <uses-permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER"/>


+24 −58
Original line number Original line Diff line number Diff line
@@ -125,13 +125,11 @@ public class HeadsetPhoneStateTest {
    public void testListenForPhoneState_ServiceAndSignalStrength() {
    public void testListenForPhoneState_ServiceAndSignalStrength() {
        BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1);
        BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE
        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
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS));
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
        verify(mTelephonyManager).setRadioIndicationUpdateMode(
                        | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH));
                TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH,
                TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF);
        verifyNoMoreInteractions(mTelephonyManager);
    }
    }


    /**
    /**
@@ -142,19 +140,14 @@ public class HeadsetPhoneStateTest {
    public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffSignalStrengh() {
    public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffSignalStrengh() {
        BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1);
        BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE
        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
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS));
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
        verify(mTelephonyManager).setRadioIndicationUpdateMode(
                        | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH));
                TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH,
                TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE);
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_NONE));
        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));
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE));
        verifyNoMoreInteractions(mTelephonyManager);
    }
    }


    /**
    /**
@@ -164,18 +157,13 @@ public class HeadsetPhoneStateTest {
    public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffAll() {
    public void testListenForPhoneState_ServiceAndSignalStrengthUpdateTurnOffAll() {
        BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1);
        BluetoothDevice device1 = TestUtils.getTestDevice(mAdapter, 1);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE
        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
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS));
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
        verify(mTelephonyManager).setRadioIndicationUpdateMode(
                        | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH));
                TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH,
                TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE);
        verify(mTelephonyManager).listen(any(), eq(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);
        BluetoothDevice device2 = TestUtils.getTestDevice(mAdapter, 2);
        // Enabling updates from first device should trigger subscription
        // Enabling updates from first device should trigger subscription
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_SERVICE_STATE
        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
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS));
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
        verify(mTelephonyManager).setRadioIndicationUpdateMode(
                        | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH));
                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
        // Enabling updates from second device should not trigger the same subscription
        mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SERVICE_STATE
        mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_SERVICE_STATE
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
        verifyNoMoreInteractions(mTelephonyManager);
                        | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH);
        // Disabling updates from first device should not cancel subscription
        // Disabling updates from first device should not cancel subscription
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE);
        verifyNoMoreInteractions(mTelephonyManager);
        // Disabling updates from second device should cancel subscription
        // Disabling updates from second device should cancel subscription
        mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE);
        mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE);
        verify(mTelephonyManager).listen(any(), eq(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));
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE));
        verifyNoMoreInteractions(mTelephonyManager);
        verifyNoMoreInteractions(mTelephonyManager);
        // Partially enabling updates from second device should trigger partial subscription
        // 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).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
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SERVICE_STATE
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS));
                | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
        verify(mTelephonyManager).setRadioIndicationUpdateMode(
                        | PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH));
                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
        // Partially disabling updates from first device should not cancel all subscription
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE);
        mHeadsetPhoneState.listenForPhoneState(device1, PhoneStateListener.LISTEN_NONE);
        verify(mTelephonyManager, times(2)).listen(any(), eq(PhoneStateListener.LISTEN_NONE));
        verify(mTelephonyManager, times(2)).listen(any(), eq(PhoneStateListener.LISTEN_NONE));
        verify(mTelephonyManager, times(2)).setRadioIndicationUpdateMode(
        verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
                TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH,
                | PhoneStateListener.LISTEN_ALWAYS_REPORTED_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
        // Partially disabling updates from second device should cancel subscription
        mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE);
        mHeadsetPhoneState.listenForPhoneState(device2, PhoneStateListener.LISTEN_NONE);
        verify(mTelephonyManager, times(3)).listen(any(), eq(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