Obtainium icon indicating copy to clipboard operation
Obtainium copied to clipboard

Default Pseudo-Versioning Method switches back to APK Link Hash

Open 5FeetUnder opened this issue 1 year ago • 7 comments

Describe the bug

I changed the "Default Pseudo-Versioning Method" for an app to "Partial APK Hash" and updated the app. After a while the Method is back to "APK Link Hash" for that same app.

To Reproduce

  1. Edit an apps additional options in Obtainium
  2. Set default versioning method to partial APK hash
  3. Wait a while (probably for the next background update period)
  4. Get an app update notification from Obtainium for the app
  5. In the additional options the default Pseudo-Versioning method is now back to APK Link Hash

Please complete the following information:

  • Device: Sony Xperia 1 III
  • OS: Android 13
  • Obtainium Version: 1.0.2

Additional context

I wanted to try out that Pseudo-Versioning method for an app where the APK link is always the same without any version information (something like "website.of.dev/download/app.apk")

5FeetUnder avatar Feb 04 '24 11:02 5FeetUnder

Can you provide the app URL?

ImranR98 avatar Feb 04 '24 14:02 ImranR98

Of course. It happens for me with both proton calendar and proton drive:

https://proton.me/download/CalendarAndroid/ProtonCalendar-Android.apk

https://proton.me/download/DriveAndroid/ProtonDrive-Android.apk

5FeetUnder avatar Feb 06 '24 06:02 5FeetUnder

This happens to me as well, also with the 3 Proton apps, which don't have Github releases. Strangely enough it doesn't happen on every update check, but about half the time. So it is not reliably reproducible. It doesn't matter whether it is a manual or automatic background check. I also tried whether setting the APK Link Filter to either the APK name or even the full URL would make a difference, but both didn't help.

The in-app logs from the settings menu unfortunately don't provide any additional information to related events causing the switch to the APK Link Hash.

genericusername87 avatar Mar 05 '24 23:03 genericusername87

Here's what I think is happening. The APK link hash doesn't actually hash the entire APK because then you'd have to download the entire APK and that's not practical just for an update check. So instead we try to hash the first few kilobytes and we repeat this process a few times to make sure the hash is consistent. The reason I had to add this repetition is because for some reason that I can't figure out, some sources send a slightly different APK each time (maybe some file metadata changes). When this happens, Obtainium decides that APK hashing is not reliable and falls back to hashing the link.

I haven't actually checked the proton APK to confirm that this is what's going on but if it is then it could probably be communicated more clearly, so I'll add a UI element somewhere for that.

ImranR98 avatar Mar 06 '24 00:03 ImranR98

Thank you for the detailed explanation! This helps a lot to understand.

I have to admit, I totally missed out on #1292 and just discovered that this was implemented. Should have digged a little deeper when looking for previous issues. Using Direct APK Link instead of HTML source solved the problem for me.

Sorry for the inconveniences!

Don't know if a new UI element is necessary. I think copying your explanation about the Partial APK Hash logic to the HTML section of the Wiki might be enough ^^

genericusername87 avatar Mar 06 '24 17:03 genericusername87

Might be unrelated, but would I use HTML source or Direct APK link for these apps? Using HTML seems to crash my app but direct link is fine

vvirtues avatar Mar 15 '24 13:03 vvirtues

Here's what I think is happening...

Got around to actually checking the code, and what I wrote was incorrect. Obtainium does automatically adjust some settings but the "pseudo-versioning method" is not one of them. If partial APK hashing fails, it just errors out and expects the user to change the setting manually.

So I'm not sure what caused the behaviour reported by @5FeetUnder. Strangely it doesn't happen for me, at least right now.

ImranR98 avatar Mar 17 '24 08:03 ImranR98