izivkov/CasioGShockSmartSync

Limit syncing to paired watches

tomasz-c opened this issue · 44 comments

Is your feature request related to a problem? Please describe.
Currently, the app has something like auto-pairing.
I observed a situation where a watch that was not paired with my smartphone triggered (when trying to sync) my calendar entries to be sent to it.

To repeat this:
Restore to factory settings (or unpair) watches A and B.
We pair watch A with the official Casio app on smartphone 1, watch B with CasioGShockSmartSync on smartphone 2.

Let's turn off the CasioGShockSmartSync app on smartphone 2 (although in my case it was on) and wait for watch A to sync. It connected to smartphone 2, from which the calendar entries (REM) were sent.

Maybe someone with access to two watches and smartphones would be able to confirm this, but it seems to me that this is repeatable.

Describe the solution you'd like
It seems to me that there would be a useful option that would allow only watches that were previously paired to sync. Without this, our calendar entries can go to other people, at work, school or on the bus :)

By the way, I wanted to thank you for creating and developing this application.

@tomasz-c OK, good point!

Here is what the app currently does:

  • The first time a watch tries to connect, and no other watches are paird ("No Watch" is displayd on the app) the app will pair with the watch automatically.
  • From then on, it will only pair with the same watch until you press the "FORGET" button.
  • If you try to connect another watch, it will fail.

You can test this by resetting your watch to factory default and then try to connect. This will fail because the Bluetooth ID of the watch changes when reset, equivalent to connecting a new watch. To connect the watch, you must press the "FORGET" button. (Prior to version 11.9, I have gone back and forth allowing all watches to auto-connect because some people have requested auto-syncing multiple watches, but now only one watch can connect until "FORGET" is pressed).

Now, the only way somebody else can connect to the watch is if they are running the app and have not yet paired it with a watch. This can happen when the watch auto-syncs, and they are nearby, like on a bus (a very rare event, I can only hope this app is popular enough for random people to run it on the same bus). In this case, they will not be able to see your Google reminders in the app, but it is possible to send their reminders to your watch, which is, of course, a problem.

Auto-pair is generally a good feature. The app can connect to watches ad-hoc, even if they are not in the supported list. People like this feature, and I would like to keep it.

To address the rare possibility of sending the wrong reminders, I will arrange the app not to send reminders if this is the first time they have connected to this watch.

@tomasz-c The scenario you described in your comment is kind of expected behavior though. If watch A was previously connected to this app, it simply connected to this app again and got reminders from it. The same reminders will show up in the official app.

If you really wanted only watch B to connect to this app, pair it, and do not press the "FORGET" button. Watch A will not connect to the app. This is what should happen in version 11.9 and later of this app. Let me know if this is not what you see.

Generally, I recommend running only one app, not both.

If you really wanted only watch B to connect to this app, pair it, and do not press the "FORGET" button. Watch A will not connect to the app. This is what should happen in version 11.9 and later of this app. Let me know if this is not what you see.

The question here is the pairing attempt? (long press on the mode button). If so, on the app version 12 I manage to repeat it.

  • I clear the app data,
  • I reset the watch,
  • I pair the watch, disconnect, at the bottom in the app displays my watch model,
  • I reset the watch and try to pair, (without using FORGET) and the loading wheel is displayed and the watch connects to the app,
  • I disconnect watch B, without using FORGET press pairing on watch A (not main), and it succeeds, on the application at the bottom the watch model changes, the connection animation is displayed and the screen loads after the connection.

Of course, the first request was not for this scenario, but when the watch tries to synchronize time. But this is the fastest way I can test it.

From my observations it seems that:

  • I have my watch (2) paired with my Casio G-Shock Smart Sync app and do not use FORGET
  • watch 1 (not mine) tries to automatically synchronize the time at, for example, 6:30 a.m., and is in range of my smartphone,
  • this automatically pairs watch (1) with my Casio G-Shock Smart Sync app (a different model appears at the bottom) and sends my reminders to it,

Generally, I recommend running only one app, not both.

I only use your app. Watch A and smartphone 1, are not mine. And it is on it that my calendar reminders appear :)

OK, this should not happen. I will investigate.

I did some tests with my two watches, GW-B5600 and GAB-2100, and the app worked as expected for me (with some small display issues, which I will fix in the next release). Basically, if the watch is already paired, another watch cannot connect unless the "FORGET" button is pressed. I made a video to ensure we are on the same page:

