izivkov / CasioGShockSmartSync

Apache License 2.0
112 stars 12 forks source link

The app doesn't work if location permission isn't granted. #71

Closed Nj0be closed 7 months ago

Nj0be commented 7 months ago

Describe the bug The app doesn't work if location permission isn't granted. If I grant the access to the location and I pair the watch, the app works fine. Even if I revoke the permission after pairing, the app still works fine. But if the first time I don't grant the access, the app won't work.

To Reproduce

  1. Open the app
  2. Refuse the location permission
  3. The app will crash
  4. If you open the app, it will not work

Expected behavior The app should work even without granting the location access.

Smartphone (please complete the following information):

Additional context I was watching the code and I tried compiling the app removing the location permission (private var PERMISSIONS = arrayOf\<String>() instead of Manifest.permission.ACCESS_FINE_LOCATION,). The app works perfectly. I opened this bug report because if it isn't strictly necessary to have the location on, i don't see why it should be mandatory. Otherwise the app is great and it's miles better than the Casio one. It's a really good project, I'm happy to help in the development if it's needed. Thanks

izivkov commented 7 months ago

I will take a look at this, but as far as I remember the localtion permissions were needed for BLE scanning. If you already have the watch paired, there is no need to scan for watches, and maybe this is why it works. If you press the "FORGET" button, it might have a problem working without the location permissions. Give it a try.

izivkov commented 7 months ago

It's a really good project, I'm happy to help in the development if it's needed.

I might take you up on this ;-). There are many improvements I like to make, and not enough time.

Nj0be commented 7 months ago

I will take a look at this, but as far as I remember the localtion permissions were needed for BLE scanning. If you already have the watch paired, there is no need to scan for watches, and maybe this is why it works. If you press the "FORGET" button, it might have a problem working without the location permissions. Give it a try.

I tried with the modded app (the app that doesn't require location permission) and it works even after pressing the "FORGET" button. I also tried cleaning data, cache, everything. I don't thing it's needed for my phone and watch to work.

It's a really good project, I'm happy to help in the development if it's needed.

I might take you up on this ;-). There are many improvements I like to make, and not enough time.

Nice! I honestly don't know Kotlin very well, it's my first experience with this language. I programmed in C/C++, Java, Python, etc... I don't think it will take me long to figure out how it works, but in the meantime if there is something easy to do I can get to work.

izivkov commented 7 months ago

Ok, I'm working on another issue at the moment, and I'll look into it in a few days. I must have had a reason to add this permission, maybe things have changed. What is your android version?

Nj0be commented 7 months ago

Ok, I'm working on another issue at the moment, and I'll look into it in a few days. I must have had a reason to add this permission, maybe things have changed. What is your android version?

Ok, this is a minor issue anyway. My android version is 13. Thank you.

izivkov commented 7 months ago

I have started a discussion here, about some ideas for new feature. What I have listed so far are pretty large sub-projects, but there will be smaller projects and bug fixes. Let us move the discussion there for ideas and contribution to the project.

I will look at the location permission issue shortly.

izivkov commented 7 months ago

@imBenjamin741 OK, about the location permission, I see that Android 11 and earlier require FINE_LOCATION when using BlueTooth:

https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#declare-android11-or-lower

On my Android 11 phone, the app does not attempt to scan when this parmission is not granted.

I will refine for higher Android versions, like 12, 13, 14, but I am not sure I can test them, since I do not have these phone. I will ask you to test with your devices.

Thanks, Ivo

Nj0be commented 7 months ago

@imBenjamin741 OK, about the location permission, I see that Android 11 and earlier require FINE_LOCATION when using BlueTooth:

https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#declare-android11-or-lower

On my Android 11 phone, the app does not attempt to scan when this parmission is not granted.

I will refine for higher Android versions, like 12, 13, 14, but I am not sure I can test them, since I do not have these phone. I will ask you to test with your devices.

Thanks, Ivo

Perfect, I am fully available for any kind of testing. By the way, my phone should be receiving a new Android update soon, so I can try it on Android 14 in the future as well.

Thank you for taking the time to address this issue, Beniamino

izivkov commented 7 months ago

@imBenjamin741 OK, I created a branch "location" which addresses this issue. Can you build and try with Android >= 12. If you have a phone with an older version of Android, please try as well.

Thanks for reporting this and for your help. Ivo

Nj0be commented 7 months ago

@imBenjamin741 OK, I created a branch "location" which addresses this issue. Can you build and try with Android >= 12. If you have a phone with an older version of Android, please try as well.

Thanks for reporting this and for your help. Ivo

Ok I tried with two different phones:

By the way, I've noticed that when I try to run the app on the Samsung phone from Android Studio, the watch is not detected. I have to install it and then I can run it after stopping the Android Studio "debugger" (the run action). This has nothing to do with the app, but I lost some time thinking it was an app problem.

The original permissions issue seems to have been completely resolved. Let me know if there is anything else I can do to help.

Thanks for your work and commitment to the project, Beniamino

izivkov commented 7 months ago

Great, thanks, I will merge with the main branch, but will not create a new release on PlayStore and F-DROID yet. Usually I wait for more fixes, and gives me a change to eun for a few days before making a release.

Thanks for your help.