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

Commit c734627c authored by Gaurav Asati's avatar Gaurav Asati Committed by Linux Build Service Account
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

Change-Id: I7dc4fc693993d96821acb69d5ecaa44857853273
parent 04ca681a
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -521,7 +521,29 @@ public final class CachedBluetoothDevice implements Comparable<CachedBluetoothDe
     * 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;