Watch Connection Video

If you actually connect and are able to get to the TIME screen without forgetting, there may be some problem saving to the LocalStorage of your phone, since the paired watch info is stored there. I'm hoping that this is just a display issue, as shown in the video.

I will try with a few other phones tomorrow.

Regards

@tomasz-c Here are a few things to try:

  • Make sure you have all permissions for the app enabled, especially read/write permissions.
  • Try using a different phone with the two watches. This will eliminate the posibility that the problem is related to the phone setting/Android version.

Regards

@tomasz-c Here are a few things to try:

  • Make sure you have all permissions for the app enabled, especially read/write permissions.
  • Try using a different phone with the two watches. This will eliminate the posibility that the problem is related to the phone setting/Android version.

I will check it and let you know.
Currently, I have recorded a video of how the application behaves on my smartphone, so I am sharing it:
https://filebin.net/vat5a7wdpupfe770/casio.webm

I will check it and let you know. Currently, I have recorded a video of how the application behaves on my smartphone, so I am sharing it:

The application is launched immediately after clearing the data.
0:03 - information about the program, with visible version,
0:13 - GST-B500 pairing
0:23 - disconnected
0:32 - MSG-B100 pairing
0:43 - disconnected
0:50 - GST-B500 pairing
0:56 - disconnected

I didn't use FORGET here.
This is Android 14, tested on the v12.0 app from Fdroid and Google Play.
By the way. If you release a new official version, would it be possible to include on GitHub the apk there in addition to the source code, as other projects do? This would allow to test new versions quickly.

Regards

On Android 10 with your application, this situation does not occur, the second watch does not pair, it has ERR.
After restarting the application, I can pair the second watch without using FORGET, but this is probably intentional.

On Android 14, there is no read/write access (data access) in the permission settings, so you can't grant it even manually. On Android 10 this is possible. So I guess you had a good idea to check it out.
I don't know which Android version you are using, maybe it's due to a change: https://developer.android.com/about/versions/11/privacy/storage

OK, thanks for helping thack this issue. I's running Android 11, so this change must be new, possible since android 14. I will look into getting it to work with Adroid 14, and aslo making other small fixes. Should take a couple of days.

So, looks like the Android Version is not causing the problem. I ran the app with an Android 14 emulator (Pixel 3a API 34), and I can read and write from local storage.
Which phone make and model are you using?

I'm using OnePlus 6 running crDroid which is based on LineageOS.

I checked the application in App Manager and there are two permissions with data access and the status "revoked", even though in the application settings I have the status "No permissions denied":

Screenshot_20240207-180348_Permission controller
Screenshot_20240207-173557_App Manager

I added permissions manually via adb:

adb shell pm grant org.avmedia.gshockGoogleSync android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant org.avmedia.gshockGoogleSync android.permission.WRITE_EXTERNAL_STORAGE

They appeared in App Manager (granted):

Screenshot_20240207-173623_App Manager

But it didn't help and the application works the same.

Unfortunately, I cannot check it on another smartphone with Android 14.
I understand that since I have an unofficial Android installation, there may be a problem here somewhere, but overall crDroid works very well for me and I haven't had any problems with it.

So we'll probably have to stop looking for the cause until someone else is able to confirm it on stock Android 14.

Regards

OK, np.
I noticed that in your "TIME" screen, the tempearure is formatted incorrecly, something like "24 st C" as opposed to "24°C. I'm using localization and have not hardcoded this simbol. Maybe you know if this is specific to the Polish language on Android. I could not find anything related to thes issue on the internet.

OK, nevermind, "st" i short for "stopnie". or "degrees". Is this normal?

Yes, that's a shortcut. Anyone would understand it, but it's not commonly used and looks a bit strange. Maybe someone uses it in some literary (non-technical) texts. I think it would be better to use °C. I have no idea why Android shows it this way for the Polish language. In Android battery settings and in the weather on the screen, the temperature is given as °C. So it looks like Android itself is not using its interpretation.

@tomasz-c I have updated the app to use DataStore instead of SharedPreferences. I think this will address the problem you are experincing on your Android 14 phone, and also it is the recommenerd method to use now. The app will automatically migrate your configuration, so the process should be seamless. You might want to give it a try, and let me know how it goes

