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

Commit 4b8ec1d8 authored by AnubhavGupta's avatar AnubhavGupta Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Don't Initiate Connection if UUID not updated

 - if UUIDs are not updated don't initiate profile connection
 - add new profiles to already existing list
 -  don't delete profiles from the existing list

CRs-Fixed: 717840

Change-Id: Id71a5aad59f4004c262f3ad17f34fa0574654170
parent 7286f3fc
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -544,7 +544,29 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
     * Refreshes the UI when framework alerts us of a UUID change.
     */
    void onUuidChanged() {
        Log.d(TAG, " onUuidChanged, mProfile Size " + mProfiles.size());
        List<LocalBluetoothProfile> mPrevProfiles =
                new ArrayList<LocalBluetoothProfile>();
        mPrevProfiles.clear();
        mPrevProfiles.addAll(mProfiles);
        updateProfiles();
        /*
         * Check if new profiles are added
         */
        if ((mPrevProfiles.containsAll(mProfiles)) && (!mPrevProfiles.isEmpty())) {
            Log.d(TAG,"UUID not udpated, returning");
            mProfiles.clear();
            mProfiles.addAll(mPrevProfiles);
            return;
        }
        for (int i = 0; i<mProfiles.size(); ++i) {
            if (!mPrevProfiles.contains(mProfiles.get(i))) {
                mPrevProfiles.add(mProfiles.get(i));
            }
        }
        mProfiles.clear();
        mProfiles.addAll(mPrevProfiles);

        ParcelUuid[] uuids = mDevice.getUuids();
        long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT;
        if (DEBUG){