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

Commit 65ee48c6 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8445529 from 6a7cb937 to tm-qpr1-release

Change-Id: Ic8100587c9e124301eb26723b8c710ff7459a39a
parents c27ed7b3 6a7cb937
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ final class BondStateMachine extends StateMachine {
        }
    }


    private class PendingCommandState extends State {
        private final ArrayList<BluetoothDevice> mDevices = new ArrayList<BluetoothDevice>();

@@ -195,9 +194,9 @@ final class BondStateMachine extends StateMachine {

            DeviceProperties devProp = mRemoteDevices.getDeviceProperties(dev);
            boolean result = false;
            if (mDevices.contains(dev) && msg.what != CANCEL_BOND
                    && msg.what != BONDING_STATE_CHANGE && msg.what != SSP_REQUEST
                    && msg.what != PIN_REQUEST) {
            if ((mDevices.contains(dev) || mPendingBondedDevices.contains(dev))
                    && msg.what != CANCEL_BOND && msg.what != BONDING_STATE_CHANGE
                    && msg.what != SSP_REQUEST && msg.what != PIN_REQUEST) {
                deferMessage(msg);
                return true;
            }
@@ -279,7 +278,6 @@ final class BondStateMachine extends StateMachine {
                        sendDisplayPinIntent(devProp.getAddress(), 0,
                                BluetoothDevice.PAIRING_VARIANT_PIN);
                    }

                    break;
                default:
                    Log.e(TAG, "Received unhandled event:" + msg.what);
@@ -288,7 +286,6 @@ final class BondStateMachine extends StateMachine {
            if (result) {
                mDevices.add(dev);
            }

            return true;
        }
    }
@@ -317,7 +314,6 @@ final class BondStateMachine extends StateMachine {
                }
                return true;
            }

        }
        return false;
    }