I have placed the APK on my Google Drive, since I have not figured out how to build an APK on GitHub yet. The code for this APK is in branch "pairing", if you like to build it from source. (If you are familiar with creating APK's on GitHub, feel free to contribute)

This branch also fixes a number of display issues, as well as closing the loophole of getting the incorrect reminders for unpaired watches.

I will do some more testing as well, and if there are no issues, I will merge to main and create another relase.

Cheers,
Ivo

Thank you very much. I'd like to test it, but I can't download this file from Google Drive, is it marked as private?

It works! Now on Android 14 without using 'FORGET' the second watch is unable to pair, it displays 'ERR'.

When it comes to building Android applications, I have no experience. I thought you could just attach an APK file you built yourself, e.g. the one for Google Play. But I read the article and it looks like it's not that easy:
https://blog.dhina17.dev/build-and-share-android-apps-with-ease-using-github-actions

Thank you for this change in the program. It will be useful in the future when more users will have newer Androids.

Edit:
I have one more question. Is it the correct behavior of the application that after closing it and reopening it, I have to use the 'FORGET' button to pair even the watch that was last paired (and is displayed at the bottom)?
It doesn't bother me, I just have a question whether it's supposed to be like that.

Edit 2:
It seems that without restarting I also have to use 'FORGET' to connect it again after disconnecting the same watch.
I suspect that this may cause it to not want to automatically synchronize the time. But I will check it and let you know.

Yes, I noticed a problem, I edited the previous comment, you probably already replied and didn't see it. Please take a look at them.

No, should not have to use FORGET to connect the same watch. Is this behavior only on your Android 14 phone? BTW, I don't think it is the Android version, but the os distribution.

The app 12.1 should be coming on the playstote soon, maybe try it and see any difference

Strange, I'll try with more phones. Seems like the new settings are not saved. I think the crDroid is super secure.

Can you try this:

  • Select some actions in the action screen.
  • go to the time screen
  • disconnect and restart the app
  • see if the newly selected actions are still selected.
    This will tell is if you are able to save your preference

I did some tests:

  • there is no entry in the application. phone and settings are remembered after restart,
  • I built version 12.1, I don't know if I did it correctly, but I got app-debug.apk, it works and presents itself as 12.1, but this version works the same as the previous one,
  • the most important observation - if I pair the watch in the Android system settings, I can reconnect without using 'FORGET', both after disconnecting the watch and restarting the application. So after pairing in the system, everything in the application seems to work correctly (I haven't tested automatic time synchronization yet)

I hope that such pairing in the system was not always required and I did not know about it. But probably not, because previously the app connected to all watches every time without pairing in the system.

I forgot to mention that I have Android without Gapps (I did not install it), so I do not have GSF (Google Services Framework), but this application in the Google Play store does not show that it is dependent on GSF.

Conclusion:

  • currently (after pairing in the system) the application seems to work as expected, I will let you know if the watch synchronizes automatically,
  • this action is fine for me, it doesn't bother me that I have to pair the watch in the system, unless there are some negative consequences that I don't know about,

Thank you for these changes to the application.
Regards.

OK, will leave it for now. I think it is some permissions related to BT for your device.

In the future, I will try ti install crDroid 14 on one of my phones and see if I can reproduce it.

I will leave this issue open in case somebody else want to chime in.

Thanks for all the feedback

Automatic time synchronization does not work. I waited for the watch to want to update, then it was visible that it was connecting and after a short while it displayed ERR. Connecting (bottom left button) and triggering actions (bottom right button) work properly, e.g. sending time to the watch.
I have no more ideas why it doesn't work for me. I will wait until you or someone else has access to Android 14. Not necessarily crDroid, just information that it works properly on any Android 14 is enough, then I will know that it is definitely something on my side.

Edit:
I will check the version from Google Play, because currently I tested it on a self-built APK.

I don't even have the official app on this phone. But it was running on another phone nearby. I will check synchronization if there is no official application nearby and let you know.
Thank you for your suggestion.

Edit:
Yes, I have the notification option turned on, at least for now for testing.

You're right! I set the watch to an hour just before the update, and if there was no other phone with the official application nearby, the synchronization worked :)
Thank you for the idea. I thought that if each watch is paired with its application on separate phones, there will be no conflict.

Edit:
I set a different synchronization time for myself, maybe if the watches don't talk to applications at the same time, it will change something.
Because now I tested nearby the second application and synchronization also works. But it may be a random situation, which one connects with first. I'll see.

Just keeping some notes about this issue for future reference.

Location of DataStore data file:
/data/data/org.avmedia.gshockGoogleSync/files/datastore/CASIO_GOOGLE_SYNC_STORAGE.preferences_pb

Simmilar issue found here:
https://issuetracker.google.com/issues/242755161

@tomasz-c
If you are comfortable with it, do you mind building the branch new-ble and testing it with your Android 14? This should address the issue of having to press the "FORGET" button with every connection, without manually pairing the watch.

I replaced my own implementation of the BLE interface with this library. This is supposed to be the "gold standard" when referring to BLE libs, so I hope this fixes the issue.

Note that this was a massive change, so you may encounter some small issues. I have seen the alarm screen display only 4 alarms instead of 5, but this is rare, and I cannot reproduce it now.

Thanks for your help in advance.

@izivkov
Of course, I was happy to test it. I was only able to do it now, so I checked the latest version 12.4.

  • if the watch is paired in the Android configuration, everything seems to work properly,
  • if my watch is unpaired and I use FORGET after the first and next connections, everything works fine,
  • if I do not use FORGET after the first connection, when I try to connect for the second time, the application crashes with the error:
time: 1709332930999
msg: java.lang.NullPointerException: getName(...) must not be null
stacktrace: java.lang.NullPointerException: getName(...) must not be null
	at org.avmedia.gshockapi.ble.GShockManagerImpl.isRequiredServiceSupported(IGShockManager.kt:161)
	at no.nordicsemi.android.ble.BleManagerHandler$4.onServicesDiscovered(BleManagerHandler.java:2282)
	at android.bluetooth.BluetoothGatt$1$5.run(BluetoothGatt.java:406)
	at android.os.Handler.handleCallback(Handler.java:958)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8244)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

Please keep in mind that I am using a custom ROM based on LineageOS. There have also been some recent changes with Bluetooth here:

Dropped the "switch to Bluetooth AIDL" change since it was causing problems for someone trying to enumerate bluetooth devices. Probably requires using the updated blobs from guacamole; we'll save that for kernel 4.19 changeover.

So maybe it's worth having someone else test it on the Android 14 stock ROM before taking any steps.
If you need to test the application, let me know.

Regards,

Automatic time synchronization does not work. I waited for the watch to want to update, then it was visible that it was connecting and after a short while it displayed ERR. Connecting (bottom left button) and triggering actions (bottom right button) work properly, e.g. sending time to the watch. I have no more ideas why it doesn't work for me. I will wait until you or someone else has access to Android 14. Not necessarily crDroid, just information that it works properly on any Android 14 is enough, then I will know that it is definitely something on my side.

Edit: I will check the version from Google Play, because currently I tested it on a self-built APK.

I'm having the same issue with auto time adjustment, but I do have the official app installed, what steps do I take to make sure it works properly?

  • First make sure the official app is not running. You can shut it down
    from the the Android settings -> Applications.

  • Test that time settings work manually. Set action "set time" and trigger
    it by short-pressing the lower-right button. If that works, the automatic
    time setting should work. There is no difference to the app how time
    setting was triggered.

  • Also, the app should be running when auto time sync takes place. It can
    be in the background, but still running. Sometimes, Android will swap it
    out of memory. What this means is that if you started the app within a few
    hours of auto sync, this should work.

Hope this helps, and let me know if it works for you.

Ivo

On Mon, Apr 1, 2024, 10:21 AM ppsasho @.***> wrote:

Automatic time synchronization does not work. I waited for the watch to
want to update, then it was visible that it was connecting and after a
short while it displayed ERR. Connecting (bottom left button) and
triggering actions (bottom right button) work properly, e.g. sending time
to the watch. I have no more ideas why it doesn't work for me. I will wait
until you or someone else has access to Android 14. Not necessarily
crDroid, just information that it works properly on any Android 14 is
enough, then I will know that it is definitely something on my side.

Edit: I will check the version from Google Play, because currently I
tested it on a self-built APK.

I'm having the same issue with auto time adjustment, but I do have the
official app installed, what steps do I take to make sure it works properly?


Reply to this email directly, view it on GitHub
#70 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA7M37VB6YYM7RHNTKX5GY3Y3EKHHAVCNFSM6AAAAABC2XA6VGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRZGM3TGNBXGM
.
You are receiving this because you were mentioned.Message ID:
@.***>

The action button works great and I've done it before but I could never get auto time adjustment to work, I'll try your suggestions now.

I think there should be at least 6 hours from last time set (manually or
automatic) for the automatic action to trigger.

On Mon, Apr 1, 2024, 10:40 AM ppsasho @.***> wrote:

First make sure the official app is not running. You can shut it down
from the the Android settings -> Applications.

Test that time settings work manually. Set action "set time" and
trigger
it by short-pressing the lower-right button. If that works, the
automatic
time setting should work. There is no difference to the app how time
setting was triggered.

Also, the app should be running when auto time sync takes place. It can
be in the background, but still running. Sometimes, Android will swap
it
out of memory. What this means is that if you started the app within a
few
hours of auto sync, this should work.

Hope this helps, and let me know if it works for you.

Ivo

On Mon, Apr 1, 2024, 10:21 AM ppsasho @.***> wrote:

Automatic time synchronization does not work. I waited for the watch to
want to update, then it was visible that it was connecting and after a
short while it displayed ERR. Connecting (bottom left button) and
triggering actions (bottom right button) work properly, e.g. sending time
to the watch. I have no more ideas why it doesn't work for me. I will wait
until you or someone else has access to Android 14. Not necessarily
crDroid, just information that it works properly on any Android 14 is
enough, then I will know that it is definitely something on my side.

Edit: I will check the version from Google Play, because currently I
tested it on a self-built APK.

I'm having the same issue with auto time adjustment, but I do have the
official app installed, what steps do I take to make sure it works
properly?


Reply to this email directly, view it on GitHub
#70 (comment)
#70 (comment)
,
or unsubscribe

https://github.com/notifications/unsubscribe-auth/AA7M37VB6YYM7RHNTKX5GY3Y3EKHHAVCNFSM6AAAAABC2XA6VGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRZGM3TGNBXGM
.
You are receiving this because you were mentioned.Message ID:
@.***>

The action button works great and I've done it before but I could never
get auto time adjustment to work, I'll try your suggestions now.


Reply to this email directly, view it on GitHub
#70 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA7M37RSTSD2QIW5W4HIJBDY3EMQLAVCNFSM6AAAAABC2XA6VGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRZGQYTINRQGM
.
You are receiving this because you were mentioned.Message ID:
@.***>

I'm not syncing it on purpose to see if it auto syncs, I'm on a POCO X3 PRO - version MIUI 13. I gave the app all necessary permissions to run in the background, removed it from battery restrictions and also used: IMG_20240401_112331.jpg

the app lock feature on MIUI that doesn't let it get closed. Also noticed when trying to change the minutes when it will sync it always goes back to 5 minutes when I Re-connect.

So, just to understand, is the auto time adjustment triggered and gets an error, or not triggered at all? If it is triggered, there is something else interfering with the connection, like the official app.

About settings the minutes, there maybe a small input bug, which I'll fix in the next release. After entering the number, touch the field again, to stop the blinking cursor. Then send to watch.

So, just to understand, is the auto time adjustment triggered and gets an error, or not triggered at all? If it is triggered, there is something else interfering with the connection, like the official app.

About settings the minutes, there maybe a small input bug, which I'll fix in the next release. After entering the number, touch the field again, to stop the blinking cursor. Then send to watch.

I actually checked my apps and forgot I deleted the official app so I hope interference is not the issue, But in the past when It tried to auto sync I would see the watch trying to pair with the phone, failing and leaving an error on the display for a moment. I'm waiting for the auto time to adjust and see if I get an error this time without the app.

Ok, seems like there is a problem setting the time to adjust value. It worked for me during testing, but not working at the moment. I'll have to investigate further. I plan to have another release around apr. 20th.

Ok, seems like there is a problem setting the time to adjust value. It worked for me during testing, but not working at the moment. I'll have to investigate further. I plan to have another release around apr. 20th.

I just got a notification, it connected flawlessly, I'm so glad it worked 😁

Fixed