Updater: add support for local updates

Allow importing and installation of OTA files already
downloaded instead of requiring to reboot to recovery
to install them.

Squash of:
- Add support for importing local updates
  Signed-off-by: Joey <jbevilacqua@shiftphones.com>
  Change-Id: I64ca3a6af29bdf8b2c6023a502f23080a27fd79e
- OTA: read timestamp from imported zip metadata
  Signed-off-by: Joey <jbevilacqua@shiftphones.com>
  Change-Id: I93a5c0be81adab9ba8e50afde0e09839f059c9e0
- OTA: fix UI issues with local update
  Signed-off-by: Joey <jbevilacqua@shiftphones.com>
  Change-Id: I07c8f5507bc52c254c3dc1468fea495a073ae96c
- OTA: fix local updates not being shown in UI (pt.2)
  Signed-off-by: Joey <jbevilacqua@shiftphones.com>
  Change-Id: Ife40eea05099eca9e1ee84c6f87d2715e5981cab
- OTA: ignore download status changes for local updates
  Signed-off-by: Joey <jbevilacqua@shiftphones.com>
  Change-Id: I198f9b5462718f8a6e5687c891f3bfc6b1c645bd
- UpdaterService: fix crash with local install
  Change-Id: I27b187cf4adec986d516e3017d1b3877691029b2
  Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
- Local updates: do not remove local update from ui after installation
  Change-Id: I869e090f26273006f933ad99c42b7c6a2e963797
  Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
- Local updates: modify display version
  Change-Id: I8a39e0936040bb9546499754ab4a9ef60c56aca0
  Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
- Local updates: show build date in import dialog
  Change-Id: I9014358ea1cf941e76fdd80a5147e9d924fc1a8f
  Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>

Change-Id: I64ca3a6af29bdf8b2c6023a502f23080a27fd79e
Signed-off-by: Joey <joey@lineageos.org>
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
9 files changed
tree: 250e3ab39956685543f10198d0c4efa76c962d06
  1. app/
  2. gradle/
  3. .gitignore
  4. build.gradle.kts
  5. gen-keystore.sh
  6. gradle.properties
  7. gradlew
  8. gradlew.bat
  9. keystore.properties.sample
  10. push-update.sh
  11. README.md
  12. settings.gradle.kts
README.md

Updater

Simple application to download and apply OTA packages.

Server requirements

The app sends GET requests to the URL defined by the updater_server_url resource (or the lineage.updater.uri system property) and expects as response a JSON with the following structure:

{
  "response": [
    {
      "datetime": 1230764400,
      "filename": "ota-package.zip",
      "id": "5eb63bbbe01eeed093cb22bb8f5acdc3",
      "romtype": "nightly",
      "size": 314572800,
      "url": "https://example.com/ota-package.zip",
      "version": "15.1"
    }
  ]
}

The datetime attribute is the build date expressed as UNIX timestamp.
The filename attribute is the name of the file to be downloaded.
The id attribute is a string that uniquely identifies the update.
The romtype attribute is the string to be compared with the ro.lineage.releasetype property.
The size attribute is the size of the update expressed in bytes.
The url attribute is the URL of the file to be downloaded.
The version attribute is the string to be compared with the ro.lineage.build.version property.

Additional attributes are ignored.

Build with Android Studio

Updater needs access to the system API, therefore it can't be built only using the public SDK. You first need to generate the libraries with all the needed classes. The application also needs elevated privileges, so you need to sign it with the right key to update the one in the system partition. To do this:

  • Place this directory anywhere in the Android source tree
  • Generate a keystore and keystore.properties using gen-keystore.sh
  • Build the dependencies running make UpdaterStudio from the root of the Android source tree. This command will add the needed libraries in system_libraries/.

You need to do the above once, unless Android Studio can't find some symbol. In this case, rebuild the system libraries with make UpdaterStudio.