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

Rename account with jtx collection: IllegalArgumentException #1185

Open
rfc2822 opened this issue Dec 20, 2024 · 4 comments · May be fixed by #1198
Open

Rename account with jtx collection: IllegalArgumentException #1185

rfc2822 opened this issue Dec 20, 2024 · 4 comments · May be fixed by #1198
Assignees
Labels
bug Something isn't working

Comments

@rfc2822
Copy link
Member

rfc2822 commented Dec 20, 2024

During rename:

Couldn't propagate new account name to tasks provider
java.lang.IllegalArgumentException: Currently only Syncadapters are supported. Uri: (content://at.techbee.jtx.provider/tasks)
	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:155)
	at android.content.ContentProviderProxy.update(ContentProviderNative.java:685)
	at android.content.ContentProviderClient.update(ContentProviderClient.java:417)
	at android.content.ContentProviderClient.update(ContentProviderClient.java:406)
	at at.bitfire.davdroid.resource.LocalTaskList$Companion.onRenameAccount(LocalTaskList.kt:40)
	at at.bitfire.davdroid.repository.AccountRepository.rename(AccountRepository.kt:259)
	at at.bitfire.davdroid.repository.AccountRepository$rename$1.invokeSuspend(Unknown Source:15)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:832)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)

Steps to reproduce:

  1. Use DAVx5 with jtx Board, sync a collection.
  2. Rename the account and watch the logs.

Possible reason: rename accounts always expects an OpenTasks task app (and not jtx Board).

Further info: Also LocalTaskList.onRenameAccount should be moved to LocalTaskListStore.updateAccount.

@rfc2822 rfc2822 added the bug Something isn't working label Dec 20, 2024
@rfc2822 rfc2822 self-assigned this Dec 20, 2024
@rfc2822
Copy link
Member Author

rfc2822 commented Dec 23, 2024

I think the problem is that LocalTaskList.onRenameAccount always expects an OpenTasks-compatible task list, even if jtx Board is the current app.

We should probably call something like LocalTaskListStore.updateAccount(), which then does the correct thing according to the task list provider instead.

@rfc2822 rfc2822 assigned ArnyminerZ and unassigned rfc2822 Dec 23, 2024
@ArnyminerZ
Copy link
Member

Yup, reproduced correctly as stated:

Logs
Couldn't propagate new account name to tasks provider
java.lang.IllegalArgumentException: Currently only Syncadapters are supported. Uri: (content://at.techbee.jtx.provider/tasks)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
    at android.content.ContentProviderProxy.update(ContentProviderNative.java:653)
    at android.content.ContentProviderClient.update(ContentProviderClient.java:417)
    at android.content.ContentProviderClient.update(ContentProviderClient.java:406)
    at at.bitfire.davdroid.resource.LocalTaskList$Companion.onRenameAccount(LocalTaskList.kt:40)
    at at.bitfire.davdroid.repository.AccountRepository.rename(AccountRepository.kt:259)
    at at.bitfire.davdroid.repository.AccountRepository$rename$1.invokeSuspend(Unknown Source:15)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:832)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)

@ArnyminerZ
Copy link
Member

Okay, so after tumbling around for quite longer than I expected, I guess that the problem is that OpenTasks-compatible apps use the content provider as .../tasks, and Jtx uses (I think) .../collections:

https://github.com/TechbeeAT/jtxBoard/blob/develop/app/src/main/java/at/techbee/jtx/SyncContentProvider.kt#L140C42-L140C52

which is what holds the account:

https://github.com/TechbeeAT/jtxBoard/blob/a9c4c727e414a08b1d669236ac2675cb1c6f4342/app/src/main/java/at/techbee/jtx/database/ICalCollection.kt#L138-L144

Then the thing would be to check whether the provider is jtx board, and use /collections or use /tasks otherwise. Is this correct?

I've tried doing this, and it's still failing with "Currently only Syncadapters are supported". My question is also whether this is a problem of our own, or it's caused by Android, and we are simply trying to do something that is not supported.

@ArnyminerZ ArnyminerZ linked a pull request Dec 27, 2024 that will close this issue
4 tasks
@rfc2822
Copy link
Member Author

rfc2822 commented Dec 27, 2024

Okay, so after tumbling around for quite longer than I expected, I guess that the problem is that OpenTasks-compatible apps use the content provider as .../tasks, and Jtx uses (I think) .../collections:

https://github.com/TechbeeAT/jtxBoard/blob/develop/app/src/main/java/at/techbee/jtx/SyncContentProvider.kt#L140C42-L140C52

which is what holds the account:

https://github.com/TechbeeAT/jtxBoard/blob/a9c4c727e414a08b1d669236ac2675cb1c6f4342/app/src/main/java/at/techbee/jtx/database/ICalCollection.kt#L138-L144

Yes, during rename, we want to change the account.

  1. jtx Board has the ACCOUNT_NAME in Collection – the jtx Board database should however not be relevant (or is only indirectly). The relevant lines are in JtxContract:

https://github.com/TechbeeAT/jtxBoard/blob/a9c4c727e414a08b1d669236ac2675cb1c6f4342/app/src/main/java/at/techbee/jtx/contract/JtxContract.kt#L1189-L1199

So if we want to update the account name in jtx Board, we have to update the Collections using the correct Collections.CONTENT_URI "as sync adapter", see the other collection updates in ical4android.

It's however possible that jtx Board refuses to change the account when we request it. In this case, we would have to open a feature request for jtx Board. But even then it shouldn't try the wrong (OpenTasks) URI for jtx Board.

  1. Tasks.org / OpenTasks on the other side use the method that's currently used.

Then the thing would be to check whether the provider is jtx board, and use /collections or use /tasks otherwise. Is this correct?

Yes, but I think the check shouldn't be in onRename. Instead, we should probably call something like LocalTaskListStore.updateAccount() (with LocalTaskListStore according to the current task provider type, so LocalJtxCollectionStore for jtx Board and LocalTaskListStore for the others), which then does the correct thing according to its task list provider instead.

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
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants