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

Commit 54e7928e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12327203 from c3a18ca7 to 24Q4-release

Change-Id: Ida9cc7504f98bbbbb52153013416f0bcbeee29e7
parents 41d269e1 c3a18ca7
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -607,8 +607,7 @@ public class AvrcpTargetService extends ProfileService {
            Metadata newMetadata = newQueue.get(index);

            if (!Objects.equals(currentMetadata.title, newMetadata.title)
                    || !Objects.equals(currentMetadata.artist, newMetadata.artist)
                    || !Objects.equals(currentMetadata.album, newMetadata.album)) {
                    || !Objects.equals(currentMetadata.artist, newMetadata.artist)) {
                return true;
            }
        }
+12 −5
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Pattern;
@@ -257,6 +258,8 @@ public class AdapterService extends Service {
            mBluetoothQualityReportReadyCallbacks = new RemoteCallbackList<>();
    private final RemoteCallbackList<IBluetoothCallback> mRemoteCallbacks =
            new RemoteCallbackList<>();
    private final RemoteCallbackList<IBluetoothConnectionCallback> mBluetoothConnectionCallbacks =
            new RemoteCallbackList<>();

    private final EvictingQueue<String> mScanModeChanges = EvictingQueue.create(10);

@@ -283,7 +286,6 @@ public class AdapterService extends Service {

    private boolean mNativeAvailable;
    private boolean mCleaningUp;
    private Set<IBluetoothConnectionCallback> mBluetoothConnectionCallbacks = new HashSet<>();
    private boolean mQuietmode = false;
    private Map<String, CallerInfo> mBondAttemptCallerInfo = new HashMap<>();

@@ -3452,7 +3454,7 @@ public class AdapterService extends Service {
                return;
            }
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);
            service.mBluetoothConnectionCallbacks.add(callback);
            service.mBluetoothConnectionCallbacks.register(callback);
        }

        @Override
@@ -3466,7 +3468,7 @@ public class AdapterService extends Service {
                return;
            }
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);
            service.mBluetoothConnectionCallbacks.remove(callback);
            service.mBluetoothConnectionCallbacks.unregister(callback);
        }

        @Override
