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

Commit 370496b7 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Add api BluetoothAdapter.getMostRecentlyConnectedDevices() to be able...

Merge "Add api BluetoothAdapter.getMostRecentlyConnectedDevices() to be able to get connected devices ordered by how recently they were connected" am: 4f833efcbb am: 3007e729 am: 7ad6f1f1

Change-Id: I49225d84e7ae60cb042d31479623b19bce7608fb
parents a0cab5b2 7ad6f1f1
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -2161,6 +2161,33 @@ public final class BluetoothAdapter {
        }
    }

    /**
     * Fetches a list of the most recently connected bluetooth devices ordered by how recently they
     * were connected with most recently first and least recently last
     *
     * @return {@link List} of bonded {@link BluetoothDevice} ordered by how recently they were
     * connected
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
    public @NonNull List<BluetoothDevice> getMostRecentlyConnectedDevices() {
        if (getState() != STATE_ON) {
            return new ArrayList<>();
        }
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                return mService.getMostRecentlyConnectedDevices();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        } finally {
            mServiceLock.readLock().unlock();
        }
        return new ArrayList<>();
    }

    /**
     * Return the set of {@link BluetoothDevice} objects that are bonded
     * (paired) to the local adapter.