Updater: add configurable update check frequency and update behavior#126
Open
misakazip wants to merge 1 commit into
Open
Updater: add configurable update check frequency and update behavior#126misakazip wants to merge 1 commit into
misakazip wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds two new user-configurable settings to the Updater app — update check frequency (Daily / Weekly / Monthly / Manual only) and update behavior (auto-install / auto-download + notify / notify-only) — and wires the supporting flow so that pre-install notifications can trigger an install via a new InstallReceiver. The previously hardcoded 6-hour periodic check interval is replaced by the user-selected frequency, with 0 meaning "manual only" (the periodic job is cancelled).
Changes:
- Replace the hardcoded
INTERVAL_MILLISinPeriodicJobwithSettings.getCheckFrequency(...), including a "manual only" path that cancels the periodic job. - Plumb a new
update_behaviorsetting and aUSER_REQUESTED_INSTALLintent extra throughService/Service.onDownloadFinishedso the service can stop after the metadata fetch (notify only) or after verification (auto-download), with a newInstallReceivertriggered by notification actions. - Add
NOTIFICATION_ID_AVAILABLE/NOTIFICATION_ID_DOWNLOADEDnotifications and the associatedavailablenotification channel, plus all new strings and array resources for the twoListPreferenceentries insettings.xml.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/seamlessupdate/client/Settings.java | Adds KEY_CHECK_FREQUENCY / KEY_UPDATE_BEHAVIOR, getter helpers, behavior constants, and rescheduling on frequency change. |
| src/app/seamlessupdate/client/PeriodicJob.java | Replaces fixed 6-hour interval with Settings.getCheckFrequency; cancels job when value is 0. |
| src/app/seamlessupdate/client/Service.java | Branches on update behavior to either skip download, skip install after verify, or proceed; threads installAfterVerify into onDownloadFinished. |
| src/app/seamlessupdate/client/NotificationHandler.java | Adds new IDs, an available channel, and showUpdateAvailableNotification / showUpdateDownloadedNotification with an install action. |
| src/app/seamlessupdate/client/InstallReceiver.java | New broadcast receiver invoked from notification action; starts Service with USER_REQUESTED_INSTALL=true. |
| AndroidManifest.xml | Registers the new InstallReceiver. |
| res/xml/settings.xml | Adds the two new ListPreference entries. |
| res/values/strings.xml | Adds titles, entries, notification text, and action labels. |
| res/values/arrays.xml | Adds entries/values arrays for frequency and behavior. |
| res/values/config.xml | Adds default values for check_frequency (24h) and update_behavior (auto-install). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+214
to
+246
| void showUpdateAvailableNotification() { | ||
| final Notification.Action action = new Notification.Action.Builder( | ||
| Icon.createWithResource(service.getApplication(), R.drawable.system_update_fill0_wght400_grad0_opsz48), | ||
| service.getString(R.string.notification_available_action), | ||
| getPendingInstallIntent()).build(); | ||
|
|
||
| notificationManager.notify(NOTIFICATION_ID_AVAILABLE, new Notification.Builder(service, NOTIFICATION_CHANNEL_ID_AVAILABLE) | ||
| .addAction(action) | ||
| .setContentIntent(getPendingInstallIntent()) | ||
| .setContentTitle(service.getString(R.string.notification_available_title)) | ||
| .setContentText(service.getString(R.string.notification_available_text)) | ||
| .setShowWhen(true) | ||
| .setTimeoutAfter(-1) | ||
| .setSmallIcon(R.drawable.system_update_fill0_wght400_grad0_opsz48) | ||
| .build()); | ||
| } | ||
|
|
||
| void showUpdateDownloadedNotification() { | ||
| final Notification.Action action = new Notification.Action.Builder( | ||
| Icon.createWithResource(service.getApplication(), R.drawable.system_update_fill0_wght400_grad0_opsz48), | ||
| service.getString(R.string.notification_downloaded_action), | ||
| getPendingInstallIntent()).build(); | ||
|
|
||
| notificationManager.notify(NOTIFICATION_ID_DOWNLOADED, new Notification.Builder(service, NOTIFICATION_CHANNEL_ID_AVAILABLE) | ||
| .addAction(action) | ||
| .setContentIntent(getPendingInstallIntent()) | ||
| .setContentTitle(service.getString(R.string.notification_downloaded_title)) | ||
| .setContentText(service.getString(R.string.notification_downloaded_text)) | ||
| .setShowWhen(true) | ||
| .setTimeoutAfter(-1) | ||
| .setSmallIcon(R.drawable.system_update_fill0_wght400_grad0_opsz48) | ||
| .build()); | ||
| } |
| final Network network = connectivityManager.getActiveNetwork(); | ||
| final Intent service = new Intent(context, Service.class); | ||
| service.putExtra(Service.INTENT_EXTRA_NETWORK, network); | ||
| service.putExtra(Service.INTENT_EXTRA_USER_REQUESTED_INSTALL, true); |
| service.getString(R.string.notification_downloaded_action), | ||
| getPendingInstallIntent()).build(); | ||
|
|
||
| notificationManager.notify(NOTIFICATION_ID_DOWNLOADED, new Notification.Builder(service, NOTIFICATION_CHANNEL_ID_AVAILABLE) |
| } | ||
| if (!installAfterVerify) { | ||
| Log.d(TAG, "update downloaded and verified; notifying user to install manually"); | ||
| notificationHandler.showUpdateDownloadedNotification(); |
Change-Id: I187f3d409ac3b283b942aa7c5fa6194c8a5c5f3f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GrapheneOS/os-issue-tracker#7596
(I don't have an environment where I can fully test the behavior, so please check it before merging.)