@@ -5517,8 +5519,13 @@ public class AdapterService extends Service {
        return mRemoteDevices.getUuids(device);
    }

    public Set<IBluetoothConnectionCallback> getBluetoothConnectionCallbacks() {
        return mBluetoothConnectionCallbacks;
    void aclStateChangeBroadcastCallback(Consumer<IBluetoothConnectionCallback> cb) {
        int n = mBluetoothConnectionCallbacks.beginBroadcast();
        Log.d(TAG, "aclStateChangeBroadcastCallback() - Broadcasting to " + n + " receivers.");
        for (int i = 0; i < n; i++) {
            cb.accept(mBluetoothConnectionCallbacks.getBroadcastItem(i));
        }
        mRemoteCallbacks.finishBroadcast();
    }

    /**
+36 −31
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.util.Log;

@@ -80,6 +79,8 @@ public class RemoteDevices {

    private static final int UUID_INTENT_DELAY = 6000;
    private static final int MESSAGE_UUID_INTENT = 1;
    private static final int MESSAGE_UUID_STATUS_SUCCESS = 0;
    private static final int MESSAGE_UUID_STATUS_TIMEOUT = 1;
    private static final String LOG_SOURCE_DIS = "DIS";

    private final HashMap<String, DeviceProperties> mDevices;
@@ -120,12 +121,13 @@ public class RemoteDevices {
                case MESSAGE_UUID_INTENT:
                    BluetoothDevice device = (BluetoothDevice) msg.obj;
                    if (device != null) {
                        boolean success = (msg.arg1 == MESSAGE_UUID_STATUS_SUCCESS);
                        debugLog("MESSAGE_UUID_INTENT: " + device);
                        // SDP Sending delayed SDP UUID intent
                        MetricsLogger.getInstance()
                                .cacheCount(BluetoothProtoEnums.SDP_SENDING_DELAYED_UUID, 1);
                        DeviceProperties prop = getDeviceProperties(device);
                        sendUuidIntent(device, prop);
                        sendUuidIntent(device, prop, success);
                    } else {
                        // SDP Not sending delayed SDP UUID intent b/c device is not there
                        MetricsLogger.getInstance()
@@ -727,10 +729,13 @@ public class RemoteDevices {
        }
    }

    private void sendUuidIntent(BluetoothDevice device, DeviceProperties prop) {
    private void sendUuidIntent(BluetoothDevice device, DeviceProperties prop, boolean success) {
        // Send uuids within the stack before the broadcast is sent out
        ParcelUuid[] uuids = prop == null ? null : prop.getUuids();

        if (!Flags.preventDuplicateUuidIntent() || success) {
            mAdapterService.sendUuidsInternal(device, uuids);
        }

        Intent intent = new Intent(BluetoothDevice.ACTION_UUID);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
@@ -1002,7 +1007,7 @@ public class RemoteDevices {
                                        .cacheCount(
                                                BluetoothProtoEnums.SDP_ADD_UUID_WITH_INTENT, 1);
                                mAdapterService.deviceUuidUpdated(bdDevice);
                                sendUuidIntent(bdDevice, deviceProperties);
                                sendUuidIntent(bdDevice, deviceProperties, true);
                            } else if (mAdapterService.getState()
                                    == BluetoothAdapter.STATE_BLE_ON) {
                                // SDP Adding UUIDs to property cache but with no intent
@@ -1177,17 +1182,19 @@ public class RemoteDevices {
            return;
        }

        BluetoothDevice device = getDevice(address);

        if (device == null) {
            warnLog(
                    "aclStateChangeCallback: device is NULL, address="
                            + Utils.getRedactedAddressStringFromByte(address)
                            + ", newState="
                            + newState);
            addDeviceProperties(address);
            device = Objects.requireNonNull(getDevice(address));
        }
        final BluetoothDevice device =
                Objects.requireNonNullElseGet(
                        getDevice(address),
                        () -> {
                            Log.w(
                                    TAG,
                                    "aclStateChangeCallback: device is NULL"
                                            + ("address="
                                                    + Utils.getRedactedAddressStringFromByte(
                                                            address))
                                            + (" newState=" + newState));
                            return addDeviceProperties(address).getDevice();
                        });

        DeviceProperties deviceProperties = getDeviceProperties(device);

@@ -1297,22 +1304,18 @@ public class RemoteDevices {
        mAdapterService.sendBroadcast(
                intent, BLUETOOTH_CONNECT, Utils.getTempBroadcastOptions().toBundle());

        synchronized (mAdapterService.getBluetoothConnectionCallbacks()) {
            Set<IBluetoothConnectionCallback> bluetoothConnectionCallbacks =
                    mAdapterService.getBluetoothConnectionCallbacks();
            for (IBluetoothConnectionCallback callback : bluetoothConnectionCallbacks) {
                try {
        Utils.RemoteExceptionIgnoringConsumer<IBluetoothConnectionCallback>
                connectionChangeConsumer;
        if (connectionState == BluetoothAdapter.STATE_CONNECTED) {
                        callback.onDeviceConnected(device);
            connectionChangeConsumer = cb -> cb.onDeviceConnected(device);
        } else {
                        callback.onDeviceDisconnected(
            connectionChangeConsumer =
                    cb ->
                            cb.onDeviceDisconnected(
                                    device, AdapterService.hciToAndroidDisconnectReason(hciReason));
        }
                } catch (RemoteException ex) {
                    Log.e(TAG, "RemoteException in calling IBluetoothConnectionCallback");
                }
            }
        }

        mAdapterService.aclStateChangeBroadcastCallback(connectionChangeConsumer);
    }

    @NonNull
@@ -1441,6 +1444,7 @@ public class RemoteDevices {

        Message message = mHandler.obtainMessage(MESSAGE_UUID_INTENT);
        message.obj = device;
        message.arg1 = MESSAGE_UUID_STATUS_TIMEOUT;
        mHandler.sendMessageDelayed(message, UUID_INTENT_DELAY);

        // Uses cached UUIDs if we are bonding. If not, we fetch the UUIDs with SDP.
@@ -1460,6 +1464,7 @@ public class RemoteDevices {
    void updateUuids(BluetoothDevice device) {
        Message message = mHandler.obtainMessage(MESSAGE_UUID_INTENT);
        message.obj = device;
        message.arg1 = MESSAGE_UUID_STATUS_SUCCESS;
        mHandler.sendMessage(message);
    }

+5 −4
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;

import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNullElse;
import static java.util.Objects.requireNonNullElseGet;

import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothDevice;
@@ -122,8 +122,9 @@ public class HapClientService extends ProfileService {
        super(adapterService);
        mAdapterService = requireNonNull(adapterService);
        mHapClientNativeInterface =
                requireNonNullElse(
                requireNonNullElseGet(
                        nativeInterface,
                        () ->
                                new HapClientNativeInterface(
                                        new HapClientNativeCallback(adapterService, this)));
        mDatabaseManager = requireNonNull(mAdapterService.getDatabase());
+1 −1
Original line number Diff line number Diff line
@@ -363,7 +363,7 @@ public class BluetoothInCallService extends InCallService {

    private BluetoothInCallService(CallInfo callInfo) {
        Log.i(TAG, "BluetoothInCallService is created");
        mCallInfo = Objects.requireNonNullElse(callInfo, new CallInfo());
        mCallInfo = Objects.requireNonNullElseGet(callInfo, () -> new CallInfo());
        sInstance = this;
        mExecutor = Executors.newSingleThreadExecutor();
    }
Loading