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

Figure Out Silent/Background Updates #25

Closed
ImranR98 opened this issue Sep 22, 2022 · 82 comments
Closed

Figure Out Silent/Background Updates #25

ImranR98 opened this issue Sep 22, 2022 · 82 comments
Labels
high priority This issue is a high priority

Comments

@ImranR98
Copy link
Owner

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 #12 (comment)

@S7venLights
Copy link

S7venLights commented Sep 24, 2022

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

@ImranR98
Copy link
Owner Author

ImranR98 commented Sep 24, 2022

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 (felipheallef/flutter-app-installer#1), but this is parked until they respond.

@ImranR98 ImranR98 added the help wanted Extra attention is needed label Sep 24, 2022
@ImranR98 ImranR98 pinned this issue Sep 24, 2022
@ImranR98 ImranR98 changed the title Try Switching to a Different APK Install Plugin to Enable Background Updates Figure Out Silent/Background Updates Sep 24, 2022
@ImranR98
Copy link
Owner Author

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.

@S7venLights
Copy link

Nice, this is exciting

@matchboxbananasynergy
Copy link

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?

@S7venLights
Copy link

The one mentioned in this thread 👆

UPDATE_PACKAGES_WITHOUT_USER_ACTION

@Universal-Igloo
Copy link

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?

@S7venLights
Copy link

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

@ImranR98
Copy link
Owner Author

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.

@S7venLights
Copy link

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:

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.

@ImranR98
Copy link
Owner Author

ImranR98 commented Oct 6, 2022

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

@ImranR98
Copy link
Owner Author

ImranR98 commented Oct 6, 2022

@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
Copy link
Owner Author

ImranR98 commented Oct 7, 2022

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

@ph00lt0
Copy link

ph00lt0 commented Oct 8, 2022

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

@ImranR98
Copy link
Owner Author

ImranR98 commented Oct 8, 2022

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 ImranR98 added the high priority This issue is a high priority label Oct 29, 2022
@S7venLights
Copy link

S7venLights commented Nov 4, 2022

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 🤔

@ImranR98
Copy link
Owner Author

ImranR98 commented Nov 4, 2022

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 ImranR98 added the blocked This is dependent on external changes label Nov 6, 2022
@Kreuger
Copy link

Kreuger commented Dec 8, 2022

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?

@ImranR98
Copy link
Owner Author

Updated the links in the comment above - fixed a bug where the update checking task would only run once (instead of every N hours)

@ImranR98
Copy link
Owner Author

Updated the comment with bugfixes (task scheduling and notification related).

@S7venLights
Copy link

So excited to test!

ImranR98 added a commit that referenced this issue Aug 25, 2023
Enable Background Updates (#25)
@ImranR98
Copy link
Owner Author

Released: https://github.com/ImranR98/Obtainium/releases/tag/v0.14.0-beta

There is still the problem with install results not being sent back, but I'll open a separate issue for that (I really want to see the purple check on #25 🥲).

There was discussion about unofficial install methods like root and Shizuku. I don't plan on adding those personally but any PRs are welcome.

@Kreuger
Copy link

Kreuger commented Aug 26, 2023

Is there a reason you don't plan to add support for root?

@S7venLights
Copy link

The idea that started this app was a more secure way to install apps, so I guess root is not a priority for Imrans spare time

@S7venLights
Copy link

S7venLights commented Aug 26, 2023

I was just coming to say though that so far 2 of my apps that need updates, did not background install yet. Used on the zip version you shared.

I've just installed the latest version.
Will test.
Congrads on your milestone though! 😅

Question, how does background update determine which And pick to use (Architecture wise)?

@ImranR98
Copy link
Owner Author

ImranR98 commented Aug 26, 2023

Is there a reason you don't plan to add support for root?

Not against it, but it's unlikely I'll know how to do it, given that even using the official Android APIs took so long to figure out (and I don't have rooted devices to test with). Wouldn't be a high priority either way but you could open an issue for it - could always get picked up by someone.

so far 2 of my apps that need updates, did not background install yet.

Criteria for an app to be installed silently:

  • Only 1 APK available after applying any filters you set (so you don't need to be present to manually pick an APK)
  • The app was originally installed or last updated by Obtainium
  • Your OS SDK version must be at least 30 (Android 11)
  • The app being updated must target an SDK that is, at most, 3 less than your OS

So I'm guessing those apps don't fulfill one or more of these.

Question, how does background update determine which And pick to use (Architecture wise)?

Same as in the foreground, by file name (if "Attempt to filter APKs by CPU architecture if possible" is enabled). If there's more than one APK available after applying all filters then it doesn't install silently.

@ImranR98 ImranR98 unpinned this issue Aug 26, 2023
@ImranR98 ImranR98 removed help wanted Extra attention is needed blocked This is dependent on external changes labels Aug 26, 2023
@rollingmoai
Copy link
Contributor

Android 11? You mean Android 12 (which you even mentioned in the first comment)?

@S7venLights
Copy link

Okay thanks, any guide you can link to, to use regular expressions to filter APKs?
Also any way to globally toggle 'Attempt to Filter APK by Architecture' and choose a preferred architecture?

@Efreak
Copy link

Efreak commented Aug 28, 2023

@S7venLights I just use .*arm64.* for my regex on most packages.

@S7venLights
Copy link

S7venLights commented Aug 30, 2023

For Brave browser what regular expression can one use, I've tried a few:
.Bravearm64Universal.
Bravearm64Universal.apk
.arm64.

Note I also have a regular expression set for releases in Brave: ^Release

@zsolt-donca
Copy link

Are there any plans to make silent background update configurable on the individual application level? The reason I'm asking is that while generally I welcome silent background updates for most apps, I would like to still manually update some of my apps, such as Immich, where they sometimes break compatibility on new releases between server and mobile client (they are still in very active development and thus can afford it).

@ImranR98
Copy link
Owner Author

@zsolt-donca you already can - there's a toggle at the bottom of the app options.

@NaeemBolchhi
Copy link

For Brave browser what regular expression can one use, I've tried a few: .Bravearm64Universal. Bravearm64Universal.apk .arm64.

Note I also have a regular expression set for releases in Brave: ^Release

Just 64Universal should work for you.

@ImranR98
Copy link
Owner Author

ImranR98 commented Aug 31, 2023

Android 11? You mean Android 12 (which you even mentioned in the first comment)?

You're right. Not sure how I ended up thinking it was SDK 30. Will be corrected soon.

@S7venLights
Copy link

So happy this feature is here, well done again Imran 🙌

@zsolt-donca
Copy link

@ImranR98 I'm sorry but I can't find it. Can you be more specific?

@S7venLights
Copy link

S7venLights commented Aug 31, 2023

@zsolt-donca

  1. In Obtainium, Click on the desired apps logo
  2. Click the pen icon 🖋️
  3. Scroll down to the last option "Exempt from Backround update"
  4. Toggle that on

@zsolt-donca
Copy link

Thank you, @S7venLights , I swear I went through the same menu but did not find it 😁

@S7venLights
Copy link

I'm not why, but I've not been getting BG updates for a while now.
The update check task works but nothing is installing in the background, I have to manually download.
Also if I manually Download Obtainium updates and minimize the app, I get the 'Obtainium must be open to install updates' notification.

Not sure if it's related but I do get a consistent error from Collabora Office (logs shared below). Even though I set it to exempt from background updates and auto-select highest version and No version Detection. With these settings or default settings, it always says: 'No App was found with that ID or Name'

additionally the app FFShare always gives an error on install: Cannot install an older version of an App: [com.caydey.ffshare]

These may be separate issues but I thought I'd post here first before opening new issues.

Logs:
2023-09-14 10:03:12.148: info: Cleared 6 logs (before = 2023-09-07 10:03:11.900054, after = null)

2023-09-14 10:03:16.864: info: BG update task 666: Started (71).

2023-09-14 10:03:20.532: info: BG update task 666: Got error on checking for com.collabora.libreoffice 'No App was found with that ID or Name'.

2023-09-14 10:03:20.533: info: BG update task 666: Will continue in 1 seconds (with com.collabora.libreoffice moved to the end of the line).

2023-09-14 10:10:31.525: info: BG update task 667: Started (71).

2023-09-14 10:22:15.884: info: BG update task 667: Got error on checking for com.collabora.libreoffice 'No App was found with that ID or Name'.

2023-09-14 10:22:15.884: info: BG update task 667: Will continue in 4 seconds (with com.collabora.libreoffice moved to the end of the line).

2023-09-14 10:22:21.225: info: Cleared 7 logs (before = 2023-09-07 10:22:20.956947, after = null)

2023-09-14 10:22:26.007: info: BG update task 668: Started (1).

2023-09-14 10:22:27.832: info: BG update task 668: Got error on checking for com.collabora.libreoffice 'No App was found with that ID or Name'.

2023-09-14 10:22:27.832: info: BG update task 668: Will continue in 9 seconds (with com.collabora.libreoffice moved to the end of the line).

2023-09-14 10:22:41.935: info: BG update task 669: Started (1).

2023-09-14 10:22:45.583: info: BG update task 669: Got error on checking for com.collabora.libreoffice 'No App was found with that ID or Name'.

@ImranR98
Copy link
Owner Author

@S7venLights could you open another issue

@rollingmoai
Copy link
Contributor

Root and Shizuku installation is now implemented in #1184 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority This issue is a high priority
Projects
None yet
Development

No branches or pull requests