/ / Czy możliwe jest automatyczne akceptowanie parowania Bluetooth? - Android, Bluetooth, parowanie

Automatyczne akceptowanie parowania bluetooth możliwe? - Android, Bluetooth, parowanie

W przykładzie systemu Android 2.3.3 BluetoothChat z interfejsem API createInsecureRfcommSocketToServiceRecord () użytkownicy nadal są proszeni o zaakceptowanie żądania parowania, nawet jeśli kod PIN nie jest wyświetlany.

Czy istnieje sposób na zautomatyzowanie parowania Bluetoothzapytanie bez interwencji użytkownika? Czy to nigdy nie jest możliwe ze względów bezpieczeństwa? Szukałem online już 2 dni i naprawdę nie znalazłem wiele, więc jeśli ktoś wie, napisz.

Dzięki!

Odpowiedzi:

3 dla odpowiedzi № 1

Nie ze standardowym API, nie: jeśli adres MAC nie znajduje się już w bazie danych parowania, zawsze pojawi się monit. Powiedziano mi, że jeśli masz zrootowane urządzenie i masz publiczny dostęp do odczytu / zapisu do punktu końcowego DBus usługi bluetooth, możesz obejść ten problem, ale nigdy nie widziałem, żeby to faktycznie zostało wdrożone.


4 dla odpowiedzi nr 2

Miałem to pytanie, jeśli ktoś potrzebuje odpowiedzi na to, pracując w Androidzie 4.4.2

 IntentFilter filter = new IntentFilter(
"android.bluetooth.device.action.PAIRING_REQUEST");


/*
* Registering a new BTBroadcast receiver from the Main Activity context
* with pairing request event
*/
registerReceiver(
new PairingRequest(), filter);

i kod odbiorcy

  public static class PairingRequest extends BroadcastReceiver {
public PairingRequest() {
super();
}

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.bluetooth.device.action.PAIRING_REQUEST")) {
try {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int pin=intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY", 0);
//the pin in case you need to accept for an specific pin
Log.d("PIN", " " + intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY",0));
//maybe you look for a name or address
Log.d("Bonded", device.getName());
byte[] pinBytes;
pinBytes = (""+pin).getBytes("utf-8");
device.setPin(pinBytes);
//setPairing confirmation if neeeded
device.setPairingConfirmation(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

oraz w pliku manifestu

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

i broadcastReceiver

 <receiver android:name=".MainActivity$PairingRequest">
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<action android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
</intent-filter>
</receiver>

3 dla odpowiedzi nr 3

napotkałem ten sam problem, mam nadzieję, że następujący kod pomoże: potrzebujemy:

<receiver android:name=".broadcast.PairingRequest"> <intent-filter> <action android:name="android.bluetooth.device.action.PAIRING_REQUEST" /> <action android:name="android.bluetooth.device.action.PAIRING_CANCEL" /> </intent-filter></receiver>

po drugie potrzebujemy klasy BluetoothDevice i:

public class PairingRequest extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent){
if (intent.getAction().equals("ACTION_PAIRING_REQUEST")) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
byte[] pinBytes = BluetoothDevice.convertPinToBytes("1234");
device.setPin(pinBytes);
}
}
}

3 dla odpowiedzi № 4

Nie ze standardowym API, nie: jeśli adres MAC nie znajduje się już w bazie danych parowania, zawsze pojawi się monit. Powiedziano mi, że jeśli masz zrootowane urządzenie i masz publiczny dostęp do odczytu / zapisu do punktu końcowego DBus usługi bluetooth, możesz obejść ten problem, ale nigdy nie widziałem, żeby to faktycznie zostało wdrożone.


4 dla odpowiedzi № 5

Miałem to pytanie, jeśli ktoś potrzebuje odpowiedzi na to, pracując w Androidzie 4.4.2

 IntentFilter filter = new IntentFilter(
"android.bluetooth.device.action.PAIRING_REQUEST");


/*
* Registering a new BTBroadcast receiver from the Main Activity context
* with pairing request event
*/
registerReceiver(
new PairingRequest(), filter);

i kod odbiorcy

  public static class PairingRequest extends BroadcastReceiver {
public PairingRequest() {
super();
}

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.bluetooth.device.action.PAIRING_REQUEST")) {
try {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int pin=intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY", 0);
//the pin in case you need to accept for an specific pin
Log.d("PIN", " " + intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY",0));
//maybe you look for a name or address
Log.d("Bonded", device.getName());
byte[] pinBytes;
pinBytes = (""+pin).getBytes("utf-8");
device.setPin(pinBytes);
//setPairing confirmation if neeeded
device.setPairingConfirmation(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

oraz w pliku manifestu

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

i broadcastReceiver

 <receiver android:name=".MainActivity$PairingRequest">
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<action android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
</intent-filter>
</receiver>

3 dla odpowiedzi № 6

napotkałem ten sam problem, mam nadzieję, że następujący kod pomoże: potrzebujemy:

<receiver android:name=".broadcast.PairingRequest"> <intent-filter> <action android:name="android.bluetooth.device.action.PAIRING_REQUEST" /> <action android:name="android.bluetooth.device.action.PAIRING_CANCEL" /> </intent-filter></receiver>

po drugie potrzebujemy klasy BluetoothDevice i:

public class PairingRequest extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent){
if (intent.getAction().equals("ACTION_PAIRING_REQUEST")) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
byte[] pinBytes = BluetoothDevice.convertPinToBytes("1234");
device.setPin(pinBytes);
}
}
}