Commit graph

22 commits

Author SHA1 Message Date
Tianjie Xu
b5108c372c Move librecovery_ui to a sub-directory
This helps to expose librecovery_ui for device specific RecoveryUi.

Bug: 76436783
Test: mma, unit tests pass
Change-Id: Ic6c3d301d5833e4a592e6ea9d9d059bc4e4919be
2019-03-21 00:45:37 -07:00
xunchang
3cc23d5eac Move apply_from_sdcard to fuse_sdcard_install
Move the sdcard installation function and all helper functions to a
separate file, and drop the dependency on common.h.

In the future, we want to move these functions into the install class.

Bug: 127071893
Test: unit tests pass
Change-Id: I0b7f7cbf0b68918e638e13878ca28bfca367088a
2019-03-19 23:05:13 -07:00
Hridya Valsaraju
e4ef453914 Fix sideload for user devices by adding a new sideload config
Bug: 113563995
Test: Tested the 'adb sideload' command on marlin user/userdebug builds
and walleye user/userdebug builds

Change-Id: I00d565547b85f2db87012e4a08316609e03395ac
2018-09-07 15:02:43 -07:00
Hridya Valsaraju
cfb3c92302 Move recovery from /sbin to /system/bin
Executables should be in /system/bin
rather than sbin.

Bug: 78793464
Test: boot into recovery, try adb sideload
Change-Id: I194589119a099d29e56b0648f0906a5ae2aa6770
2018-07-26 17:12:40 -07:00
Tao Bao
641fa97def Rename CacheLocation to Paths.
We have a general need for overriding more paths (e.g. "/tmp"), mostly
for testing purpose. Rename CacheLocation to Paths, and use that to
manage TEMPORARY_{INSTALL,LOG}_FILE.

Test: mmma -j bootable/recovery
Test: recovery_component_test
Change-Id: Ia8ce8e5695df37ca434f13ac4d3206de1e8e9396
2018-04-25 21:46:00 -07:00
Tao Bao
0167d4c382 Don't write to /sys/class/android_usb/android0/enable with configfs.
USB configfs doesn't use /s/c/a/a/enable. Trying to set that gives
confusing message on screen when sideloading.

Bug: 37713851
Test: adb sideload on device using with configfs.
Test: adb sideload on marlin.
Change-Id: Ifa55f90c2a5fe6bf9e7cee95882de9f6de686d73
2017-05-11 14:50:20 -07:00
Tao Bao
0150d013eb adb_install: Stop passing RecoveryUI as a parameter.
It's already a global declared in common.h which is included by
adb_install.cpp.

Remove '#include "minadbd/fuse_adb_provider.h"' that's not needed by
adb_install.cpp (minadbd takes care of that).

Test: mmma bootable/recovery
Change-Id: I6d08b7abc706b4b05de2ef46a57ced2204ad297e
2017-05-01 11:47:43 -07:00
Tao Bao
3da880156b Replace _exit(-1) with _exit(EXIT_FAILURE).
-1 is not a valid exit status.

Also replace a few exit(1) with exit(EXIT_FAILURE).

Test: mmma bootable/recovery
Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd
2017-02-03 14:11:11 -08:00
Elliott Hughes
cb22040c63 Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-26 09:51:37 -07:00
Elliott Hughes
4692e5d8c8 Merge \"Remove an abused global so we can actually see logging.\"
am: 37450d7f42

Change-Id: Id9c78be08f2822ec92d54ba11693d3e5adb7b5aa
2016-06-15 23:16:14 +00:00
Elliott Hughes
59bf0da22f Remove an abused global so we can actually see logging.
Change-Id: Ib97440bc0542003b84c45cb05f194ba20104dad6
2016-06-15 15:14:04 -07:00
Tianjie Xu
162558382b Allow recovery to return error codes
Write error code, cause code, and retry count into last_install. So we
can have more information about the reason of a failed OTA.

Example of new last_install:
@/cache/recovery/block.map     package name
0                              install result
retry: 1                       retry count (new)
error: 30                      error code (new)
cause: 12                      error cause (new)

Details in:
go/android-ota-errorcode

Bug: 28471955
Change-Id: I00e7153c821e7355c1be81a86c7f228108f3dc37
2016-05-20 13:56:53 -07:00
Tao Bao
80e46e08de recovery: Switch to clang
And a few trival fixes to suppress warnings.

Change-Id: I38734b5f4434643e85feab25f4807b46a45d8d65
2015-06-03 11:30:03 -07:00
Elliott Hughes
7bad7c4646 Check all lseek calls succeed.
Also add missing TEMP_FAILURE_RETRYs on read, write, and lseek.

