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

Exporting/Importing a keymap that can be triggered by other apps should preserve its UID #1120

Closed
4 tasks done
sudomain opened this issue Jan 12, 2023 · 4 comments
Closed
4 tasks done
Assignees
Labels
bug Something isn't working

Comments

@sudomain
Copy link

sudomain commented Jan 12, 2023

Developer TODO (don't remove)

  • create new branch. put issue number at start of name if not a very quick fix.
  • write tests. put issue number in comment
  • update documentation
  • merge and delete branch (don't squash because want commit history to see why I made changes)

Discord message link/email recipient

Describe the bug
I know the app is no longer developed, but if someone knows the import/export code, I think this should be fixed: I trigger some of my keymaps using shell scripts in Termux using the am tool:
am broadcast -a io.github.sds100.keymapper.ACTION_TRIGGER_KEYMAP_BY_UID --es io.github.sds100.keymapper.EXTRA_KEYMAP_UID 48df9264-da54-4bab-af80-ea53e1a70782

But if the keymaps were recently exported and imported (for example when migrating to a new Android device), then their UIDs change. My scripts stopped working which wasn't a big deal. I just copy/pasted the new UID's into the scripts and it only took a few minutes. It's just another step involved in a rare event such as a device migration, but since keymaps are given UIDs, they should probably be preserved.

To Reproduce
Steps to reproduce the behavior:

  1. Export keymaps with uids/triggered from other apps
  2. Import keymaps

Upload a backup of your keymaps. Follow the guide here

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: [e.g. OnePlus 6T] Pixel 2
  • Android version: [e.g. Android 10] 11

Additional context
Add any other context about the problem here.

@sudomain sudomain added the bug Something isn't working label Jan 12, 2023
@sudomain
Copy link
Author

sudomain commented Aug 4, 2023

Hmm... Backing up a map creates a zip containing a data.json file. This contains an uid with the correct uid needed to trigger the map from other apps. This means the back up code is fine, it's the restore code that assigning a random uid

Edit: The issue is [https://github.com/keymapperorg/KeyMapper/blob/81a438acd753178169f15cf2c05d4e0a4fc2890f/app/src/main/java/io/github/sds100/keymapper/backup/BackupManager.kt#L278] which assigns a random uid during restore. The random approach solves the problem of the restore process running into keymaps with conflicting UIDs. It also causes restored keymaps to not have their original UIDs, thus they can't be triggered via intent which relies on the UID. How should the restore function handle restoring a keymap that has a UID which already exists in KeyMapper? Overwrite? Discard? Prompt the user? It'd be nice if the schema had the epoch time of when a keymap was last modified, and just accept the newer one.

@sds100
Copy link
Collaborator

sds100 commented Aug 4, 2023

Since it is a universal unique identifier then I shouldn't even need to update the ID for conflict reasons. I'm thinking that I just overwrite any key maps that have the same UID, what do you think? The only situation where this would happen is if the same person exports and then imports the key maps they already have, which is quite unusual.

@sudomain
Copy link
Author

sudomain commented Aug 4, 2023

True. I was overthinking a somewhat contrived scenario with my message above 😆

@sds100
Copy link
Collaborator

sds100 commented Aug 6, 2023

implemented

@sds100 sds100 closed this as completed Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants