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

Commit 1122fdff 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 am: aaf5f700

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



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


    public CallInfo mCallInfo = new CallInfo();
    public CallInfo mCallInfo = new CallInfo();


    protected boolean mOnCreateCalled = false;

    /**
    /**
     * Listens to connections and disconnections of bluetooth headsets.  We need to save the current
     * 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.
     * 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)
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public boolean listCurrentCalls() {
    public boolean listCurrentCalls() {
        synchronized (LOCK) {
        synchronized (LOCK) {
            if (!mOnCreateCalled) {
                Log.w(TAG, "listcurrentCalls() is called before onCreate()");
                return false;
            }
            enforceModifyPermission();
            enforceModifyPermission();
            // only log if it is after we recently updated the headset state or else it can
            // 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.
            // 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 = getSystemService(AudioManager.class);
        mAudioManager.addOnModeChangedListener(
        mAudioManager.addOnModeChangedListener(
                Executors.newSingleThreadExecutor(), mBluetoothOnModeChangedListener);
                Executors.newSingleThreadExecutor(), mBluetoothOnModeChangedListener);
        mOnCreateCalled = true;
    }
    }


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


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

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


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


    @After
    @After