derdilla / blood-pressure-monitor-fl

A cross platform app to save blood pressure values with export function
MIT License
72 stars 15 forks source link

v1.8.1: Export functionality seems broken #480

Open uli-on opened 1 week ago

uli-on commented 1 week ago

Before updating to the new fdroid release 1.8.2 I tried exporting the db but alas nothing happened on pressing the Export button. Can you please try and verify? Thanks!

(BTW, I didn't ignore-delete any preceding inquiry form here, I'm using the Octodroid app which doesn't display anything else than two empty text fields)

derdilla commented 1 week ago

That's surprising. I just tried it and got the shared file just fine.

  1. Can you think of any particularly weird entries you might have
  2. Since you seem to be using a non-standard android: does sharing work in general/needs special permissions
uli-on commented 1 week ago

Re 1. The only weird entry is a colour I entered when i tested the new data field. But that is supposed to be okay, right? Else I should have only numeric entries and nothing unusual there. What's not okay with that single colour, though, is ... that I can't remove that colour again, the "no colour"-field doesn't accept my finger taps. But that didn't really bug me since just now, that I want to iron out any potential wrinkles.

re 2. I can't spot the non-standard parts, i can only post them again, see below.

I can at least save bpm's prefs without problems, which is satisfying. I can't grant bpm permissions other than for "devices around" (retranslation mine).

EDIT i also tried exporting to the internal sd card but no luck.

——

Screen Metrics Width: 1080 px Height: 2022 px Display density: 460 dpi Drawable density: Unknown DPI: 460 Screen size: Normal

Software Android version: 13 SDK Int: 33 OpenGL ES version: 3.2 Google Play Services version: 24.43.36 (190400-691491885) [244336029] Build Number: 6.A.031.2

Hardware Manufacturer: Fairphone Device model: FP3 Device: FP3 Brand: Fairphone Board: FP3 Host: jenkins-agent-01 Product: FP3 Memory class: 192 MB Large memory class: 512 MB Max memory: 192 MB Free space: 32,3 GB Telephony: Enabled SD Card: Present: true, Emulated: true ABIs: arm64-v8a, armeabi-v7a, armeabi Online Processors: 8

derdilla commented 1 week ago

Yes, color only exports do work in my tests. I assume you have no default dir set?

Since I see no direct path to fixing I'm very sorry, if this becomes stale. At some point the native sharing code may get replaced by another library to support more platforms. This might randomly fix it and I will try to make sure to ping you, but unless this is really blocking for you I would try to avoid stabs in the dark like this.

My thoughts on the issue (nerd stuff)

What's really puzzling is that that code wasn't touched in ages and is as close to calling the same native functions as any other app as possible. If someone follows along and wants to have a look this start [here](https://github.com/derdilla/blood-pressure-monitor-fl/blob/main/app/lib/features/export_import/export_button_bar.dart#L186). Here are the basic operations: ```dart final path = join(await getDatabasesPath(), 'bp.db'); final data = await File(path).readAsBytes(); await _exportData(context, data, '$filename.db', 'application/vnd.sqlite3'); final settings = Provider.of(context, listen: false); if (settings.defaultExportDir.isEmpty || !Platform.isAndroid) { await PlatformClient.shareData(data, mimeType, fullFileName); } else { const userDir = PersistentUserDirAccessAndroid(); await userDir.writeFile(settings.defaultExportDir, fullFileName, mimeType, data); } } ``` And `shareData` (the branch that I _think_ gets called) is natively [implemented](https://github.com/derdilla/blood-pressure-monitor-fl/blob/main/app/android/app/src/main/kotlin/com/derdilla/blood_pressure_app/StorageProvider.kt#L55-L66) like: ```kt private fun shareData(data: ByteArray, mimeType: String, name: String) { val uri = sharableUriFromData(data, name) val sendIntent: Intent = Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_STREAM, uri) type = mimeType } val shareIntent = Intent.createChooser(sendIntent, null) startActivity(context, shareIntent, null) } private fun sharableUriFromData(data: ByteArray, name: String): Uri { if (!shareFolder.exists()) shareFolder.mkdirs() val sharablePath = File(shareFolder, name) if (sharablePath.exists()) sharablePath.delete() sharablePath.createNewFile() sharablePath.writeBytes(data) return getUriForFile(context, "com.derdilla.bloodPressureApp.share", sharablePath) } ``` and is looks like best-practice example on how to share data on android. Another thing to note is that technically the database file is currently in use by the app. But its file should be closed with the system since there are no writes (and reads should be from memory) when on this screen. With that being said: The way we export is not entirely idiomatic (closing and reopening the DB), afaik the apps sql library(sqflite) uses the sqlite library from the system so different behavior on FairPhone flavored android can't be ruled out entirely. (Although I think that would be a _really_ weird part to change for an OEM, even if privacy and foss orientated)

uli-on commented 1 week ago

I assume you have no default dir set?

I initially set my export path to the removable SD, habitually, cause I store my backups there. I then tried the internal SD ans also deleted my path preferences (trash can icon aside the custom path) but all 3 to no avail.

uli-on commented 1 week ago

At some point the native sharing code may get replaced by another library to support more platforms. This might randomly fix it and I will try to make sure to ping you, but unless this is really blocking for you I would try to avoid stabs in the dark like this.

After you mentioned my non-standard system i mulled on possible causes and remembered an article in a security blog that mocked Fairphones habit of delivering security updates with one year delay and selling it as "long term support" . And, yes, I had a security update one or two months ago, so might there be the cause? Or might it even be a recent update of the Google Play Services?

Thanks for your nerd stuff deliberations, looks like quite a bit of time you spent on that. Thanks and sorry 🙏!