Bug 29957 - Encrypted connection to bluetooth device fails on certain devices.
Summary: Encrypted connection to bluetooth device fails on certain devices.
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 5.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-05-11 17:19 UTC by Jon Goldberger [MSFT]
Modified: 2017-11-15 16:05 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Jon Goldberger [MSFT] 2015-05-11 17:19:19 UTC
## Description (from customer... can't repro due to not having bluetooth device or Xperia Android devices)

"currently we are Developing a Payment System with a Bluetooth device to read the bank card and do some other security stuff, but we are in some trouble lately, we cannot seem to get the Bluetooth connection working on xperia z1 with android 4.4.4 and xperia z2 with android 5.0.2 which miraculously worked with the android 4.4.4. version. The project seems to work with all the major brands like Samsung, HTC, Nexus Devices, Motorola, and so on, but somehow the project does not like Xperia models.

Here is the problem, we need to establish a secure Bluetooth Le connection with MITM protection, which means at the beginning of a send process the encryption should be started by the Android device, which works fine on the brands mentioned on top but some how not with the xperia models, I can see that all the routines are followed correctly in the debugger, but in our Bluetooth over the air sniffer I can clearly see that there is no Bluetooth encryption started, but the data is send anyways. Which might lead to security issues, so our Bluetooth le device is rejecting the data.

> To ensure that it is not an issue of our implementation or the Xperia implementation, we rebuild the app to some extend in native Android Java code, but here every thing works fine. 

I have no idea what is going on, it might be a threading issue but I can't seem to get the hang of it."

## Known devices affected
xperia z1 with android 4.4.4
xperia z2 with android 5.0.2 

## Notes 

Customer reports that ported code works in native java app. 

## Re: Test Project (from customer's support email")
"I included an early test project of mine, which has a lot of bug but shows the exact same behaviour, but to test the program you probably need one of our Bluetooth card readers, you can come back to me for this."
Comment 3 Jon Goldberger [MSFT] 2015-05-11 17:27:38 UTC
Possibly relevant form logcat:

>W/BluetoothAdapter( 2414): getBluetoothService() called with no BluetoothManagerCallback
>
>
>E/BluetoothServiceJni( 2414): SOCK FLAG = 0 ***********************
>
>
>I/BtOppRfcommListener( 2414): Accept thread started.
>
>
>D/LocalBluetoothProfileManager( 4712): LocalBluetoothProfileManager construction complete
>
>
>W/ContextImpl( 4712): Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1591 android.content.ContextWrapper.bindService:517 android.bluetooth.BluetoothPbap.doBind:164 android.bluetooth.BluetoothPbap.<init>:157 com.android.settings.bluetooth.PbapServerProfile.<init>:68 
>
>
>D/BluetoothManagerService( 996): checkIfCallerIsForegroundUser: valid=true callingUser=0 foregroundUser=0
>
>
>W/BluetoothAdapter( 4730): getBluetoothService() called with no BluetoothManagerCallback
>
>
>E/BluetoothServiceJni( 2414): SOCK FLAG = 3 ***********************
>
>
>D/DockEventReceiver( 4712): finishStartingService: stopping service
>
>
>D/AuthorizationBluetoothService( 1674): Received GmsCore event: Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.auth.be.proximity.authorization.bt.AuthorizationBluetoothService$AutoStarter }.
>
>
>E/AuthorizationBluetoothService( 1674): Proximity feature is not enabled.
>
>
>V/GmsCoreStatsServiceLauncher( 2107): Received broadcast intent Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.common.stats.GmsCoreStatsServiceLauncher }
>
>
>W/PackageManager( 996): Not granting permission android.permission.BLUETOOTH_PRIVILEGED to package girocard.girocard (protectionLevel=18 flags=0x8be44)
Comment 4 Jonathan Pryor 2015-05-12 17:37:29 UTC
@Goldberger: I may be blind, but I don't see any relevant output in logcat.txt:

> $ grep -i monodroid logcat.txt 
> D/dalvikvm( 6984): Trying to load lib /data/app-lib/girocard.girocard-1/libmonodroid.so 0x447c0580
> ...
> F/monodroid( 6984): cannot find libmonosgen-2.0.so in app_libdir: /data/app-lib/girocard.girocard-1 nor in runtime_libdir as: /system/lib/libmonosgen-2.0.so
> F/monodroid( 6984): Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
> F/monodroid( 6984): Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).

Ditto for pid 7000 and 7014. AFAICT, there is no Xamarin.Android process running in logcat.txt.
Comment 5 Jonathan Pryor 2015-05-12 17:37:29 UTC
@Goldberger: I may be blind, but I don't see any relevant output in logcat.txt:

> $ grep -i monodroid logcat.txt 
> D/dalvikvm( 6984): Trying to load lib /data/app-lib/girocard.girocard-1/libmonodroid.so 0x447c0580
> ...
> F/monodroid( 6984): cannot find libmonosgen-2.0.so in app_libdir: /data/app-lib/girocard.girocard-1 nor in runtime_libdir as: /system/lib/libmonosgen-2.0.so
> F/monodroid( 6984): Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
> F/monodroid( 6984): Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).

Ditto for pid 7000 and 7014. AFAICT, there is no Xamarin.Android process running in logcat.txt.
Comment 6 Jon Goldberger [MSFT] 2015-05-12 17:45:28 UTC
OK, sorry, I will ping the customer and have them re-provide the logcat output captured immediately after the issue occurs.
Comment 12 Jon Douglas [MSFT] 2017-11-15 16:05:30 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.

Note You need to log in before you can comment on or make changes to this bug.