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

CCTG Import does not work #162

Open
Kabelgleichung opened this issue Apr 4, 2022 · 14 comments
Open

CCTG Import does not work #162

Kabelgleichung opened this issue Apr 4, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@Kabelgleichung
Copy link

The "CCTG Import" option does not work in Version 2.3.5 on an unrooted phone. Whenever I select the option from the menu, the message "Im Moment kann der Modus leider nicht gewechselt werden. Bitte warte, bis alle Berechnungen abgeschlossen sind.", although no key matching is done at that moment.
As far as I unterstand, some file-chooser should appear when selecting the option and an exposure.db can be opened.

@mh-
Copy link
Owner

mh- commented Apr 4, 2022

Does it work after you kill and re-open the app?

@mh- mh- added the bug Something isn't working label Apr 4, 2022
@Kabelgleichung
Copy link
Author

Kabelgleichung commented Apr 4, 2022

No. I killed the app in settings using "force quit", re-opened the app, waited until "downloading diagnosis keys" finished and tried "CCTG Import", but the same message appears.

Edit: I tried on another device with root access, and the same message appears.

@mh-
Copy link
Owner

mh- commented Apr 4, 2022

Ok, so mode switching is blocked in your scenario. I will try to reproduce and fix that.
In the mean time, maybe if you temporarily set the device to airplane mode, this might help enable switching to the desired Companion App mode.

@Kabelgleichung
Copy link
Author

The workaround to enable airplane mode does not work, but I found the following workaround:
When I export the IDs from CCTG to companion first and then choose "CCTG import" without closing the app, I can open the database file.

@stephankn
Copy link

I can confirm the same behavior happens for me on Android 11. Also using 2.3.5. I freshly installed, so can't confirm it ever worked. For me also the CCTG export mode via sharing does not work. It just opens Companion in the same mode I had it earlier. If it was root mode, then I get the root warning. In demo mode it opens demo mode. And in import mode it opens a file chooser. Closing File chooser activity with back button leads to screen full of "please wait" indicators.

@mh-
Copy link
Owner

mh- commented Apr 5, 2022

And in import mode it opens a file chooser.

So if you chose the exposure.db that you copied from /data/data/de.corona.tracing/databases/exposure.db to e.g. the Downloads directory, import works?

Sharing from CCTG should of course work, maybe that's an issue with Android 11? I need an Android 11 device...

@stephankn
Copy link

It sounds like a permission issue. I looked into logcat for Errors and see this already happening once I try to export:

2022-04-05 16:19:11.631 14824-15429/? E/DatabaseUtils: Writing exception to parcel
    java.lang.SecurityException: Permission Denial: reading org.microg.gms.nearby.exposurenotification.ExposureFileProvider uri content://de.corona.tracing.microg.exposure.export/exposureDatabase/exposure.db from pid=20201, uid=1000 requires the provider be exported, or grantUriPermission()
        at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:848)
        at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:689)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:244)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
        at android.os.Binder.execTransactInternal(Binder.java:1157)
        at android.os.Binder.execTransact(Binder.java:1126)

So I am unable to export it to a file as well. I guess this is something out of scope for companion. But it might explain why it doesn't work as expected, due to not getting data properly. Maybe error handling could be improved? It seems to fall back into some mode it had earlier. As it never worked for me, this might be some unexpected state.
CCTG has all permissions granted. microg is the internal one of it. So no additional permissions possible there.

I do not want to mix up issues here. The issue initially described happens here as well. The workaround as described by @Kabelgleichung worked for me as well to switch modes. I am stuck now on another problem, that CCTG/microg is not giving me the data. @Kabelgleichung I am on Android 11/nonroot. What is your environment?

@JohaJung
Copy link

JohaJung commented Apr 5, 2022

I can confirm the initial bug for latest app version (2.3.5, did not use earlier versions) on my non-rooted Android 7 phone.
Kill/Restart or offline mode did not fix the issue, however the woraround described by Kabelgleichung in this comment worked as described.

@Kabelgleichung
Copy link
Author

So if you chose the exposure.db that you copied from /data/data/de.corona.tracing/databases/exposure.db to e.g. the Downloads directory, import works?

Yes. When I first shared the data from CCTG, wait until matching finished I can open the exposure.db from menu.

Sharing from CCTG should of course work, maybe that's an issue with Android 11? I need an Android 11 device...

I am having this issue on an Android 12 and Android 11 device. The Android 12 device is not rooted, the Android 11 device is rooted (LineageOS), @stephankn

@mh-
Copy link
Owner

mh- commented Apr 6, 2022

I just installed CCTG 2.18.1.0 on a new Android 11 device (rooted, but I don't think it makes a difference) and can export from CCTG e.g. to e-mail; and also share from CCTG to WAC without any problem.

@stephankn
Copy link

I recently got update to Android 12 based Miui 13.
In this version the export of exposure.db is possible. The SecurityException I mentioned earlier is gone.
So my state is sort of in line with the initial bug report. Directly opening companion has mode set to "normal mode (root)". On my unrooted device it is not possible to switch to "CCTG import".

With the above mentioned workaround, I used the "share" functionality to open the db. Then I could switch the mode to import. Opening directly now asks to select exposure db (I can export that to eg download folder).

I am not certain how useful it is to directly open the app without sharing a recent db. The user interface in case I refuse to select a file on the picker is showing only "please wait" indicators.
It might display cached results from earlier run. On the other side it is maybe not desired to display outdated data.

Could you fix the problem of mode switching and maybe display an activity/fragment in the modes where no exposure.db is available on how to load one?
In the "root" modes, it can directly access exposure db, but for other modes an import is required. Either by manually opening a file or by receiving it on a share intent.
I guess this is where the app ends up in an error state after it tried to open a non-accessible file and failed. Could it be, that backgroundThreadsShouldStop is only reset to false once it works on matching, which is never done, as it has no access to the DB, so it is in a dead-lock? Maybe not setting it to true from the beginning, but wait for actual processing to start?

@skyerjoe
Copy link

skyerjoe commented Apr 20, 2022

It seems that the security handling has changed on miui from 12 to 12.5

I could see this also on other apps or for ex. when I tried to install an apk from some file managers ( included also the mui standard one).

So, the function to export from cctg without root is not possible anymore on these devices.

Update: it seems with MIUI 13 everything works as it should thnx @stephankn for this info

@stephankn
Copy link

@skyerjoe maybe there was an issue with Miui 12 and 12.5, which would explain the SecurityException I had above. With Miui 13, the export works as intended. Import via sharing works as well. Changing manually the operation mode of the app fails with the initially reported problem.

@skyerjoe
Copy link

@stephankn
So I have to correct myself
Thx for clarifying it

My device will be get miui 13 on q2, so may it's to late then, I hope so xiaomi is known for surprises related to supporting his devices.

Best regards

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

5 participants