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

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

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

parents 342c8e2f 3272d97d
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