Commit Graph

47 Commits

Author SHA1 Message Date
Michael Bestas
aed99e306c Updater: Add FLAG_IMMUTABLE flag to PendingIntent
Fixes:
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE
or FLAG_MUTABLE be specified when creating a PendingIntent.

Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some
functionality depends on the PendingIntent being mutable,
e.g. if it needs to be used with inline replies or bubbles.

Change-Id: I63b25512d3bf6e0d3b0cc95d91295f4065175848
2021-10-11 22:36:40 +03:00
Luca Stefani
d1273f214e Only cancel notification if update isn't installed
* Even if the package is removed on A/B devices
  we still want to show the reboot notification

Change-Id: I980d36766a1427874b65b11674a8f0ae4ce1db88
2020-04-11 12:19:52 +02:00
Michael W
e4822ff569 Updater: Delete updates only after refreshing the notification
* Looks like we first need to process the notification before we can delete
  an update

Change-Id: I49f6c03a109f908e8a7b01f02b821a68ab273af3
2020-04-02 13:44:32 +02:00
Luca Stefani
91f33aa03e Updater: Move to AndroidX
Change-Id: I7bd67915638db5330b854f66f9fc1adb864b64be
2019-09-07 19:11:27 +02:00
Luca Stefani
50d0fd5291 Updater: Allow to suspend A/B updates
Change-Id: I0387fd491a07a2214e4331a2cfe25988e0016a61
2019-04-10 22:04:32 +02:00
Gabriele M
5648b3cd27 Don't use one shot PendingIntents for the notification actions
FLAG_ONE_SHOT doesn't make so much sense here, the intents are generic
and can be repeated.

Change-Id: Ib457d975387dfd838372639e2aaa40a3df6f4d15
2018-07-14 18:47:12 +02:00
Gabriele M
0332be5ec7 Minor app notification improvements
- Don't use BigTextStyle if we only need to show a single line of
  text, but keep using it if the progressbar is visible.
- Change the icon to reflect the currrent state.
- Use android.R.drawable instead of com.android.internal.R.drawable

Change-Id: I0f69fe5f4fa63cdec180e89afa098d27819f33fd
2018-06-13 23:30:08 +02:00
Gabriele M
f4b3729426 Turn UpdateInstaller into a singleton
For symmetry with ABUpdateInstaller.

Change-Id: I9b61ed286c91f10140705e7b3e24b0eab0c75f49
2018-06-13 23:30:08 +02:00
Gabriele M
4bacd24da4 Remove Controller interface
This is just useless as is.

Change-Id: I957ea3bda4097ccb8d730943639cd5e74b1b2440
2018-06-13 23:30:08 +02:00
Gabriele M
fd096a564a Allow to properly translate the download ETA string
Change-Id: Ie6bbbddbbd9fd7adbc16472ad9c42c1d257413a1
2018-04-21 16:31:28 +02:00
Gabriele M
3aabbc7ed5 Use single return statement in onStartCommand()
This should prevent future changes from accidentally turning a
sticky service into a not sticky one.

Change-Id: I89f172626a98635149441a63536e0aa5a27f8280
2018-04-05 16:37:49 +02:00
Gabriele M
2ec8fc6cec Prevent NPE on A/B devices
The NPE shouldn't happen as we get a null intent only when the
service is sticky (i.e., isInstallingUpdate() is true), so this
is currently not a problem.

Change-Id: I8647498d9a1022f5c7207a2da3e42cf57d9ee030
2018-04-05 16:37:49 +02:00
Gabriele M
28644b3491 Don't register multiple UpdateEngine callbacks
We are loosely tied to UpdateEngine and have no way to know whether
we are bound or not without keeping track of the connection manually.
Since UpdaterService is for both A/B and legacy updates, turn
ABUpdateInstaller into a singleton to keep the code simple while
ensuring that a single callback is registered.

Change-Id: Ib4e9ad1413ba96bf5ed59cc3383741b5c9bac427
2018-04-05 16:37:49 +02:00
Harry Youd
ff53035537 Updater: Add notification channels
Change-Id: I2f538fb47fe90e1008bf286739d33c829123353a
2018-01-23 23:47:18 +01:00
Gabriele M
e50edf0811 Remove progress from notification when done
Change-Id: If49c8d0ca2270f22dcc5350379f1bb1f34f02041
2018-01-23 22:41:40 +01:00
Gabriele M
63f6fd1a70 Report installation failures
Change-Id: I5e11db1e6e338a510b3c1c7d16f8c085d874a9db
2018-01-23 22:41:40 +01:00
Gabriele M
e02b8a0b00 Copy the updates for uncrypt using a Service
Same as change I488018d01c0baf74660362a384e53bfe5d85de2b
("Use a service to export the updates"). While at it, move the code
out of UpdaterService to better separate the code that deal with AB
updates and regular updates.

Change-Id: I2bc3e78e80f5e63c57303cbbcdc0353dbab0f67f
2018-01-23 22:41:40 +01:00
Gabriele M
e66a8fa53a Keep track of the installation status of AB updates
This allows to show the correct labels.

Change-Id: I52f42e042af0df2d091d786c03102cec352b3a5b
2018-01-23 22:41:40 +01:00
Gabriele M
8e369117bf Allow to cancel ongoing installations
Change-Id: I46884b42b6e3f87fbee99a23f538cec990b3b873
2018-01-23 22:41:40 +01:00
Gabriele M
f3d9b3f1b2 Allow service restarts while installing AB updates
The update engine service is independent and once started doesn't need
our service to install updates. Therefore we can't assume that our
service will stay up as long as the installation is being performed.
If the service gets terminated while an update is being installed, we
simply lose our connection to the update engine service and stop
receiving notifications, the installation itself won't stop. Keep
track of ongoing installations using a shared preference and use a
sticky service when installing updates. The service will try to
re-connect to the update engine service and determine if the
installation is still ongoing.

Change-Id: Id2fc11cab51610d04bf41a0927824bb8c0c94d71
2018-01-23 22:41:40 +01:00
Gabriele M
02f52108d9 Show progress when installing AB updates
Change-Id: If8cd2e2da1f15a4af415aa35ccf61052c318333f
2018-01-23 22:41:40 +01:00
Gabriele M
d4a65e455e Stop service when pausing downloads
Change-Id: Ibb77c7f0d4309874fcfa591d12b5e6ce4a6d6abc
2018-01-23 22:41:34 +01:00
Gabriele M
cbe6bd69fd Use the right preference for the auto-delete option
Change-Id: Iac7e838e8ecf1e5ed27bb0c9587442aa2ec8ffec
(cherry picked from commit 8ff6f57e7b)
2018-01-18 19:27:20 +00:00
Gabriele M
7be5b7c057 Don't stop service while installing AB updates
Change-Id: I2e5eaffa2b64ce8d387958b070a23f393f827c5e
2017-11-12 20:14:18 +01:00
Gabriele M
ea3ac38e25 Dismiss some notifications when clicked 2017-08-08 10:32:48 +02:00
Gabriele M
cdc4849767 Remove duplicate icon
ic_tab_install is basically the same as ic_system_update. The only
difference is the color, but that doesn't really matter.
2017-08-07 16:43:34 +02:00
Gabriele M
13f3849b96 Actually check if an OTA is encrypted 2017-07-26 11:57:32 +02:00
Gabriele M
8768daddf0 Add option to delete updates when installed
This is mostly useful on encrypted devices since it allows to not
copy the update before installing it.
2017-07-22 20:38:20 +02:00
Gabriele M
20ea513684 Create a copy of the zips on encrypted devices
On encrypted devices, uncrypt modifies the zip so that it can be
read without mounting the filesystem. Instead of installing the zip
downloaded, create a copy of it which will be deleted. This will
allow to re-install the zip multiple times or export it after
installing it.
2017-07-21 17:05:53 +02:00
Gabriele M
28b8774db6 Define interfaces with only getters for the updates
This also changes the code to use the new interfaces wherever the
update is not supposed to change.
2017-07-21 16:52:24 +02:00
Gabriele M
11f82cfb87 Reorder includes directives
These went out of order moving some stuff around. Reorder them so
that there won't be unnecessary line changes in future.
2017-07-21 01:17:19 +02:00
Gabriele M
821efd8219 Rename UpdaterControllerInt to Controller 2017-07-18 22:26:51 +02:00
Gabriele M
82dbc8fde3 Remove a couple of extra semicolons 2017-07-18 22:17:29 +02:00
Gabriele M
a06fa3f9f0 Add own formatDuration() method
DateUtils.formatDuration() is not public, so create our own version.
2017-07-18 22:17:26 +02:00
Gabriele M
af1e9c4478 Create model package 2017-07-18 22:15:13 +02:00
Gabriele M
8ce10da9ce Use UTC timezone for the build dates 2017-07-18 12:52:08 +02:00
Gabriele M
d0f9c4be22 Don't use the filename as notification title
Be consistent with the rest of the app and use "version - date".
2017-07-17 12:27:15 +02:00
Gabriele M
c3515644b6 Ask for confirmation before installing updates
Since there's no quick and clean way to show a dialog from a
serivice, don't allow to install updates from the notification.
2017-07-16 22:52:45 +02:00
Gabriele M
12688ba761 Allow to check if an update is of type AB from anywhere 2017-07-16 22:52:45 +02:00
Gabriele M
a455c95e0c Install updates from UpdaterService
This allows to easily handle AB updates.
2017-07-16 22:52:45 +02:00
Gabriele M
d327d61cc6 Send an event when update are canceled
This allows to properly update the status of the application.
In particular, when an update is deleted:
 - Cancel the associated notification, if any.
 - Remove the entry from the controller if the update is no longer
   available online.
 - Disable the resume button if download is partially downloaded
   and is no longer available online.
2017-07-07 22:05:22 +02:00
Gabriele M
e245631b46 Add support for A/B (Seamless) System Updates
Loosely based on:
0465cb691d
2017-07-04 19:36:32 +02:00
Gabriele M
bb2f2c1005 Disable indeterminate progressbar in case of download error
Similar to the 'paused' case, but take into account that the error
can happen when the progress is 0, in which case we just hide the
progress bar.
2017-07-04 19:05:04 +02:00
Gabriele M
4dcf4199f1 Minor code refactoring 2017-07-04 19:05:04 +02:00
Gabriele M
520105284c Rename some constants 2017-07-04 19:05:04 +02:00
Gabriele M
437d4b1913 Don't make UpdaterService sticky
We are using it as non-sticky service, so just declare it as such.
2017-07-04 19:05:04 +02:00
Gabriele M
db3f14832a Replace 'Download' prefix with 'Updater'
These classes do more than controlling the download of the updates.
2017-07-04 19:05:04 +02:00