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

Commit 1db7a31a authored by Nick Pelly's avatar Nick Pelly Committed by Android (Google) Code Review
Browse files

Merge "Add BluetoothAdapter.getRemoteDevice(byte[])"

parents 8c9d0139 75596b45
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4244,6 +4244,7 @@ package android.bluetooth {
    method public int getProfileConnectionState(int);
    method public boolean getProfileProxy(android.content.Context, android.bluetooth.BluetoothProfile.ServiceListener, int);
    method public android.bluetooth.BluetoothDevice getRemoteDevice(java.lang.String);
    method public android.bluetooth.BluetoothDevice getRemoteDevice(byte[]);
    method public int getScanMode();
    method public int getState();
    method public boolean isDiscovering();
+20 −1
Original line number Diff line number Diff line
@@ -398,6 +398,25 @@ public final class BluetoothAdapter {
        return new BluetoothDevice(address);
    }

    /**
     * Get a {@link BluetoothDevice} object for the given Bluetooth hardware
     * address.
     * <p>Valid Bluetooth hardware addresses must be 6 bytes. This method
     * expects the address in network byte order (MSB first).
     * <p>A {@link BluetoothDevice} will always be returned for a valid
     * hardware address, even if this adapter has never seen that device.
     *
     * @param address Bluetooth MAC address (6 bytes)
     * @throws IllegalArgumentException if address is invalid
     */
    public BluetoothDevice getRemoteDevice(byte[] address) {
        if (address == null || address.length != 6) {
            throw new IllegalArgumentException("Bluetooth address must have 6 bytes");
        }
        return new BluetoothDevice(String.format("%02X:%02X:%02X:%02X:%02X:%02X",
                address[0], address[1], address[2], address[3], address[4], address[5]));
    }

    /**
     * Return true if Bluetooth is currently enabled and ready for use.
     * <p>Equivalent to:
@@ -1281,7 +1300,7 @@ public final class BluetoothAdapter {
    }

    /**
     * Validate a Bluetooth address, such as "00:43:A8:23:10:F0"
     * Validate a String Bluetooth address, such as "00:43:A8:23:10:F0"
     * <p>Alphabetic characters must be uppercase to be valid.
     *
     * @param address Bluetooth address as string