Bug: http://b/20625546
Change-Id: I03b198e11c1921b35518ee2dd005a7cfcf4fd94b
2015-04-29 17:46:43 -07:00
Elliott Hughes
20531ef605 Switch minadb over to C++.
Change-Id: I5afaf70caa590525627c676c88b445d3162de33e
2015-04-10 13:59:19 -07:00
Elliott Hughes
018ed31c51 Enable printf format argument checking.
The original attempt missed the fact that Print is a member function,
so the first argument is the implicit 'this'.

Change-Id: I963b668c5432804c767f0a2e3ef7dea5978a1218
2015-04-08 16:56:17 -07:00
Tao Bao
682c34bbc3 Rotate logs only when there are actual operations
Currently it rotates the log files every time it boots into the recovery
mode. We lose useful logs after ten times. This CL changes the rotation
condition so that it will rotate only if it performs some actual
operations that modify the flash (installs, wipes, sideloads and etc).

Bug: 19695622
Change-Id: Ie708ad955ef31aa500b6590c65faa72391705940
2015-04-07 22:02:27 -07:00
Tao Bao
145d861460 Factor out option variables from int to bool types
Change-Id: Ia897aa43e44d115bde6de91789b35723826ace22
2015-03-25 15:56:15 -07:00
Elliott Hughes
f14af80a14 recovery: Properly detect userdebug or eng builds
The recovery system behaves a little bit differently on userdebug or
eng builds by presenting error reports to the user in the ui.
This is controlled by checking the build fingerprint for the string
:userdebug/ or :eng/. But with AOSP version numbers most AOSP
builds blows the 92 char limit of ro.build.fingerprint and therefore
the property is not set, so this condition will always be evaluated
to false, for most builds.

Instead of depending on the flaky ro.build.fingerprint this change
uses ro.debuggable.

Change-Id: I74bc00c655ac596aaf4b488ecea58f0a8de9c26b
2015-02-10 14:46:14 -08:00
Doug Zongker
18a78e0a16 refactor fuse sideloading code
Split the adb-specific portions (fetching a block from the adb host
and closing the connections) out from the rest of the FUSE filesystem
code, so that we can reuse the fuse stuff for installing off sdcards
as well.

Change-Id: I0ba385fd35999c5f5cad27842bc82024a264dd14
2014-07-10 10:55:07 -07:00
Doug Zongker
075ad800c5 sideload without holding the whole package in RAM
Implement a new method of sideloading over ADB that does not require
the entire package to be held in RAM (useful for low-RAM devices and
devices using block OTA where we'd rather have more RAM available for
binary patching).

We communicate with the host using a new adb service called
"sideload-host", which makes the host act as a server, sending us
different parts of the package file on request.

We create a FUSE filesystem that creates a virtual file
"/sideload/package.zip" that is backed by the ADB connection -- users
see a normal file, but when they read from the file we're actually
fetching the data from the adb host.  This file is then passed to the
verification and installation systems like any other.

To prevent a malicious adb host implementation from serving different
data to the verification and installation phases of sideloading, the
FUSE filesystem verifies that the contents of the file don't change
between reads -- every time we fetch a block from the host we compare
its hash to the previous hash for that block (if it was read before)
and cause the read to fail if it changes.

One necessary change is that the minadbd started by recovery in
sideload mode no longer drops its root privileges (they're needed to
mount the FUSE filesystem).  We rely on SELinux enforcement to
restrict the set of things that can be accessed.

Change-Id: Ida7dbd3b04c1d4e27a2779d88c1da0c7c81fb114
2014-07-02 12:16:36 -07:00
Doug Zongker
9270a20a80 support "sideload over ADB" mode
Rather than depending on the existence of some place to store a file
that is accessible to users on an an unbootable device (eg, a physical
sdcard, external USB drive, etc.), add support for sideloading
packages sent to the device with adb.

This change adds a "minimal adbd" which supports nothing but receiving
a package over adb (with the "adb sideload" command) and storing it to
a fixed filename in the /tmp ramdisk, from where it can be verified
and sideloaded in the usual way.  This should be leave available even
on locked user-build devices.

The user can select "apply package from ADB" from the recovery menu,
which starts minimal-adb mode (shutting down any real adbd that may be
running).  Once minimal-adb has received a package it exits
(restarting real adbd if appropriate) and then verification and
installation of the received package proceeds.

Change-Id: I6fe13161ca064a98d06fa32104e1f432826582f5
2012-01-10 10:18:17 -08:00