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

Commit aaf5f700 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "BluetoothInCallService: Check bound count before calling...

Merge "BluetoothInCallService: Check bound count before calling listCurrentCalls" am: 3272d97d am: 1208b341

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2048823



Change-Id: I3bcdcbe9b4c87dec7b0589d3ea01cd296f8b397b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7a78e38e 1208b341
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -146,6 +146,8 @@ public class BluetoothInCallService extends InCallService {

    public CallInfo mCallInfo = new CallInfo();

    protected boolean mOnCreateCalled = false;

    /**
     * Listens to connections and disconnections of bluetooth headsets.  We need to save the current
     * bluetooth headset so that we know where to send BluetoothCall updates.
@@ -487,6 +489,10 @@ public class BluetoothInCallService extends InCallService {
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public boolean listCurrentCalls() {
        synchronized (LOCK) {
            if (!mOnCreateCalled) {
                Log.w(TAG, "listcurrentCalls() is called before onCreate()");
                return false;
            }
            enforceModifyPermission();
            // only log if it is after we recently updated the headset state or else it can
            // clog the android log since this can be queried every second.
@@ -655,12 +661,14 @@ public class BluetoothInCallService extends InCallService {
        mAudioManager = getSystemService(AudioManager.class);
        mAudioManager.addOnModeChangedListener(
                Executors.newSingleThreadExecutor(), mBluetoothOnModeChangedListener);
        mOnCreateCalled = true;
    }

    @Override
    public void onDestroy() {
        Log.d(TAG, "onDestroy");
        clear();
        mOnCreateCalled = false;
        super.onDestroy();
    }

+5 −0
Original line number Diff line number Diff line
@@ -111,6 +111,10 @@ public class BluetoothInCallServiceTest {
        }
        @Override
        protected void enforceModifyPermission() {}

        protected void setOnCreateCalled(boolean called) {
            mOnCreateCalled = called;
        }
    }

    @Before
@@ -140,6 +144,7 @@ public class BluetoothInCallServiceTest {
        mBluetoothInCallService.setBluetoothHeadset(mMockBluetoothHeadset);
        mBluetoothInCallService.setBluetoothLeCallControl(mMockBluetoothLeCallControl);
        mBluetoothInCallService.mCallInfo = mMockCallInfo;
        mBluetoothInCallService.setOnCreateCalled(true);
    }

    @After