Android的蓝牙低耗能:characteristic.getPermissions()返回0? [英] Android Bluetooth Low Energy: characteristic.getPermissions() returns 0?

查看:1198
本文介绍了Android的蓝牙低耗能:characteristic.getPermissions()返回0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个Android BLE应用程序,我想获得某种特性的权限。我已经设法获得其特性与characteristic.getProperties(),并且,它返回一个非零值,但是当我使用getPermission()方法返回0,即使我深信特性具有PERMISSION_WRITE_ENCRYPTED_MITM(0x00000040 )。

I am writing an Android BLE application, and I am trying to get the permissions of a certain characteristic. I have already managed to get the characteristic properties with characteristic.getProperties(), and it returns a non-zero value, however, when I use the getPermission() method it returns 0 even though I am sure that the characteristic has PERMISSION_WRITE_ENCRYPTED_MITM (0x00000040).

下面是一个code段

    // properties
    int properties = ch.getProperties();
    DebugWrapper.infoMsg("properties: " + properties, TAG); //returns non-zero value

    // permissions      
    int permissions = ch.getPermissions();  
    DebugWrapper.infoMsg("permissions: " + permissions, TAG); //returns zero value

我是不是做错了什么?有没有一种特定的方式来获得性能的权限,或者这是与Android的API有问题?

Am I doing something wrong? Is there a specific way to get the permissions of the characteristic or is this a problem with the android api?

我使用的API 19日和三星Galaxy Note的3测试我的程序。

I am using API 19 and testing my program on a Samsung Galaxy Note 3.

我AP preciate任何帮助。

I appreciate any help.

推荐答案

这看起来像一个问题与底层框架。 <一href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/bluetooth/BluetoothGatt.java#L237-L253">This链接显示$ c。该远程设备上发现服务/特性当框架执行$ C块。你可以看到,当新的 BluetoothGattCharacteristic 创建,权限参数总是传递为 0

This looks like an issue with the underlying framework. This link shows the block of code that the framework executes when discovering services/characteristics on the remote device. You can see when the new BluetoothGattCharacteristic is created, the permissions parameter is always passed in as 0.

此外,即使当特性后读,只有特性的值被更新,没有其他参数重置对象上。

Additionally, even when the characteristic is later read, only the characteristic's value is updated, no other parameters are reset on the object.

相反,它似乎Android的尝试处理一个<一个认证/权限问题href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/bluetooth/BluetoothGatt.java#L306-L346">trial和错误基础。换句话说,框架总是尝试一个基本的读/写,而且如果它失败认证原因,自动与请求认证的MITM再次尝试。

Instead, it seems Android attempts to handle authentication/permission issues on a trial and error basis. In other words, the framework always attempts a basic read/write, and if it fails for authentication reasons, it automatically tries again with MITM authentication requested.

这篇关于Android的蓝牙低耗能:characteristic.getPermissions()返回0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