8

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).

Here is a code snippet

    // 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

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?

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

I appreciate any help.

KikiTheMonk
  • 985
  • 10
  • 24
  • how did you set permission for MITM thing. Also I am also not so much clear on process of Pairing thing and how to get callback if it not paired....any suggestion? – CoDe Jul 01 '14 at 10:57
  • The permissions are not being set form the android device, but they are set from the BLE hardware device that i am using – KikiTheMonk Jul 08 '14 at 09:58

1 Answers1

11

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.

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.

devunwired
  • 62,780
  • 12
  • 127
  • 139
  • This is very insightful. We're seeing the exact same issue, but for some reason the onCharacteristicChange callback is never being fired when we write a value to it. Any suggestions? – James Parker Oct 31 '14 at 16:07
  • 1
    Unfortunately, this suggests that the property is meaningless. – ThomasW May 08 '15 at 08:27