Obtainium icon indicating copy to clipboard operation
Obtainium copied to clipboard

Figure Out Silent/Background Updates

Open ImranR98 opened this issue 3 years ago • 15 comments

This app is nearly exactly what I was just looking for, except I need unattended/background updates. I'm not an Android dev, what exactly would be required for you to be able to add this feature? I'm almost tempted to hire an Android dev that could build a Flutter plugin that would work for this project, because that would make this the perfect app updater 🤔

At a glance though, it seems like replacing install_plugin_v2 with flutter_install_app would provide the functionality you're looking for, is there a reason this plugin couldn't be used?

  • Without user action (Android 12 or higher):

If set, user action will not be required when all of the following conditions are met:

  • The app being installed targets API 30 or higher and is running on Android 12 or higher:
  • The app is the installer of record of an existing version of the app (in other words, this install session is an app update) or the installer is updating itself.
  • The installer declares the UPDATE_PACKAGES_WITHOUT_USER_ACTION permission.

AppInstaller.installApk('/sdcard/apk/app-debug.apk', actionRequired: false);

https://pub.dev/packages/flutter_install_app

Originally posted by @jonaharagon in https://github.com/ImranR98/Obtainium/issues/12#issuecomment-1255538404

ImranR98 avatar Sep 22 '22 21:09 ImranR98

This, Shizuku, is one thing Droidify uses. But I see in my Droidify settings that it isn't using this, rather session installer and still the updates are unattended. So not sure how he does it.

https://github.com/RikkaApps/Shizuku

S7venLights avatar Sep 24 '22 09:09 S7venLights

