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

Commit d2e6c81a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove the local cached BluetoothClass"

parents 9d30bf15 8df81e3e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -274,7 +274,6 @@ public class BluetoothEventManager {
        public void onReceive(Context context, Intent intent,
                BluetoothDevice device) {
            short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
            BluetoothClass btClass = intent.getParcelableExtra(BluetoothDevice.EXTRA_CLASS);
            String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
            // TODO Pick up UUID. They should be available for 2.1 devices.
            // Skip for now, there's a bluez problem and we are not getting uuids even for 2.1.
@@ -285,7 +284,6 @@ public class BluetoothEventManager {
                        + cachedDevice);
            }
            cachedDevice.setRssi(rssi);
            cachedDevice.setBtClass(btClass);
            cachedDevice.setJustDiscovered(true);
        }
    }
+2 −28
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
    private long mHiSyncId;
    // Need this since there is no method for getting RSSI
    private short mRssi;
    //TODO: consider remove, BluetoothDevice.getBluetoothClass() is already cached
    private BluetoothClass mBtClass;
    private HashMap<LocalBluetoothProfile, Integer> mProfileConnectionState;

    private final List<LocalBluetoothProfile> mProfiles =
@@ -374,7 +372,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>

    // TODO: do any of these need to run async on a background thread?
    private void fillData() {
        fetchBtClass();
        updateProfiles();
        fetchActiveDevices();
        migratePhonebookPermissionChoice();
@@ -587,13 +584,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        return getBondState() == BluetoothDevice.BOND_BONDING;
    }

    /**
     * Fetches a new value for the cached BT class.
     */
    private void fetchBtClass() {
        mBtClass = mDevice.getBluetoothClass();
    }

    private boolean updateProfiles() {
        ParcelUuid[] uuids = mDevice.getUuids();
        if (uuids == null) return false;
@@ -637,15 +627,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        }
    }

    /**
     * Refreshes the UI for the BT class, including fetching the latest value
     * for the class.
     */
    void refreshBtClass() {
        fetchBtClass();
        dispatchAttributesChanged();
    }

    /**
     * Refreshes the UI when framework alerts us of a UUID change.
     */
@@ -696,15 +677,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        }
    }

    void setBtClass(BluetoothClass btClass) {
        if (btClass != null && mBtClass != btClass) {
            mBtClass = btClass;
            dispatchAttributesChanged();
        }
    }

    public BluetoothClass getBtClass() {
        return mBtClass;
        return mDevice.getBluetoothClass();
    }

    public List<LocalBluetoothProfile> getProfiles() {
@@ -738,7 +712,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        }
    }

    private void dispatchAttributesChanged() {
    void dispatchAttributesChanged() {
        synchronized (mCallbacks) {
            for (Callback callback : mCallbacks) {
                callback.onDeviceAttributesChanged();
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ public class CachedBluetoothDeviceManager {
    public synchronized void onBtClassChanged(BluetoothDevice device) {
        CachedBluetoothDevice cachedDevice = findDevice(device);
        if (cachedDevice != null) {
            cachedDevice.refreshBtClass();
            cachedDevice.dispatchAttributesChanged();
        }
    }