ImranR98 / Obtainium

Get Android app updates straight from the source.
https://obtainium.imranr.dev
GNU General Public License v3.0
7.45k stars 163 forks source link

Default Pseudo-Versioning Method switches back to APK Link Hash #1373

Open 5FeetUnder opened 8 months ago

5FeetUnder commented 8 months ago

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:

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")

ImranR98 commented 8 months ago

Can you provide the app URL?

5FeetUnder commented 8 months ago

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

genericusername87 commented 7 months ago

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.

ImranR98 commented 7 months ago

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.

genericusername87 commented 7 months ago

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 ^^

vvirtues commented 6 months ago

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

ImranR98 commented 6 months ago

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.