The new plugin does work, and updates done while the app is in the foreground will not have a prompt starting from the next version. Unfortunately, trying to update from a background process is causing an error I haven't been able to figure out. I've made a new issue for that on the plugin repo (https://github.com/felipheallef/flutter-app-installer/issues/1), but this is parked until they respond.

ImranR98 avatar Sep 24 '22 22:09 ImranR98

Just leaving a note that this new plugin uses a permission that is not allowed for Play Store apps, which I guess is part of why Droidify, Neo-Store, etc. are not there. Took down the Play Store listing as it's not as important as having silent updates.

ImranR98 avatar Sep 25 '22 07:09 ImranR98

Nice, this is exciting

S7venLights avatar Sep 25 '22 10:09 S7venLights

Just leaving a note that this new plugin uses a permission that is not allowed for Play Store apps, which I guess is part of why Droidify, Neo-Store, etc. are not there. Took down the Play Store listing as it's not as important as having silent updates.

Out of curiosity, what's that permission?

matchboxbananasynergy avatar Sep 28 '22 22:09 matchboxbananasynergy

The one mentioned in this thread 👆

UPDATE_PACKAGES_WITHOUT_USER_ACTION

S7venLights avatar Sep 29 '22 06:09 S7venLights

Apps like Neostore/Droidi-fy/GrapheneOS App Store, support unattended updates really well, if you want to have a look at their implementation.

Do those have the same limitations as the flutter plugin method above?

Universal-Igloo avatar Sep 30 '22 11:09 Universal-Igloo

GraoheneOS probably achieves this by being a system app. The other two have been mentioned in this thread 👍

S7venLights avatar Sep 30 '22 16:09 S7venLights

Those Apps are not Flutter-based as far as I know, so they probably just use the relevant Android API (the old one is PackageInstaller, idk about the new one). I used Flutter because learning Android would've been too big a time commitment, but I guess that comes with consequences 🥲

Either way, the plugin used right now does work, just not in background processes for some reason. Might be a Flutter limitation and not an issue with the plugin itself.

ImranR98 avatar Sep 30 '22 16:09 ImranR98

Ideas for implementation: Unattended background updates would be great and I'm anticipating users are probably going to be interested in 3 things I can think of:

  • Knowing what's been updated in the background. Requiring a menu/tab with a log of updates that can be cleared manually or after a specified period. Or a notification every time an apps are updated.

  • Knowing what changes were made to apps. Requiring a method to quickly view change logs/release notes See #42

and

  • People may want the option to only do manual updates to certain apps. Requiring a toggle in per app settings and a universal toggle for all apps.

S7venLights avatar Oct 04 '22 06:10 S7venLights

I'm not 100% certain, but I think this issue will be fixed once the changes from https://github.com/flutter/flutter/issues/13937 reach Flutter stable.

ImranR98 avatar Oct 06 '22 15:10 ImranR98

@S7venLights regarding your suggestions:

  • There is already code to notify users about which apps were updated in the background. I'll just uncomment/enable it when (if?) this issue is fixed.
  • For the manual update for specific Apps option, you can make a separate issue for that when this one is resolved.

ImranR98 avatar Oct 06 '22 15:10 ImranR98

The new plugin mentioned above has a dealbreaker - see #46. Switching back to the old one; this issue is blocked for now..

ImranR98 avatar Oct 07 '22 23:10 ImranR98

It actually did work for me. With the latest version I got the prompts back but before the update worked just fine as well.

ph00lt0 avatar Oct 08 '22 21:10 ph00lt0

It worked with 1 or even 2 apps sometimes, but would choke with larger numbers at least for me. May need to eventually look into learning enough to write my own Flutter plugin for this, or waiting for someone else to :(

ImranR98 avatar Oct 08 '22 21:10 ImranR98

I may be mistaken, but I think Protonmail just installed silently. I opened protonmail in Obtanium, clicked download but the android update dialogue never showed. But it has updated 🤔

S7venLights avatar Nov 04 '22 16:11 S7venLights

You probably already had the new update installed, so obtainium just skipped installation and incremented the version number. The installer plugin hasn't been updated in over a year so I don't see how it could do that.

ImranR98 avatar Nov 04 '22 16:11 ImranR98

Hey I have a question. Im not sure if it falls under the same category but some apps require a user choice (such as package architecture differences). Would it be possible to have Obtanium remember the selection and therefore not ask the user?

Kreuger avatar Dec 08 '22 17:12 Kreuger

I've Also wondered about this but I don't imagine there's a standardized way across all of Github to tell which architecture the apk is just from the file name hosted on Github. Obtainium would have to download all the APKs to read the architecture and that would be inefficient.

This may actually be a barrier to silent background updates if the plugin is ever updated.

S7venLights avatar Dec 08 '22 17:12 S7venLights

What I meant was once the user had chosen a package, it will always opt for that same one.

Kreuger avatar Dec 08 '22 20:12 Kreuger

Packages are not guaranteed to be the same between apps or even between releases, so any method to save these choices would be unreliable. Also the APK selection is not an architecture selection (APKs are often divided by arch, but no always - some apps have different APKs for the play store VS f-droid for nonfree dependencies, etc.).

ImranR98 avatar Dec 08 '22 20:12 ImranR98

Yes Im aware that theres more than one reason for multiple versions. That was just an example.

Kreuger avatar Dec 08 '22 21:12 Kreuger

Perhaps if there was a way for the user to set a regular expression per app for which APK to select. That way it's in our hands to control and adjust it when things change.

So Obtainium automatically selects the APK that contains ARM in the title or Free, etc. If it fails to find that expression, then it simply notifies the user to select as usual. If it works, it would save time and clicks.

But up to you, I don't feel like this is a pressing issue.

S7venLights avatar Dec 09 '22 07:12 S7venLights

DarQ is a flutter app that uses Shizuku.

AppManager installs apps in the background via local ADB (unfortunately not Shizuku and doesn't auto detect port); the prompt includes version number/name of the old and new version, as well as a list of added/removed activities and checks for trackers. The app provides a large amount of other functionality as well, though I personally only use it for background installs.

Edit: AppManager also has some method to initiate installs via intent using a secret token rather than opening the apk with it. This would be nice as an option as well.

Efreak avatar Jan 29 '23 20:01 Efreak

Appmanager is a great project, im[]agine it also had obtainium features

S7venLights avatar Jan 29 '23 21:01 S7venLights

Newer versions of Android allow you to silently update apps that you installed, using a normal supported API. Using something like Shizuku or ADB seems like overkill for something like this (and more difficult than the normal API method).

ImranR98 avatar Jan 29 '23 23:01 ImranR98

There's a new APK installer plugin available (44 days old): https://github.com/playbott/android_package_installer Seems to be broken right now though, will keep an eye on it.

ImranR98 avatar Feb 05 '23 03:02 ImranR98

Is it possible to add silent installations with root permissions, like fdroid? Maybe a toggle in the settings to choose silent installation method (when other methods are available). I think having Root and Shizuku as options would be nice.

Love the app, by the way. Thank you.

NaeemBolchhi avatar Feb 14 '23 17:02 NaeemBolchhi

I think firstly his focus in this app is security and root would undermine that, however, as an optional feature maybe it isn't a concern. Also read two messages up.

But also, this app is built with flutter plugins and implementation would depend on if those plugins exist.

S7venLights avatar Feb 14 '23 19:02 S7venLights

I have read the overkill part. I was only offering my perspective as another user of this app. To me, convenience takes priority. But I also recognize that not everyone would think the same. Thus I suggested a toggle.

I'm not an app developer myself, so I apologize if I happened to have asked for too much.

NaeemBolchhi avatar Feb 15 '23 02:02 NaeemBolchhi