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

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

Merge "Unregister GATT client if closed before registration completes" into...

Merge "Unregister GATT client if closed before registration completes" into main am: bc46ffd1 am: 364fe474 am: a5f01b3f

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



Change-Id: I8f249d994ccaf573a9e346406bf606f93801e463
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 839a7144 a5f01b3f
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -229,14 +229,24 @@ public final class BluetoothGatt implements BluetoothProfile {
                        Log.d(TAG, "onClientRegistered() - status=" + status
                        Log.d(TAG, "onClientRegistered() - status=" + status
                                + " clientIf=" + clientIf);
                                + " clientIf=" + clientIf);
                    }
                    }
                    if (VDBG) {
                    mClientIf = clientIf;
                    synchronized (mStateLock) {
                    synchronized (mStateLock) {
                        if (mConnState == CONN_STATE_CLOSED) {
                            if (DBG) {
                                Log.d(
                                        TAG,
                                        "Client registration completed after closed,"
                                                + " unregistering");
                            }
                            unregisterApp();
                            return;
                        }
                        if (VDBG) {
                            if (mConnState != CONN_STATE_CONNECTING) {
                            if (mConnState != CONN_STATE_CONNECTING) {
                                Log.e(TAG, "Bad connection state: " + mConnState);
                                Log.e(TAG, "Bad connection state: " + mConnState);
                            }
                            }
                        }
                        }
                    }
                    }
                    mClientIf = clientIf;
                    if (status != GATT_SUCCESS) {
                    if (status != GATT_SUCCESS) {
                        runOrQueueCallback(new Runnable() {
                        runOrQueueCallback(new Runnable() {
                            @Override
                            @Override
@@ -1006,8 +1016,8 @@ public final class BluetoothGatt implements BluetoothProfile {
    @RequiresBluetoothConnectPermission
    @RequiresBluetoothConnectPermission
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
    private void unregisterApp() {
    private void unregisterApp() {
        if (DBG) Log.d(TAG, "unregisterApp() - mClientIf=" + mClientIf);
        if (mService == null || mClientIf == 0) return;
        if (mService == null || mClientIf == 0) return;
        if (DBG) Log.d(TAG, "unregisterApp() - mClientIf=" + mClientIf);


        try {
        try {
            mCallback = null;
            mCallback = null;