Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on Android 10 #14

Open
RoProducts opened this issue Nov 27, 2019 · 10 comments
Open

Crash on Android 10 #14

RoProducts opened this issue Nov 27, 2019 · 10 comments

Comments

@RoProducts
Copy link

Using the pluginLib_3-6-0.jar on Android 10 results in the following crash :

java.lang.SecurityException: MODE_WORLD_READABLE no longer supported
  at android.app.ContextImpl.checkMode (ContextImpl.java:2788)
  at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:471)
  at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:461)
  at com.dsi.ant.plugins.utility.log.LogAnt.getDebugLevel (LogAnt.java:62)
  at com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc.bindAndRequest (AntPluginPcc.java:599)
  at com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc.requestAccess_Helper_SubMain (AntPluginPcc.java:568)
  at com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc.requestAccess_Helper_Main (AntPluginPcc.java:512)
  at com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc.requestAccess_Helper_AsyncSearchByDevNumber (AntPluginPcc.java:428)

on a Samsung Galaxy S10. Please fix as otherwise Ant+ cannot be used on Android 10.

Thank you

Robert

@iforpowell
Copy link

I have seen a crash report with this. I don't know what happens if I build targeting a lower API level I don't have a suitable device to test on at present. It's going to be getting the debug logging level from the ANT Services Settings App. Maybe it will actually work if the app is not installed. I would expect the code to deal with this case.

@harrychin
Copy link
Member

This is a known compatibility issue which we are planning to address soon in a new API release. In the meantime, catching the "SecurityException" thrown by "bindAndRequest" should also be a suitable workaround.

@RoProducts
Copy link
Author

Catching the exception is not a workaround as the device is not connected.

Please provide a fix asap.

Thank you

@harrychin
Copy link
Member

We've posted a release candidate branch with a new Plugin Library which you should be able to easily replace your existing JAR with here:

https://github.com/ant-wireless/ANT-Android-SDKs/tree/development/C.B6-P.B6RC/ANT%2B_Android_SDK

Let us know how your experience with it goes.

@RoProducts
Copy link
Author

Works out for me.

Thank you for your quick reaction.

@harrychin
Copy link
Member

I have seen a crash report with this. I don't know what happens if I build targeting a lower API level I don't have a suitable device to test on at present. It's going to be getting the debug logging level from the ANT Services Settings App. Maybe it will actually work if the app is not installed. I would expect the code to deal with this case.

You should be able to replicate the crash by installing the 3.8.0 version of the AntPlusPluginService which now targets API level 29, as it was mandated by Google to target newer API levels which trigger the new exception.

@hgoebl
Copy link

hgoebl commented Dec 5, 2019

You should be able to replicate the crash by installing the 3.8.0 version of the AntPlusPluginService which now targets API level 29, as it was mandated by Google to target newer API levels which trigger the new exception.

Well, maybe I misunderstand you when you say "replicate the crash with 3.8.0". I'd hope that there is no crash when switching to 3.8.0. Is this just throwing another exception?

The com.dsi.ant.plugins.utility.log.LogAnt shouldn't access preferences with "MODE_WORLD_READABLE". Has this been changed?

@harrychin
Copy link
Member

harrychin commented Dec 5, 2019

Well, maybe I misunderstand you when you say "replicate the crash with 3.8.0". I'd hope that there is no crash when switching to 3.8.0. Is this just throwing another exception?

The com.dsi.ant.plugins.utility.log.LogAnt shouldn't access preferences with "MODE_WORLD_READABLE". Has this been changed?

Correct, I was referencing the "crash" inside this issue, but it's just the SecurityException being left uncaught.

As you've intuited, com.dsi.ant.plugins.utility.log.LogAnt was using MODE_WORLD_READABLE, but that depreciation avoided linting/testing because Android references the API level for the package namespace from the AntPlusPluginService. It's only until after the service was updated, then the check for the SecurityException turned true for all apps which call into bindAndRequest(), which subsequently calls into LogAnt.

This version of the library no longer calls into a global shared preferences file for setting the debug level.

@marcoalt
Copy link

marcoalt commented Jan 5, 2020

sorry for the dumb question, how do I use the .aar file? Is it possible to provide a .jar, so that we can simply replace the faulty library? Thank you for your help.

@iforpowell
Copy link

Just use it the same as a .jar. Android studio and gradle will do the right thing. I have this in my build.gradle dependencies section.

implementation files('../libs/antpluginlib_3-8-0.aar')

If your not using Android studio or Gradle then time for some Googleing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants