Android 如何获得BLUETOOTH_在路由设备中自动配对设备的特权权限,而无需将其放入系统应用程序?
我需要蓝牙特权才能自动播放设备 如何在死记硬背的设备中获得自动播放设备的BLUETOOTH_特权权限 不把它放在系统应用程序上 我正在尝试以编程方式自动修复已在ListView中显示的设备,而不显示“配对对话框” //接受者Android 如何获得BLUETOOTH_在路由设备中自动配对设备的特权权限,而无需将其放入系统应用程序?,android,bluetooth,permissions,android-permissions,Android,Bluetooth,Permissions,Android Permissions,我需要蓝牙特权才能自动播放设备 如何在死记硬背的设备中获得自动播放设备的BLUETOOTH_特权权限 不把它放在系统应用程序上 我正在尝试以编程方式自动修复已在ListView中显示的设备,而不显示“配对对话框” //接受者 public static class PairingRequest extends BroadcastReceiver { public PairingRequest() { super(); } @Override pu
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);
device.setPairingConfirmation(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
但之后是调用device.setPairingConfirmation(true)代码>出现异常,出现此错误java.lang.SecurityException:需要蓝牙特权权限:用户10069和当前进程都没有android.permission.BLUETOOTH\u特权。
我已经进行了搜索,所有的建议都是将应用程序放在系统/应用程序中,但我不能放在那里,因为我需要在将来进行更新
我正在使用的设备已根目录,且应用程序位于“数据/应用程序”路径中
任何建议都会有帮助。
非常感谢 文档状态-“这对第三方应用程序不可用”。我假设您需要使用与设备平台相同的密钥对应用程序进行签名,并将其添加到特权权限白名单中-@MarkKeen谢谢,我将查看特权权限白名单。不过,我不认为如果不将其放在priv-app文件夹中,您将无法逃脱,不管它是否已被扎根。。
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);
device.setPairingConfirmation(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}