android - Security issues when using Content Provider in BluetoothGattCallback -


i observing strange permission related issue when oncharacteristicchanged() callback called.

i writing android service communicates le (low energy) sensor in peripheral role using bluetooth le apis. enable notification on characteristic on sensor notifies changes.

when oncharacteristicchanged() callback called, service retrieves characteristic's value , stores in content provider. access content provider restricted signature level permission. application hosting service has permission.

here simplified code of oncharacteristicchanged:

@override public void oncharacteristicchanged(final bluetoothgatt gatt, final bluetoothgattcharacteristic characteristic) {     super.oncharacteristicchanged(gatt, characteristic);      log.v(tag, "pid=" + android.os.process.mypid() + " uid=" + android.os.process.myuid());      uri uri = mcontext.getcontentresolver().insert(uri_values, characteristic.getvalue()); } 

i getting security permission when insert() api called in above callback.

02-27 15:15:32.752: v/proxygattclient(10511): pid=10511 uid=10177 02-27 15:15:32.792: e/persistenceutil(10511): error saving reading database 02-27 15:15:32.792: e/persistenceutil(10511): java.lang.securityexception: permission denial: writing com.example.content.mycontentprovider uri content://com.example/values pid=1336, uid=1002 requires com.example.permission.access_content, or granturipermission() 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.content.contentprovider$transport.enforcewritepermissioninner(contentprovider.java:445) 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.content.contentprovider$transport.enforcewritepermission(contentprovider.java:382) 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.content.contentprovider$transport.insert(contentprovider.java:210) 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.content.contentresolver.insert(contentresolver.java:917) 02-27 15:15:32.792: e/persistenceutil(10511):   @ com.qcl.vh.ble.proxygattclient.oncharacteristicchanged(proxygattclient.java:101) 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.bluetooth.bluetoothgatt$1.onnotify(bluetoothgatt.java:425) 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.bluetooth.ibluetoothgattcallback$stub.ontransact(ibluetoothgattcallback.java:397) 02-27 15:15:32.792: e/persistenceutil(10511):   @ android.os.binder.exectransact(binder.java:388) 02-27 15:15:32.792: e/persistenceutil(10511):   @ dalvik.system.nativestart.run(native method) 

running 'adb shell ps' shows pid=1336, uid=1002 process id of "com.android.bluetooth" process. above stack trace shows, content provider's insert being called in bluetooth process's context. of course process not have permission write in content provider , exception.

when log process's id within oncharacteristicchanged() shows pid=10511 uid=10177, process id of process hosting application.

can explain above behavior? why insert() called on blueooth process's context while callback running in application's process.

i running on samsung galaxy s3, android 4.3.

thanks

the answer right in error, believe.

requires com.example.permission.access_content

you must allow others read contentprovider. read more here

could show how know host application has these permissions? i've asked similar question in past, here:

what's difference between android:permission="packagename.permissions.browser_provider" , android:granturipermissions?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -