Commit Graph

380 Commits

Author SHA1 Message Date
Gabriele M
4d5e82b885 Handle install errors from onPayloadApplicationComplete()
When the installation terminates because of an error, update_engine
sets the status to IDLE and sends a notification. Thus, we might
miss the error report and never update the status of the update.

Change-Id: Ic1536b1c157c4dab0128f039f9512f2fb734287d
2018-04-05 16:37:49 +02:00
Gabriele M
8d0471effc Make updates world readable
This should allow update_engine to access the file without
granting the dac_override capability.

Change-Id: I5d0c8792fd47e5571dbaf802b2725f99ee2dc150
2018-04-05 16:37:49 +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
a409a4a03d Clear NEEDS_REBOOT preference on reboot
UpdateEngine doesn't send an initial notification to bound client
if the last status is not known, so clear the preference when we
detect that the device has been rebooted.

Change-Id: Ib15dff5fa8ac9ec07a68018a83683cc561fd3e85
2018-04-05 16:37:49 +02:00
Gabriele M
eecdf389ef Set status to INSTALLING when reconnecting to the service
Otherwise the service won't run in foreground after restarting
the app while an update is being installed.

Change-Id: I8a75d206ead2945e7326c144b0b4354fbb2accb4
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
Gabriele M
69e65ca4bf Remove duplicate INSTALLING notification
Change-Id: Ia1515aef1a24a5d54143e1423ae96f09163625bc
2018-04-05 16:37:46 +02:00
Michael Bestas
a0bdd6abba Automatic translation import
Change-Id: I0cd872bbd27613db1203a0538eff765379316ecb
2018-04-01 22:32:42 +03:00
Dan Pasanen
37524ad0fa Updater: explicitly include android-support-transition
* Fixes non-jack build

Change-Id: I44d470daa36f9ef5f06e5307297fa4c01fb078e5
2018-03-21 22:51:08 +00:00
Michael Bestas
14d522818c Automatic translation import
Change-Id: I5265394cac0bdd174c3cec21a11a1d0e6d35597d
2018-03-09 00:35:54 +02:00
Roman Birg
31057295dc Updater: fix wrong preference key in A/B installer
We are referencing the wrong key for deciding whether to delete the
update on reboot.

Change-Id: If83d278259291b61c26302bdd59c2774901b18ca
Signed-off-by: Roman Birg <romanbirg@gmail.com>
2018-03-07 02:55:32 +00:00
Michael Bestas
f183b58b09 Automatic translation import
Change-Id: I2923971e3477640a67a241762d1dc164f1e0c462
2018-02-25 22:04:16 +02:00
Michael Bestas
d44eb7c414 Automatic translation import
Change-Id: I47e08290ebdb11c3d05d0614560dc2847884928d
2018-02-22 03:49:55 +02:00
meganukebmp
76b9f49684 Updater: add changelog button
Add a changelog button in the menu toolbar throwing the user in
the recent changes page

Change-Id: I16609825c0662fc22b95189cbdf324a8c0b94f81
2018-02-17 17:46:45 +00:00
Joey
f62a57c463 Updater: gradle: target api27
Change-Id: I83aae173b4e885368737ac94f5d6d018708d642b
Signed-off-by: Joey <joey@lineageos.org>
2018-02-17 12:54:17 +00:00
Joey
2a9c85e675 Updater: adaptive icon
Change-Id: Ifee7b51f48b204b646935d9470d31f6e9519124d
Signed-off-by: Joey <joey@lineageos.org>
2018-02-15 13:43:40 +00:00
Harry Youd
ff53035537 Updater: Add notification channels
Change-Id: I2f538fb47fe90e1008bf286739d33c829123353a
2018-01-23 23:47:18 +01:00
Gabriele M
0e79b791f0 Add support for duplicate links
Support duplicate links [1] to handle better temporarily unavailable
mirrors.

[1] https://tools.ietf.org/html/rfc6249

Change-Id: If78fb4a90da68ef221294eed2c59063a14cf1f43
2018-01-23 22:41:40 +01:00
Gabriele M
3fc17494eb Updater: Android Studio support
See README-STUDIO.txt for more info.

Change-Id: Ie673bba5618b0f00a585049cd85687a64db2b420
2018-01-23 22:41:40 +01:00
Gabriele M
7005b005d9 Updater: Set version code explicitly
In this way apks built with gradle/Android Studio will have the
same versionCode, allowing to update the one in /system.

Change-Id: I020cc623dd7c1c5085fec4e6f5978b6ee46468a2
2018-01-23 22:41:40 +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
c5f36ee047 Don't allow any operation if a reboot is needed
Change-Id: I175525071faa44f30b8f2bbf36da56a2e6f2dd1b
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
6088f26f53 Wait for the UPDATED_NEED_REBOOT status
Consider an update as installed only when update engine reports that
the device needs to be rebooted. This change also move the entire
logic in onStatusUpdate(), which reports all we need to properly
track the progress of the installation.

Change-Id: Ic8db00cccdd19fd62ba4dee31fd1dccc9037193d
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
2c41ae392c Use a service to export the updates
AsyncTasks are not suitable for long lasting operations and can easily
cause memory leaks. The use of ProgressDialogs is also discouraged, so
move to a foreground service to export the updates.

Change-Id: I488018d01c0baf74660362a384e53bfe5d85de2b
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
Harry Youd
c5324a5fc6 Updater: Move to new lineage build props
Change-Id: I6ff93f34602de6e79208d382f9be157c14ffbb99
2017-11-28 14:27:20 +01: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
8c9976d622 Show delete button for old updates
Old updates can't be installed if the current build is newer, so show
a delete button instead.

Change-Id: Ib34aad31d93e87a1009c23f86686fc4a008129e7
2017-11-12 16:10:17 +01:00
Gabriele M
9dc1349c1a Implement DownloadClient using HttpURLConnection
The version of OkHttp used in AOSP doesn't handle dynamic table size
updates [1] properly [2]. Instead of fixing OkHttp or importing a
prebuilt updated version, implement a new download client only using
HttpURLConnection, which seems to work properly.

[1] https://tools.ietf.org/html/rfc7541#section-6.3
[2] https://trac.nginx.org/nginx/ticket/1397

Change-Id: I3eedf7326f2017812c4a12d41f9ea028d255f7a8
2017-11-12 16:10:17 +01:00
Abhisek Devkota
7aa3a999d8 Automatic translation import
Change-Id: I139708300601c694863783cb23cf7c2ce49150f3
2017-10-21 11:11:30 -07:00
Paul Keith
c05521baba Updater: Allow specifying a new device name
* To allow transitions from e.g. variant->unified build
* Example process, using klteusc->klte as the example:
 - Set ro.updater.next_device to klte in klteusc's tree
 - Wait for build to roll out with ro.updater.next_device
 - Pull klteusc from build roster

Change-Id: I3c70d54de3f9e036cd8700edc4ee0b11093740d2
2017-10-12 20:12:49 +02:00
Abhisek Devkota
a891ac9709 Automatic translation import
Change-Id: I15611e4ff76d2364d8be1c1873dc40796e17a7f1
2017-09-19 00:29:02 -07:00
Gabriele M
6f3dfda1b0 Improve the automatic updates checks
The builds for each device are released more or less at the same
time of the day, so check when the last build was released and
schedule the next check accordingly. Also, allow multiple automatic
updates check in the same day. There's no need to limit the number
of checks since they are not frequent and this can affect negatively
the effectiveness of the new algorithm. In addition to that, remove
any pending oneshot alarm in case a subsequent check succeeds and
log every new alarm.

Change-Id: I4668f2e342e51d3578992eec6d8c270065d9aa21
2017-08-31 22:36:23 +02:00
Gabriele M
5c09d5c5f1 Minor code refactoring
Use a separate function to process the new json to increase the
readability of the code.

Change-Id: If508563fd9ccb2a6b0edb40a3cfe2a0081cb97f4
2017-08-31 17:29:49 +02:00
Gabriele M
c50871c0dc Allow to keep incompatible updates when parsing jsons
The condition was wrong and incompatible updates were always
discarded regardless of the flag passed.

Change-Id: Iefc2d64b841921eb77a9f73cf374b63b477d2588
2017-08-31 17:29:48 +02:00
Gabriele M
17f35382d7 Show alert dialog for major upgrades
Major upgrades are not possible with Updater and they are already
blocked. This commit adds a dialog with a link to a webpage that
explains how to upgrade manually.

Based on: d5d343d627

Change-Id: Ifb23e0a4db1060fc696d13e6694f3e849af70e2d
2017-08-25 18:13:46 +00:00
Gabriele M
88b6fd84bb Show the actual version of the update
We were showing the version of the currently installed build for
all the updates.

Change-Id: I76150ff248d6c6a106571c2ba4d26ae57847aed3
2017-08-25 20:05:56 +02:00
Mustafa Karatas
2327e83c51 Fix No updates found for users with Turkish Locale
There is a problem with Java's toLowerCase() method which returns
"LATIN SMALL LETTER DOTLESS I" for "I" character. This breaks update check
because Utils.getInstalledBuildType() returns "nıghtly (notice dottles small
i)" instead of "nightly".

This change forces toLowerCase() to use ROOT locale which is recommended in
javadocs

There is a note for Turkish locale on javadocs:
http://devdocs.io/openjdk~8/java/lang/string#toLowerCase--

Change-Id: Ifada815202588d67643136846de08f94cefb46a5
Signed-off-by: Mustafa Karatas <mstfkaratas@gmail.com>
2017-08-20 14:21:38 +02:00
Gabriele M
87202371de Don't change status when cancelled downloads fail
It takes a bit of time to actually pause (i.e. cancel) a download. If
we change the update status once the download is actually cancelled,
we might override any status change that happened between the user
request and its completion. For example, the following can happen when
the user deletes an ongoing downloads:

 - pauseDownload(): DOWNLOADING -> PAUSED
 - deleteUpdate(): PAUSED -> DELETED
 - onFailure(): DELETED -> PAUSED

Don't change the status of cancelled downloads from the onFailure()
callback not to have an incorrect final status.

Change-Id: Iee90482d82df984672c59d7c508ad834fa08061f
2017-08-18 14:31:54 +02:00
Luca Stefani
4c5dd9c391 Disable clip to padding
* Allow the last item shadow to be seen

Change-Id: If24b0db3feb75a4468b6dddde62b4c79917552c8
2017-08-14 22:47:03 +02:00
Luca Stefani
a0cd205b1d Don't add margins in update items
Change-Id: I71a22a4bd0a15e70a045cef1c49f67ff5625dbd6
2017-08-14 22:47:02 +02:00
Luca Stefani
8217a4aac6 Exclude updater from recents
Change-Id: Iae2737aa5890aa00da79c5b04dd253273aa9fabc
2017-08-14 22:47:01 +02:00