+111 −25
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.bluetooth.csip;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -885,11 +887,19 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void connect(BluetoothDevice device, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(device, "device cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                boolean defaultValue = false;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.connect(device);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.connect(device);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -900,11 +910,19 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void disconnect(BluetoothDevice device, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(device, "device cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                boolean defaultValue = false;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.disconnect(device);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.disconnect(device);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -915,11 +933,18 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void getConnectedDevices(AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                List<BluetoothDevice> defaultValue = new ArrayList<>();
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getConnectedDevices();
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.getConnectedDevices();
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -930,11 +955,18 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void getDevicesMatchingConnectionStates(int[] states,
                AttributionSource source, SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                List<BluetoothDevice> defaultValue = new ArrayList<>();
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getDevicesMatchingConnectionStates(states);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.getDevicesMatchingConnectionStates(states);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -945,11 +977,18 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void getConnectionState(BluetoothDevice device, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(device, "device cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                int defaultValue = BluetoothProfile.STATE_DISCONNECTED;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getConnectionState(device);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);
                defaultValue = service.getConnectionState(device);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -960,11 +999,19 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void setConnectionPolicy(BluetoothDevice device, int connectionPolicy,
                AttributionSource source, SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(device, "device cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                boolean defaultValue = false;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.setConnectionPolicy(device, connectionPolicy);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.setConnectionPolicy(device, connectionPolicy);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -975,11 +1022,19 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void getConnectionPolicy(BluetoothDevice device, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(device, "device cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getConnectionPolicy(device);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.getConnectionPolicy(device);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -991,12 +1046,21 @@ public class CsipSetCoordinatorService extends ProfileService {
                int groupId, @NonNull IBluetoothCsipSetCoordinatorLockCallback callback,
                AttributionSource source, SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(callback, "callback cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                ParcelUuid defaultValue = null;

                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                UUID lockUuid = service.lockGroup(groupId, callback);
                defaultValue = lockUuid == null ? null : new ParcelUuid(lockUuid);
                }
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -1007,10 +1071,18 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void unlockGroup(@NonNull ParcelUuid lockUuid, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(lockUuid, "lockUuid cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    service.unlockGroup(lockUuid.getUuid());
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                service.unlockGroup(lockUuid.getUuid());
                receiver.send(null);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -1021,11 +1093,17 @@ public class CsipSetCoordinatorService extends ProfileService {
        public void getAllGroupIds(ParcelUuid uuid, AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                Objects.requireNonNull(uuid, "uuid cannot be null");
                Objects.requireNonNull(source, "source cannot be null");
                Objects.requireNonNull(receiver, "receiver cannot be null");

                List<Integer> defaultValue = new ArrayList<Integer>();
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getAllGroupIds(uuid);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }
                enforceBluetoothPrivilegedPermission(service);
                defaultValue = service.getAllGroupIds(uuid);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -1038,9 +1116,13 @@ public class CsipSetCoordinatorService extends ProfileService {
            try {
                Map<Integer, ParcelUuid> defaultValue = null;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getGroupUuidMapByDevice(device);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.getGroupUuidMapByDevice(device);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
@@ -1053,9 +1135,13 @@ public class CsipSetCoordinatorService extends ProfileService {
            try {
                int defaultValue = IBluetoothCsipSetCoordinator.CSIS_GROUP_SIZE_UNKNOWN;
                CsipSetCoordinatorService service = getService(source);
                if (service != null) {
                    defaultValue = service.getDesiredGroupSize(groupId);
                if (service == null) {
                    throw new IllegalStateException("service is null");
                }

                enforceBluetoothPrivilegedPermission(service);

                defaultValue = service.getDesiredGroupSize(groupId);
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
+10 −7
Original line number Diff line number Diff line
@@ -1775,6 +1775,16 @@ public class GattService extends ProfileService {
                    + ", originalAddress=" + originalAddress);
        }

        String identityAddress = mAdapterService.getIdentityAddress(address);
        if (!address.equals(identityAddress)) {
            if (VDBG) {
                Log.d(TAG, "found identityAddress of " + address + ", replace originalAddress as "
                        + identityAddress);
            }
            originalAddress = identityAddress;
        }


        byte[] legacyAdvData = Arrays.copyOfRange(advData, 0, 62);

        for (ScanClient client : mScanManager.getRegularScanQueue()) {
@@ -1844,13 +1854,6 @@ public class GattService extends ProfileService {
                continue;
            }

            if (matchResult.getMatchOrigin() == MatchOrigin.ORIGINAL_ADDRESS) {
                result = new ScanResult(BluetoothAdapter.getDefaultAdapter()
                        .getRemoteDevice(originalAddress), eventType, primaryPhy, secondaryPhy,
                        advertisingSid, txPower, rssi, periodicAdvInt, scanRecord,
                        SystemClock.elapsedRealtimeNanos());
            }

            if ((settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_ALL_MATCHES) == 0) {
                if (VDBG) {
                    Log.d(TAG, "Skipping client: CALLBACK_TYPE_ALL_MATCHES");
+16 −2
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public class HeadsetService extends ProfileService {
    private static final int[] CONNECTING_CONNECTED_STATES =
            {BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_CONNECTED};
    private static final int DIALING_OUT_TIMEOUT_MS = 10000;
    private static final int CLCC_END_MARK_INDEX = 0;

    // Timeout for state machine thread join, to prevent potential ANR.
    private static final int SM_THREAD_JOIN_TIMEOUT_MS = 1000;
@@ -135,6 +136,7 @@ public class HeadsetService extends ProfileService {
    private VoiceRecognitionTimeoutEvent mVoiceRecognitionTimeoutEvent;
    // Timeout when voice recognition is started by remote device
    @VisibleForTesting static int sStartVrTimeoutMs = 5000;
    private ArrayList<StateMachineTask> mPendingClccResponses = new ArrayList<>();
    private boolean mStarted;
    private boolean mCreated;
    private static HeadsetService sHeadsetService;
@@ -326,6 +328,14 @@ public class HeadsetService extends ProfileService {
        }
    }

    private void doForEachConnectedStateMachine(List<StateMachineTask> tasks) {
        synchronized (mStateMachines) {
            for (StateMachineTask task : tasks) {
                doForEachConnectedStateMachine(task);
            }
        }
    }

    void onDeviceStateChanged(HeadsetDeviceState deviceState) {
        doForEachConnectedStateMachine(
                stateMachine -> stateMachine.sendMessage(HeadsetStateMachine.DEVICE_STATE_CHANGED,
@@ -1859,10 +1869,14 @@ public class HeadsetService extends ProfileService {
    private void clccResponse(int index, int direction, int status, int mode, boolean mpty,
            String number, int type) {
        enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "Need MODIFY_PHONE_STATE permission");
        doForEachConnectedStateMachine(
                stateMachine -> stateMachine.sendMessage(HeadsetStateMachine.SEND_CCLC_RESPONSE,
        mPendingClccResponses.add(
                stateMachine -> stateMachine.sendMessage(HeadsetStateMachine.SEND_CLCC_RESPONSE,
                        new HeadsetClccResponse(index, direction, status, mode, mpty, number,
                                type)));
        if (index == CLCC_END_MARK_INDEX) {
            doForEachConnectedStateMachine(mPendingClccResponses);
            mPendingClccResponses.clear();
        }
    }

    private boolean sendVendorSpecificResultCode(BluetoothDevice device, String command,
+4 −4
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ public class HeadsetStateMachine extends StateMachine {
    static final int INTENT_CONNECTION_ACCESS_REPLY = 8;
    static final int CALL_STATE_CHANGED = 9;
    static final int DEVICE_STATE_CHANGED = 10;
    static final int SEND_CCLC_RESPONSE = 11;
    static final int SEND_CLCC_RESPONSE = 11;
    static final int SEND_VENDOR_SPECIFIC_RESULT_CODE = 12;
    static final int SEND_BSIR = 13;
    static final int DIALING_OUT_RESULT = 14;
@@ -868,7 +868,7 @@ public class HeadsetStateMachine extends StateMachine {
                    }
                    mNativeInterface.notifyDeviceStatus(mDevice, (HeadsetDeviceState) message.obj);
                    break;
                case SEND_CCLC_RESPONSE:
                case SEND_CLCC_RESPONSE:
                    processSendClccResponse((HeadsetClccResponse) message.obj);
                    break;
                case CLCC_RSP_TIMEOUT: {
@@ -2170,8 +2170,8 @@ public class HeadsetStateMachine extends StateMachine {
                return "CALL_STATE_CHANGED";
            case DEVICE_STATE_CHANGED:
                return "DEVICE_STATE_CHANGED";
            case SEND_CCLC_RESPONSE:
                return "SEND_CCLC_RESPONSE";
            case SEND_CLCC_RESPONSE:
                return "SEND_CLCC_RESPONSE";
            case SEND_VENDOR_SPECIFIC_RESULT_CODE:
                return "SEND_VENDOR_SPECIFIC_RESULT_CODE";
            case STACK_EVENT:
Loading