From 956cde8578c40ec812a933a14cb4e82f2c0de320 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Tue, 26 Jun 2012 15:01:03 -0700 Subject: Add mode when open(O_CREAT) is used. When creating a new file using open(..., O_CREAT), it is an error to fail to specify a creation mode. If a mode is not specified, a random stack provided value is used as the "mode". This will become a compile error in a future Android change. Change-Id: I73c1e1a39ca36bf01704b07302af4971d234b5a8 --- applypatch/applypatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 00004e9a8..488fd8c6f 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -324,7 +324,7 @@ static int LoadPartitionContents(const char* filename, FileContents* file) { // Save the contents of the given FileContents object under the given // filename. Return 0 on success. int SaveFileContents(const char* filename, const FileContents* file) { - int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC); + int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd < 0) { printf("failed to open \"%s\" for write: %s\n", filename, strerror(errno)); @@ -843,7 +843,7 @@ static int GenerateTarget(FileContents* source_file, strcpy(outname, target_filename); strcat(outname, ".patch"); - output = open(outname, O_WRONLY | O_CREAT | O_TRUNC); + output = open(outname, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (output < 0) { printf("failed to open output file %s: %s\n", outname, strerror(errno)); -- cgit v1.2.3 From 9c5efe6bdecfaa37fdc7c552253d2bd53235b117 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 11 Jul 2012 13:21:02 -0700 Subject: allow double-quotes or not in TARGET_RECOVERY_PIXEL_FORMAT Change-Id: I0bf22c87c51a34ee4a839c4966277fad8150bd59 --- minui/Android.mk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/minui/Android.mk b/minui/Android.mk index 4c4d7c7b6..285ac62bf 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -9,10 +9,14 @@ LOCAL_C_INCLUDES +=\ LOCAL_MODULE := libminui -ifeq ($(TARGET_RECOVERY_PIXEL_FORMAT),"RGBX_8888") +# This used to compare against values in double-quotes (which are just +# ordinary characters in this context). Strip double-quotes from the +# value so that either will work. + +ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888) LOCAL_CFLAGS += -DRECOVERY_RGBX endif -ifeq ($(TARGET_RECOVERY_PIXEL_FORMAT),"BGRA_8888") +ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888) LOCAL_CFLAGS += -DRECOVERY_BGRA endif -- cgit v1.2.3 From 862d026fb2aebb3e30be68ce2f48ef226e8c3a20 Mon Sep 17 00:00:00 2001 From: Devin Kim Date: Thu, 19 Jul 2012 10:47:34 -0700 Subject: minui: fix screen update issue yres_virtual value is set incorrectly, causing serveral images to be skipped. Change this value according to the number of buffers to fix this issue. from: codeaurora.org minui: Display the battery charging image correctly commit: 581a4dead6b96579a13ff22e2454c1f329731679 Change-Id: I10f5d1c6cc37705f0287c7dd517082de2e11d264 Signed-off-by: Iliyan Malchev --- minui/graphics.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/minui/graphics.c b/minui/graphics.c index de1cfdf3b..dc96c3b21 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -44,6 +44,8 @@ #define PIXEL_SIZE 2 #endif +#define NUM_BUFFERS 2 + typedef struct { GGLSurface texture; unsigned cwidth; @@ -54,7 +56,7 @@ typedef struct { static GRFont *gr_font = 0; static GGLContext *gr_context = 0; static GGLSurface gr_font_texture; -static GGLSurface gr_framebuffer[2]; +static GGLSurface gr_framebuffer[NUM_BUFFERS]; static GGLSurface gr_mem_surface; static unsigned gr_active_fb = 0; @@ -162,7 +164,7 @@ static void get_memory_surface(GGLSurface* ms) { static void set_active_framebuffer(unsigned n) { if (n > 1) return; - vi.yres_virtual = vi.yres * PIXEL_SIZE; + vi.yres_virtual = vi.yres * NUM_BUFFERS; vi.yoffset = n * vi.yres; vi.bits_per_pixel = PIXEL_SIZE * 8; if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) { -- cgit v1.2.3 From 17495277b1a6328f5cae68523ad00be1f1107950 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 25 Jul 2012 13:10:58 -0700 Subject: support version 2 (2048-bit e=65537) keys in recovery Change-Id: I9849c69777d513bb12926c8c622d1c12d2da568a --- install.cpp | 26 ++++++++++++++++++++++- testdata/otasigned_f4.zip | Bin 0 -> 5195 bytes testdata/test_f4.pk8 | Bin 0 -> 1217 bytes testdata/test_f4.x509.pem | 25 ++++++++++++++++++++++ verifier_test.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++---- verifier_test.sh | 15 +++++++++++++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 testdata/otasigned_f4.zip create mode 100644 testdata/test_f4.pk8 create mode 100644 testdata/test_f4.x509.pem diff --git a/install.cpp b/install.cpp index 4d73aa9b0..819650e1f 100644 --- a/install.cpp +++ b/install.cpp @@ -180,6 +180,12 @@ try_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) { // // "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" // +// For key versions newer than the original 2048-bit e=3 keys +// supported by Android, the string is preceded by a version +// identifier, eg: +// +// "v2 {64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" +// // (Note that the braces and commas in this example are actual // characters the parser expects to find in the file; the ellipses // indicate more numbers omitted from this example.) @@ -206,7 +212,23 @@ load_keys(const char* filename, int* numKeys) { ++*numKeys; out = (RSAPublicKey*)realloc(out, *numKeys * sizeof(RSAPublicKey)); RSAPublicKey* key = out + (*numKeys - 1); - if (fscanf(f, " { %i , 0x%x , { %u", + + char start_char; + if (fscanf(f, " %c", &start_char) != 1) goto exit; + if (start_char == '{') { + // a version 1 key has no version specifier. + key->exponent = 3; + } else if (start_char == 'v') { + int version; + if (fscanf(f, "%d {", &version) != 1) goto exit; + if (version == 2) { + key->exponent = 65537; + } else { + goto exit; + } + } + + if (fscanf(f, " %i , 0x%x , { %u", &(key->len), &(key->n0inv), &(key->n[0])) != 3) { goto exit; } @@ -237,6 +259,8 @@ load_keys(const char* filename, int* numKeys) { LOGE("unexpected character between keys\n"); goto exit; } + + LOGI("read key e=%d\n", key->exponent); } } diff --git a/testdata/otasigned_f4.zip b/testdata/otasigned_f4.zip new file mode 100644 index 000000000..dd1e4dd40 Binary files /dev/null and b/testdata/otasigned_f4.zip differ diff --git a/testdata/test_f4.pk8 b/testdata/test_f4.pk8 new file mode 100644 index 000000000..3052613c5 Binary files /dev/null and b/testdata/test_f4.pk8 differ diff --git a/testdata/test_f4.x509.pem b/testdata/test_f4.x509.pem new file mode 100644 index 000000000..814abcf99 --- /dev/null +++ b/testdata/test_f4.x509.pem @@ -0,0 +1,25 @@ +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIJAKhkCO1dDYMaMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNV +BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBW +aWV3MQ8wDQYDVQQKEwZHb29nbGUxEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMT +B1Rlc3QxMjMwHhcNMTIwNzI1MTg1NzAzWhcNMzkxMjExMTg1NzAzWjBvMQswCQYD +VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g +VmlldzEPMA0GA1UEChMGR29vZ2xlMRAwDgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQD +EwdUZXN0MTIzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu8WwMN9x +4Mz7YgkG2qy9g8/kl5ZoYrUM0ApHhaITAcL7RXLZaNipCf0w/YjYTQgj+75MK30x +TsnPeWNOEwA62gkHrZyyWfxBRO6kBYuIuI4roGDBJOmKQ1OEaDeIRKu7q5V8v3Cs +0wQDAQWTbhpxBZr9UYFgJUg8XWBfPrGJLVwsoiy4xrMhoTlNZKHfwOMMqVtSHkZX +qydYrcIzyjh+TO0e/xSNQ8MMRRbtqWgCHN6Rzhog3IHZu0RaPoukariopjXM/s0V +gTm3rHDHCOpna2pNblyiFlvbkoCs769mtNmx/yrDShO30jg/xaG8RypKDvTChzOT +oWW/XQ5VEXjbHwIDAQABo4HUMIHRMB0GA1UdDgQWBBRlT2dEZJY1tmUM8mZ0xnhS +GdD9TTCBoQYDVR0jBIGZMIGWgBRlT2dEZJY1tmUM8mZ0xnhSGdD9TaFzpHEwbzEL +MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDU1vdW50 +YWluIFZpZXcxDzANBgNVBAoTBkdvb2dsZTEQMA4GA1UECxMHQW5kcm9pZDEQMA4G +A1UEAxMHVGVzdDEyM4IJAKhkCO1dDYMaMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN +AQEFBQADggEBAHqnXHtE+h3hvGmHh24GT51vGAYLc68WUUtCVlMIU85zQ757wlxZ +BmRypZ1i9hSqnXj5n+mETV5rFX3g2gvdAPVHkRycuDa2aUdZSE8cW4Z6qYFx6SaD +e+3SyXokpUquW64RuHJrf/yd/FnGjneBe3Qpm2reuzGWNH90qZGdbsfNaCm5kx2L +X+ZNHM3CcGMLaphY5++sM0JxSEcju5EK33ZYgLf4YdlbyMp8LDFVNd7ff0SFi9fF +0ZlAsJWoS3QmVCj2744BFdsCu7UHpnYpG6X3MT4SHAawdOaT5zSuaCl2xx6H0O7t +w/Fvbl/KVD1ZmLHgBKjDMNSh0OB9mSsDWpw= +-----END CERTIFICATE----- diff --git a/verifier_test.cpp b/verifier_test.cpp index fe5519d79..01d092680 100644 --- a/verifier_test.cpp +++ b/verifier_test.cpp @@ -56,7 +56,45 @@ RSAPublicKey test_key = 9135381, 1625809335, -1490225159, -1342673351, 1117190829, -57654514, 1825108855, -1281819325, 1111251351, -1726129724, 1684324211, -1773988491, - 367251975, 810756730, -1941182952, 1175080310 } + 367251975, 810756730, -1941182952, 1175080310 }, + 3 + }; + +RSAPublicKey test_f4_key = + { 64, 0xc9bd1f21, + { 293133087u, 3210546773u, 865313125u, 250921607u, + 3158780490u, 943703457u, 1242806226u, 2986289859u, + 2942743769u, 2457906415u, 2719374299u, 1783459420u, + 149579627u, 3081531591u, 3440738617u, 2788543742u, + 2758457512u, 1146764939u, 3699497403u, 2446203424u, + 1744968926u, 1159130537u, 2370028300u, 3978231572u, + 3392699980u, 1487782451u, 1180150567u, 2841334302u, + 3753960204u, 961373345u, 3333628321u, 748825784u, + 2978557276u, 1566596926u, 1613056060u, 2600292737u, + 1847226629u, 50398611u, 1890374404u, 2878700735u, + 2286201787u, 1401186359u, 619285059u, 731930817u, + 2340993166u, 1156490245u, 2992241729u, 151498140u, + 318782170u, 3480838990u, 2100383433u, 4223552555u, + 3628927011u, 4247846280u, 1759029513u, 4215632601u, + 2719154626u, 3490334597u, 1751299340u, 3487864726u, + 3668753795u, 4217506054u, 3748782284u, 3150295088u }, + { 1772626313u, 445326068u, 3477676155u, 1758201194u, + 2986784722u, 491035581u, 3922936562u, 702212696u, + 2979856666u, 3324974564u, 2488428922u, 3056318590u, + 1626954946u, 664714029u, 398585816u, 3964097931u, + 3356701905u, 2298377729u, 2040082097u, 3025491477u, + 539143308u, 3348777868u, 2995302452u, 3602465520u, + 212480763u, 2691021393u, 1307177300u, 704008044u, + 2031136606u, 1054106474u, 3838318865u, 2441343869u, + 1477566916u, 700949900u, 2534790355u, 3353533667u, + 336163563u, 4106790558u, 2701448228u, 1571536379u, + 1103842411u, 3623110423u, 1635278839u, 1577828979u, + 910322800u, 715583630u, 138128831u, 1017877531u, + 2289162787u, 447994798u, 1897243165u, 4121561445u, + 4150719842u, 2131821093u, 2262395396u, 3305771534u, + 980753571u, 3256525190u, 3128121808u, 1072869975u, + 3507939515u, 4229109952u, 118381341u, 2209831334u }, + 65537 }; RecoveryUI* ui = NULL; @@ -91,14 +129,21 @@ class FakeUI : public RecoveryUI { }; int main(int argc, char **argv) { - if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); + if (argc != 2 && argc != 3) { + fprintf(stderr, "Usage: %s [-f4] \n", argv[0]); return 2; } + RSAPublicKey* key = &test_key; + ++argv; + if (strcmp(argv[0], "-f4") == 0) { + ++argv; + key = &test_f4_key; + } + ui = new FakeUI(); - int result = verify_file(argv[1], &test_key, 1); + int result = verify_file(*argv, key, 1); if (result == VERIFY_SUCCESS) { printf("SUCCESS\n"); return 0; diff --git a/verifier_test.sh b/verifier_test.sh index a1de5c57b..378b0e5ff 100755 --- a/verifier_test.sh +++ b/verifier_test.sh @@ -73,9 +73,24 @@ expect_fail() { run_command $WORK_DIR/verifier_test $WORK_DIR/package.zip && fail } +expect_succeed_f4() { + testname "$1 (should succeed)" + $ADB push $DATA_DIR/$1 $WORK_DIR/package.zip + run_command $WORK_DIR/verifier_test -f4 $WORK_DIR/package.zip || fail +} + +expect_fail_f4() { + testname "$1 (should fail)" + $ADB push $DATA_DIR/$1 $WORK_DIR/package.zip + run_command $WORK_DIR/verifier_test -f4 $WORK_DIR/package.zip && fail +} + expect_fail unsigned.zip expect_fail jarsigned.zip expect_succeed otasigned.zip +expect_fail_f4 otasigned.zip +expect_succeed_f4 otasigned_f4.zip +expect_fail otasigned_f4.zip expect_fail random.zip expect_fail fake-eocd.zip expect_fail alter-metadata.zip -- cgit v1.2.3 From a23075fb0e23978e5b8f3a7c92280ee1b2274e6d Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 6 Aug 2012 16:19:09 -0700 Subject: fix the symlink() command to create directories if needed Full OTAs currently fail if the build contains a directory containing only symlinks, because nothing creates that directory. Change the symlink() command to create any ancestor directories that don't exist. They're created as owner root perms 0700 because we assume that in practice subsequent set_perm_recursive() calls will fix up their ownership and permissions. Change-Id: I4681cbc85863d9778e36b924f0532b2b3ef14310 --- updater/install.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/updater/install.c b/updater/install.c index f981017bf..ba27e9f33 100644 --- a/updater/install.c +++ b/updater/install.c @@ -456,6 +456,26 @@ Value* PackageExtractFileFn(const char* name, State* state, } } +// Create all parent directories of name, if necessary. +static int make_parents(char* name) { + char* p; + for (p = name + (strlen(name)-1); p > name; --p) { + if (*p != '/') continue; + *p = '\0'; + if (make_parents(name) < 0) return -1; + int result = mkdir(name, 0700); + if (result == 0) fprintf(stderr, "symlink(): created [%s]\n", name); + *p = '/'; + if (result == 0 || errno == EEXIST) { + // successfully created or already existed; we're done + return 0; + } else { + fprintf(stderr, "failed to mkdir %s: %s\n", name, strerror(errno)); + return -1; + } + } + return 0; +} // symlink target src1 src2 ... // unlinks any previously existing src1, src2, etc before creating symlinks. @@ -483,6 +503,11 @@ Value* SymlinkFn(const char* name, State* state, int argc, Expr* argv[]) { ++bad; } } + if (make_parents(srcs[i])) { + fprintf(stderr, "%s: failed to symlink %s to %s: making parents failed\n", + name, srcs[i], target); + ++bad; + } if (symlink(target, srcs[i]) < 0) { fprintf(stderr, "%s: failed to symlink %s to %s: %s\n", name, srcs[i], target, strerror(errno)); @@ -504,7 +529,8 @@ Value* SetPermFn(const char* name, State* state, int argc, Expr* argv[]) { int min_args = 4 + (recursive ? 1 : 0); if (argc < min_args) { - return ErrorAbort(state, "%s() expects %d+ args, got %d", name, argc); + return ErrorAbort(state, "%s() expects %d+ args, got %d", + name, min_args, argc); } char** args = ReadVarArgs(state, argc, argv); @@ -626,7 +652,7 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) { buffer = malloc(st.st_size+1); if (buffer == NULL) { - ErrorAbort(state, "%s: failed to alloc %d bytes", name, st.st_size+1); + ErrorAbort(state, "%s: failed to alloc %lld bytes", name, st.st_size+1); goto done; } @@ -638,7 +664,7 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) { } if (fread(buffer, 1, st.st_size, f) != st.st_size) { - ErrorAbort(state, "%s: failed to read %d bytes from %s", + ErrorAbort(state, "%s: failed to read %lld bytes from %s", name, st.st_size+1, filename); fclose(f); goto done; -- cgit v1.2.3 From f510f069fd35eb259799f594975c1a990e41d870 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 8 Aug 2012 13:06:26 -0700 Subject: recovery: import init.recovery.${ro.hardware}.rc Some devices need hardware specific services started in recovery, for example watchdogd. Import init.recovery.${ro.hardware}.rc from the recovery init.rc. Bug: 6953625 Change-Id: I4a4cee210238150ffaabe774a44340ec3c8ff78c --- etc/init.rc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/init.rc b/etc/init.rc index 89a161e70..abc7b318b 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -1,3 +1,5 @@ +import /init.recovery.${ro.hardware}.rc + on early-init start ueventd -- cgit v1.2.3 From fc417fc4c4edcf49fc1e6d2cc95c2c7f381629cd Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Fri, 18 May 2012 20:03:43 -0700 Subject: host modules don't need LOCAL_MODULE_TAGS Change-Id: I5e1df90f18fbaf98e3207c553a8fb859c1064137 --- applypatch/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/applypatch/Android.mk b/applypatch/Android.mk index 0e529d4cb..ef57f243c 100644 --- a/applypatch/Android.mk +++ b/applypatch/Android.mk @@ -50,7 +50,6 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := imgdiff.c utils.c bsdiff.c LOCAL_MODULE := imgdiff LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_MODULE_TAGS := eng LOCAL_C_INCLUDES += external/zlib external/bzip2 LOCAL_STATIC_LIBRARIES += libz libbz -- cgit v1.2.3 From f47ae6a4d9a2f945eb3b74c001c5917446d707f8 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Thu, 31 May 2012 23:21:46 -0700 Subject: Multiple modules with the same name are going away. Change-Id: I4154db066865d6031caa3c2c3b94064b2f28076e --- Android.mk | 94 ++++++++++++++++++++++++++++++++++-------------------- updater/Android.mk | 5 ++- 2 files changed, 63 insertions(+), 36 deletions(-) diff --git a/Android.mk b/Android.mk index 751ed7243..5811c47cd 100644 --- a/Android.mk +++ b/Android.mk @@ -1,7 +1,21 @@ +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -commands_recovery_local_path := $(LOCAL_PATH) + +include $(CLEAR_VARS) LOCAL_SRC_FILES := \ recovery.cpp \ @@ -20,25 +34,37 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true RECOVERY_API_VERSION := 3 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) -LOCAL_STATIC_LIBRARIES := +LOCAL_STATIC_LIBRARIES := \ + libext4_utils_static \ + libsparse \ + libminzip \ + libz \ + libmtdutils \ + libmincrypt \ + libminadbd \ + libminui \ + libpixelflinger_static \ + libpng \ + libcutils \ + libstdc++ \ + libc ifeq ($(TARGET_USERIMAGES_USE_EXT4), true) -LOCAL_CFLAGS += -DUSE_EXT4 -LOCAL_C_INCLUDES += system/extras/ext4_utils -LOCAL_STATIC_LIBRARIES += libext4_utils libsparse libz + LOCAL_CFLAGS += -DUSE_EXT4 + LOCAL_C_INCLUDES += system/extras/ext4_utils + LOCAL_STATIC_LIBRARIES += libext4_utils_static libz endif ifeq ($(HAVE_SELINUX), true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_STATIC_LIBRARIES += libselinux -LOCAL_CFLAGS += -DHAVE_SELINUX + LOCAL_C_INCLUDES += external/libselinux/include + LOCAL_STATIC_LIBRARIES += libselinux + LOCAL_CFLAGS += -DHAVE_SELINUX endif # HAVE_SELINUX # This binary is in the recovery ramdisk, which is otherwise a copy of root. # It gets copied there in config/Makefile. LOCAL_MODULE_TAGS suppresses # a (redundant) copy of the binary in /system/bin for user builds. # TODO: Build the ramdisk image in a more principled way. - LOCAL_MODULE_TAGS := eng ifeq ($(TARGET_RECOVERY_UI_LIB),) @@ -46,15 +72,11 @@ ifeq ($(TARGET_RECOVERY_UI_LIB),) else LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UI_LIB) endif -LOCAL_STATIC_LIBRARIES += libext4_utils libsparse -LOCAL_STATIC_LIBRARIES += libminzip libz libmtdutils libmincrypt libminadbd -LOCAL_STATIC_LIBRARIES += libminui libpixelflinger_static libpng libcutils -LOCAL_STATIC_LIBRARIES += libstdc++ libc ifeq ($(HAVE_SELINUX),true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_STATIC_LIBRARIES += libselinux -LOCAL_CFLAGS += -DHAVE_SELINUX + LOCAL_C_INCLUDES += external/libselinux/include + LOCAL_STATIC_LIBRARIES += libselinux + LOCAL_CFLAGS += -DHAVE_SELINUX endif # HAVE_SELINUX LOCAL_C_INCLUDES += system/extras/ext4_utils @@ -62,28 +84,30 @@ LOCAL_C_INCLUDES += system/extras/ext4_utils include $(BUILD_EXECUTABLE) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := verifier_test.cpp verifier.cpp ui.cpp +include $(CLEAR_VARS) LOCAL_MODULE := verifier_test - LOCAL_FORCE_STATIC_EXECUTABLE := true - LOCAL_MODULE_TAGS := tests - -LOCAL_STATIC_LIBRARIES := libmincrypt libminui libcutils libstdc++ libc - +LOCAL_SRC_FILES := \ + verifier_test.cpp \ + verifier.cpp \ + ui.cpp +LOCAL_STATIC_LIBRARIES := \ + libmincrypt \ + libminui \ + libcutils \ + libstdc++ \ + libc include $(BUILD_EXECUTABLE) -include $(commands_recovery_local_path)/minui/Android.mk -include $(commands_recovery_local_path)/minelf/Android.mk -include $(commands_recovery_local_path)/minzip/Android.mk -include $(commands_recovery_local_path)/minadbd/Android.mk -include $(commands_recovery_local_path)/mtdutils/Android.mk -include $(commands_recovery_local_path)/tools/Android.mk -include $(commands_recovery_local_path)/edify/Android.mk -include $(commands_recovery_local_path)/updater/Android.mk -include $(commands_recovery_local_path)/applypatch/Android.mk -commands_recovery_local_path := +include $(LOCAL_PATH)/minui/Android.mk \ + $(LOCAL_PATH)/minelf/Android.mk \ + $(LOCAL_PATH)/minzip/Android.mk \ + $(LOCAL_PATH)/minadbd/Android.mk \ + $(LOCAL_PATH)/mtdutils/Android.mk \ + $(LOCAL_PATH)/tools/Android.mk \ + $(LOCAL_PATH)/edify/Android.mk \ + $(LOCAL_PATH)/updater/Android.mk \ + $(LOCAL_PATH)/applypatch/Android.mk diff --git a/updater/Android.mk b/updater/Android.mk index fcaf6d531..38bb1ae95 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -21,7 +21,10 @@ LOCAL_SRC_FILES := $(updater_src_files) ifeq ($(TARGET_USERIMAGES_USE_EXT4), true) LOCAL_CFLAGS += -DUSE_EXT4 LOCAL_C_INCLUDES += system/extras/ext4_utils -LOCAL_STATIC_LIBRARIES += libext4_utils libsparse libz +LOCAL_STATIC_LIBRARIES += \ + libext4_utils_static \ + libsparse \ + libz endif ifeq ($(HAVE_SELINUX), true) -- cgit v1.2.3 From e709c24f27afc11714b00bf2487dcadbbf2cff9c Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Mon, 23 Jul 2012 19:14:30 -0700 Subject: Use the static version of libsparse Change-Id: I664f8dc7939f8f902e4775eaaf6476fcd4ab8ed2 --- Android.mk | 2 +- updater/Android.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.mk b/Android.mk index 5811c47cd..1c78b4287 100644 --- a/Android.mk +++ b/Android.mk @@ -36,7 +36,7 @@ LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) LOCAL_STATIC_LIBRARIES := \ libext4_utils_static \ - libsparse \ + libsparse_static \ libminzip \ libz \ libmtdutils \ diff --git a/updater/Android.mk b/updater/Android.mk index 38bb1ae95..8876120b0 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -23,7 +23,7 @@ LOCAL_CFLAGS += -DUSE_EXT4 LOCAL_C_INCLUDES += system/extras/ext4_utils LOCAL_STATIC_LIBRARIES += \ libext4_utils_static \ - libsparse \ + libsparse_static \ libz endif -- cgit v1.2.3 From a3ccba6d314cb29b02d1dbda9a71427b11da936d Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 20 Aug 2012 15:28:02 -0700 Subject: add bonus data feature to imgdiff/imgpatch/applypatch The bonus data option lets you give an additional blob of uncompressed data to be used when constructing a patch for chunk #1 of an image. The same blob must be available at patch time, and can be passed to the command-line applypatch tool (this feature is not accessible from edify scripts). This will be used to reduce the size of recovery-from-boot patches by storing parts of the recovery ramdisk (the UI images) on the system partition. Change-Id: Iac1959cdf7f5e4582f8d434e83456e483b64c02c --- applypatch/applypatch.c | 13 ++++++----- applypatch/applypatch.h | 6 ++++-- applypatch/imgdiff.c | 57 ++++++++++++++++++++++++++++++++++++++++++------- applypatch/imgpatch.c | 21 ++++++++++++++---- applypatch/main.c | 23 ++++++++++++++++++-- updater/install.c | 2 +- 6 files changed, 100 insertions(+), 22 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 488fd8c6f..7b8a010e3 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -39,7 +39,8 @@ static int GenerateTarget(FileContents* source_file, const char* source_filename, const char* target_filename, const uint8_t target_sha1[SHA_DIGEST_SIZE], - size_t target_size); + size_t target_size, + const Value* bonus_data); static int mtd_partitions_scanned = 0; @@ -617,7 +618,8 @@ int applypatch(const char* source_filename, size_t target_size, int num_patches, char** const patch_sha1_str, - Value** patch_data) { + Value** patch_data, + Value* bonus_data) { printf("\napplying patch to %s\n", source_filename); if (target_filename[0] == '-' && @@ -699,7 +701,7 @@ int applypatch(const char* source_filename, int result = GenerateTarget(&source_file, source_patch_value, ©_file, copy_patch_value, source_filename, target_filename, - target_sha1, target_size); + target_sha1, target_size, bonus_data); free(source_file.data); free(copy_file.data); @@ -713,7 +715,8 @@ static int GenerateTarget(FileContents* source_file, const char* source_filename, const char* target_filename, const uint8_t target_sha1[SHA_DIGEST_SIZE], - size_t target_size) { + size_t target_size, + const Value* bonus_data) { int retry = 1; SHA_CTX ctx; int output; @@ -867,7 +870,7 @@ static int GenerateTarget(FileContents* source_file, } else if (header_bytes_read >= 8 && memcmp(header, "IMGDIFF2", 8) == 0) { result = ApplyImagePatch(source_to_use->data, source_to_use->size, - patch, sink, token, &ctx); + patch, sink, token, &ctx, bonus_data); } else { printf("Unknown patch file format\n"); return 1; diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index fb58843ba..d1a023293 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -55,7 +55,8 @@ int applypatch(const char* source_filename, size_t target_size, int num_patches, char** const patch_sha1_str, - Value** patch_data); + Value** patch_data, + Value* bonus_data); int applypatch_check(const char* filename, int num_patches, char** const patch_sha1_str); @@ -79,7 +80,8 @@ int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size, // imgpatch.c int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size, const Value* patch, - SinkFn sink, void* token, SHA_CTX* ctx); + SinkFn sink, void* token, SHA_CTX* ctx, + const Value* bonus_data); // freecache.c int MakeFreeSpaceOnCache(size_t bytes_needed); diff --git a/applypatch/imgdiff.c b/applypatch/imgdiff.c index 6b9ebee5c..05c4f250f 100644 --- a/applypatch/imgdiff.c +++ b/applypatch/imgdiff.c @@ -111,6 +111,14 @@ * * After the header there are 'chunk count' bsdiff patches; the offset * of each from the beginning of the file is specified in the header. + * + * This tool can take an optional file of "bonus data". This is an + * extra file of data that is appended to chunk #1 after it is + * compressed (it must be a CHUNK_DEFLATE chunk). The same file must + * be available (and passed to applypatch with -b) when applying the + * patch. This is used to reduce the size of recovery-from-boot + * patches by combining the boot image with recovery ramdisk + * information that is stored on the system partition. */ #include @@ -772,21 +780,45 @@ void DumpChunks(ImageChunk* chunks, int num_chunks) { } int main(int argc, char** argv) { - if (argc != 4 && argc != 5) { - usage: - printf("usage: %s [-z] \n", - argv[0]); - return 2; - } - int zip_mode = 0; - if (strcmp(argv[1], "-z") == 0) { + if (argc >= 2 && strcmp(argv[1], "-z") == 0) { zip_mode = 1; --argc; ++argv; } + size_t bonus_size = 0; + unsigned char* bonus_data = NULL; + if (argc >= 3 && strcmp(argv[1], "-b") == 0) { + struct stat st; + if (stat(argv[2], &st) != 0) { + printf("failed to stat bonus file %s: %s\n", argv[2], strerror(errno)); + return 1; + } + bonus_size = st.st_size; + bonus_data = malloc(bonus_size); + FILE* f = fopen(argv[2], "rb"); + if (f == NULL) { + printf("failed to open bonus file %s: %s\n", argv[2], strerror(errno)); + return 1; + } + if (fread(bonus_data, 1, bonus_size, f) != bonus_size) { + printf("failed to read bonus file %s: %s\n", argv[2], strerror(errno)); + return 1; + } + fclose(f); + + argc -= 2; + argv += 2; + } + + if (argc != 4) { + usage: + printf("usage: %s [-z] [-b ] \n", + argv[0]); + return 2; + } int num_src_chunks; ImageChunk* src_chunks; @@ -909,6 +941,8 @@ int main(int argc, char** argv) { // Compute bsdiff patches for each chunk's data (the uncompressed // data, in the case of deflate chunks). + DumpChunks(src_chunks, num_src_chunks); + printf("Construct patches for %d chunks...\n", num_tgt_chunks); unsigned char** patch_data = malloc(num_tgt_chunks * sizeof(unsigned char*)); size_t* patch_size = malloc(num_tgt_chunks * sizeof(size_t)); @@ -923,6 +957,13 @@ int main(int argc, char** argv) { patch_data[i] = MakePatch(src_chunks, tgt_chunks+i, patch_size+i); } } else { + if (i == 1 && bonus_data) { + printf(" using %d bytes of bonus data for chunk %d\n", bonus_size, i); + src_chunks[i].data = realloc(src_chunks[i].data, src_chunks[i].len + bonus_size); + memcpy(src_chunks[i].data+src_chunks[i].len, bonus_data, bonus_size); + src_chunks[i].len += bonus_size; + } + patch_data[i] = MakePatch(src_chunks+i, tgt_chunks+i, patch_size+i); } printf("patch %3d is %d bytes (of %d)\n", diff --git a/applypatch/imgpatch.c b/applypatch/imgpatch.c index e3ee80ac0..3a1df3872 100644 --- a/applypatch/imgpatch.c +++ b/applypatch/imgpatch.c @@ -37,7 +37,8 @@ */ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size, const Value* patch, - SinkFn sink, void* token, SHA_CTX* ctx) { + SinkFn sink, void* token, SHA_CTX* ctx, + const Value* bonus_data) { ssize_t pos = 12; char* header = patch->data; if (patch->size < 12) { @@ -123,6 +124,12 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size, // Decompress the source data; the chunk header tells us exactly // how big we expect it to be when decompressed. + // Note: expanded_len will include the bonus data size if + // the patch was constructed with bonus data. The + // deflation will come up 'bonus_size' bytes short; these + // must be appended from the bonus_data value. + size_t bonus_size = (i == 1 && bonus_data != NULL) ? bonus_data->size : 0; + unsigned char* expanded_source = malloc(expanded_len); if (expanded_source == NULL) { printf("failed to allocate %d bytes for expanded_source\n", @@ -153,13 +160,19 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size, printf("source inflation returned %d\n", ret); return -1; } - // We should have filled the output buffer exactly. - if (strm.avail_out != 0) { - printf("source inflation short by %d bytes\n", strm.avail_out); + // We should have filled the output buffer exactly, except + // for the bonus_size. + if (strm.avail_out != bonus_size) { + printf("source inflation short by %d bytes\n", strm.avail_out-bonus_size); return -1; } inflateEnd(&strm); + if (bonus_size) { + memcpy(expanded_source + (expanded_len - bonus_size), + bonus_data->data, bonus_size); + } + // Next, apply the bsdiff patch (in memory) to the uncompressed // data. unsigned char* uncompressed_target_data; diff --git a/applypatch/main.c b/applypatch/main.c index 7025a2e2e..f61db5d9e 100644 --- a/applypatch/main.c +++ b/applypatch/main.c @@ -100,6 +100,21 @@ static int ParsePatchArgs(int argc, char** argv, } int PatchMode(int argc, char** argv) { + Value* bonus = NULL; + if (argc >= 3 && strcmp(argv[1], "-b") == 0) { + FileContents fc; + if (LoadFileContents(argv[2], &fc, RETOUCH_DONT_MASK) != 0) { + printf("failed to load bonus file %s\n", argv[2]); + return 1; + } + bonus = malloc(sizeof(Value)); + bonus->type = VAL_BLOB; + bonus->size = fc.size; + bonus->data = (char*)fc.data; + argc -= 2; + argv += 2; + } + if (argc < 6) { return 2; } @@ -120,7 +135,7 @@ int PatchMode(int argc, char** argv) { } int result = applypatch(argv[1], argv[2], argv[3], target_size, - num_patches, sha1s, patches); + num_patches, sha1s, patches, bonus); int i; for (i = 0; i < num_patches; ++i) { @@ -130,6 +145,10 @@ int PatchMode(int argc, char** argv) { free(p); } } + if (bonus) { + free(bonus->data); + free(bonus); + } free(sha1s); free(patches); @@ -163,7 +182,7 @@ int main(int argc, char** argv) { if (argc < 2) { usage: printf( - "usage: %s " + "usage: %s [-b ] " "[: ...]\n" " or %s -c [ ...]\n" " or %s -s \n" diff --git a/updater/install.c b/updater/install.c index ba27e9f33..41f053d01 100644 --- a/updater/install.c +++ b/updater/install.c @@ -901,7 +901,7 @@ Value* ApplyPatchFn(const char* name, State* state, int argc, Expr* argv[]) { int result = applypatch(source_filename, target_filename, target_sha1, target_size, - patchcount, patch_sha_str, patches); + patchcount, patch_sha_str, patches, NULL); for (i = 0; i < patchcount; ++i) { FreeValue(patches[i]); -- cgit v1.2.3 From 02ec6b88ed4e6cf40cc257572b07c7277b7b6341 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 22 Aug 2012 17:26:40 -0700 Subject: add simple text to recovery UI - recovery takes a --locale argument, which will be passed by the main system - the locale is saved in cache, in case the --locale argument is missing (eg, when recovery is started from fastboot) - we include images that have prerendered text for many locales - we split the background states into four (installing update, erasing, no command, error) so that appropriate text can be shown. Change-Id: I731b8108e83d5ccc09a4aacfc1dbf7e86b397aaf --- install.cpp | 2 +- install.h | 2 +- minui/graphics.c | 16 +++++ minui/minui.h | 2 + minui/resources.c | 150 +++++++++++++++++++++++++++++++++++++++++ recovery.cpp | 63 ++++++++++++++--- res/images/erasing_text.png | Bin 0 -> 4511 bytes res/images/error_text.png | Bin 0 -> 3119 bytes res/images/installing_text.png | Bin 0 -> 6433 bytes res/images/no_command_text.png | Bin 0 -> 2528 bytes screen_ui.cpp | 61 ++++++++++++----- screen_ui.h | 6 +- ui.h | 2 +- 13 files changed, 274 insertions(+), 30 deletions(-) create mode 100644 res/images/erasing_text.png create mode 100644 res/images/error_text.png create mode 100644 res/images/installing_text.png create mode 100644 res/images/no_command_text.png diff --git a/install.cpp b/install.cpp index 819650e1f..b8f478130 100644 --- a/install.cpp +++ b/install.cpp @@ -277,7 +277,7 @@ exit: static int really_install_package(const char *path, int* wipe_cache) { - ui->SetBackground(RecoveryUI::INSTALLING); + ui->SetBackground(RecoveryUI::INSTALLING_UPDATE); ui->Print("Finding update package...\n"); ui->SetProgressType(RecoveryUI::INDETERMINATE); LOGI("Update location: %s\n", path); diff --git a/install.h b/install.h index 1943f02d3..2ada529ef 100644 --- a/install.h +++ b/install.h @@ -23,7 +23,7 @@ extern "C" { #endif -enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT }; +enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT, INSTALL_NONE }; // Install the package specified by root_path. If INSTALL_SUCCESS is // returned and *wipe_cache is true on exit, caller should wipe the // cache partition. diff --git a/minui/graphics.c b/minui/graphics.c index 81f13ad2c..88572a878 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -244,6 +244,22 @@ int gr_text(int x, int y, const char *s) return x; } +void gr_texticon(int x, int y, gr_surface icon) { + GGLContext* gl = gr_context; + + gl->bindTexture(gl, (GGLSurface*) icon); + gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); + gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); + gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); + gl->enable(gl, GGL_TEXTURE_2D); + + int w = gr_get_width(icon); + int h = gr_get_height(icon); + + gl->texCoord2i(gl, -x, -y); + gl->recti(gl, x, y, x+gr_get_width(icon), y+gr_get_height(icon)); +} + void gr_fill(int x, int y, int w, int h) { GGLContext *gl = gr_context; diff --git a/minui/minui.h b/minui/minui.h index 74da4e9c0..767ffcb50 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -38,6 +38,7 @@ void gr_fb_blank(bool blank); void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); void gr_fill(int x, int y, int w, int h); int gr_text(int x, int y, const char *s); + void gr_texticon(int x, int y, gr_surface icon); int gr_measure(const char *s); void gr_font_size(int *x, int *y); @@ -71,6 +72,7 @@ void ev_dispatch(void); // Returns 0 if no error, else negative. int res_create_surface(const char* name, gr_surface* pSurface); +int res_create_localized_surface(const char* name, gr_surface* pSurface); void res_free_surface(gr_surface surface); #ifdef __cplusplus diff --git a/minui/resources.c b/minui/resources.c index b437a87cb..af8720a56 100644 --- a/minui/resources.c +++ b/minui/resources.c @@ -33,6 +33,8 @@ #include "minui.h" +extern char* locale; + // libpng gives "undefined reference to 'pow'" errors, and I have no // idea how to convince the build system to link with -lm. We don't // need this functionality (it's used for gamma adjustment) so provide @@ -173,6 +175,154 @@ exit: return result; } +static int matches_locale(const char* loc) { + if (locale == NULL) return 0; + + printf("matching loc=[%s] vs locale=[%s]\n", loc, locale); + + if (strcmp(loc, locale) == 0) return 1; + + // if loc does *not* have an underscore, and it matches the start + // of locale, and the next character in locale *is* an underscore, + // that's a match. For instance, loc == "en" matches locale == + // "en_US". + + int i; + for (i = 0; loc[i] != 0 && loc[i] != '_'; ++i); + if (loc[i] == '_') return 0; + printf(" partial match possible; i = %d\n", i); + + return (strncmp(locale, loc, i) == 0 && locale[i] == '_'); +} + +int res_create_localized_surface(const char* name, gr_surface* pSurface) { + char resPath[256]; + GGLSurface* surface = NULL; + int result = 0; + unsigned char header[8]; + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + *pSurface = NULL; + + snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name); + resPath[sizeof(resPath)-1] = '\0'; + FILE* fp = fopen(resPath, "rb"); + if (fp == NULL) { + result = -1; + goto exit; + } + + size_t bytesRead = fread(header, 1, sizeof(header), fp); + if (bytesRead != sizeof(header)) { + result = -2; + goto exit; + } + + if (png_sig_cmp(header, 0, sizeof(header))) { + result = -3; + goto exit; + } + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) { + result = -4; + goto exit; + } + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + result = -5; + goto exit; + } + + if (setjmp(png_jmpbuf(png_ptr))) { + result = -6; + goto exit; + } + + png_init_io(png_ptr, fp); + png_set_sig_bytes(png_ptr, sizeof(header)); + png_read_info(png_ptr, info_ptr); + + size_t width = info_ptr->width; + size_t height = info_ptr->height; + size_t stride = 4 * width; + + printf("image size is %d x %d\n", width, height); + + int color_type = info_ptr->color_type; + int bit_depth = info_ptr->bit_depth; + int channels = info_ptr->channels; + printf("color_type %d bit_depth %d channels %d\n", + color_type, bit_depth, channels); + + if (!(bit_depth == 8 && + (channels == 1 && color_type == PNG_COLOR_TYPE_GRAY))) { + return -7; + printf("exiting -7\n"); + goto exit; + } + + unsigned char* row = malloc(width); + int y; + for (y = 0; y < height; ++y) { + png_read_row(png_ptr, row, NULL); + int w = (row[1] << 8) | row[0]; + int h = (row[3] << 8) | row[2]; + int len = row[4]; + char* loc = row+5; + + printf("row %d: %s %d x %d\n", y, loc, w, h); + + if (y+1+h >= height || matches_locale(loc)) { + printf(" taking this one\n"); + + surface = malloc(sizeof(GGLSurface)); + if (surface == NULL) { + result = -8; + goto exit; + } + unsigned char* pData = malloc(w*h); + + surface->version = sizeof(GGLSurface); + surface->width = w; + surface->height = h; + surface->stride = w; /* Yes, pixels, not bytes */ + surface->data = pData; + surface->format = GGL_PIXEL_FORMAT_A_8; + + int i; + for (i = 0; i < h; ++i, ++y) { + png_read_row(png_ptr, row, NULL); + memcpy(pData + i*w, row, w); + } + + *pSurface = (gr_surface) surface; + break; + } else { + printf(" skipping\n"); + int i; + for (i = 0; i < h; ++i, ++y) { + png_read_row(png_ptr, row, NULL); + } + } + } + +exit: + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + if (fp != NULL) { + fclose(fp); + } + if (result < 0) { + if (surface) { + free(surface); + } + } + return result; +} + void res_free_surface(gr_surface surface) { GGLSurface* pSurface = (GGLSurface*) surface; if (pSurface) { diff --git a/recovery.cpp b/recovery.cpp index ce4358a53..e374c7d5a 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -54,6 +54,7 @@ static const struct option OPTIONS[] = { { "wipe_cache", no_argument, NULL, 'c' }, { "show_text", no_argument, NULL, 't' }, { "just_exit", no_argument, NULL, 'x' }, + { "locale", required_argument, NULL, 'l' }, { NULL, 0, NULL, 0 }, }; @@ -62,6 +63,7 @@ static const char *INTENT_FILE = "/cache/recovery/intent"; static const char *LOG_FILE = "/cache/recovery/log"; static const char *LAST_LOG_FILE = "/cache/recovery/last_log"; static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install"; +static const char *LOCALE_FILE = "/cache/recovery/locale"; static const char *CACHE_ROOT = "/cache"; static const char *SDCARD_ROOT = "/sdcard"; static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log"; @@ -69,6 +71,7 @@ static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install"; static const char *SIDELOAD_TEMP_DIR = "/tmp/sideload"; RecoveryUI* ui = NULL; +char* locale = NULL; /* * The recovery tool communicates with the main system through /cache files. @@ -283,6 +286,15 @@ finish_recovery(const char *send_intent) { chmod(LAST_LOG_FILE, 0640); chmod(LAST_INSTALL_FILE, 0644); + // Save the locale to cache, so if recovery is next started up + // without a --locale argument (eg, directly from the bootloader) + // it will use the last-known locale. + if (locale != NULL) { + FILE* fp = fopen(LOCALE_FILE, "w"); + fwrite(locale, 1, strlen(locale), fp); + fclose(fp); + } + // Reset to normal system boot so recovery won't cycle indefinitely. struct bootloader_message boot; memset(&boot, 0, sizeof(boot)); @@ -300,7 +312,7 @@ finish_recovery(const char *send_intent) { static int erase_volume(const char *volume) { - ui->SetBackground(RecoveryUI::INSTALLING); + ui->SetBackground(RecoveryUI::ERASING); ui->SetProgressType(RecoveryUI::INDETERMINATE); ui->Print("Formatting %s...\n", volume); @@ -658,6 +670,7 @@ prompt_and_wait(Device* device) { for (;;) { finish_recovery(NULL); + ui->SetBackground(RecoveryUI::NO_COMMAND); ui->SetProgressType(RecoveryUI::EMPTY); int chosen_item = get_menu_selection(headers, device->GetMenuItems(), 0, 0, device); @@ -679,6 +692,7 @@ prompt_and_wait(Device* device) { break; case Device::WIPE_CACHE: + ui->ShowText(false); ui->Print("\n-- Wiping cache...\n"); erase_volume("/cache"); ui->Print("Cache wipe complete.\n"); @@ -757,6 +771,24 @@ print_property(const char *key, const char *name, void *cookie) { printf("%s=%s\n", key, name); } +static void +load_locale_from_cache() { + FILE* fp = fopen_path(LOCALE_FILE, "r"); + char buffer[80]; + if (fp != NULL) { + fgets(buffer, sizeof(buffer), fp); + int j = 0; + int i; + for (i = 0; i < sizeof(buffer) && buffer[i]; ++i) { + if (!isspace(buffer[i])) { + buffer[j++] = buffer[i]; + } + } + buffer[j] = 0; + locale = strdup(buffer); + } +} + int main(int argc, char **argv) { time_t start = time(NULL); @@ -779,18 +811,13 @@ main(int argc, char **argv) { printf("Starting recovery on %s", ctime(&start)); - Device* device = make_device(); - ui = device->GetUI(); - - ui->Init(); - ui->SetBackground(RecoveryUI::NONE); load_volume_table(); get_args(&argc, &argv); int previous_runs = 0; const char *send_intent = NULL; const char *update_package = NULL; - int wipe_data = 0, wipe_cache = 0; + int wipe_data = 0, wipe_cache = 0, show_text = 0; bool just_exit = false; int arg; @@ -801,14 +828,27 @@ main(int argc, char **argv) { case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; - case 't': ui->ShowText(true); break; + case 't': show_text = 1; break; case 'x': just_exit = true; break; + case 'l': locale = optarg; break; case '?': LOGE("Invalid command argument\n"); continue; } } + if (locale == NULL) { + load_locale_from_cache(); + } + printf("locale is [%s]\n", locale); + + Device* device = make_device(); + ui = device->GetUI(); + + ui->Init(); + ui->SetBackground(RecoveryUI::NONE); + if (show_text) ui->ShowText(true); + #ifdef HAVE_SELINUX struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "/file_contexts" } @@ -868,10 +908,13 @@ main(int argc, char **argv) { if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui->Print("Cache wipe failed.\n"); } else if (!just_exit) { - status = INSTALL_ERROR; // No command specified + status = INSTALL_NONE; // No command specified + ui->SetBackground(RecoveryUI::NO_COMMAND); } - if (status != INSTALL_SUCCESS) ui->SetBackground(RecoveryUI::ERROR); + if (status == INSTALL_ERROR || status == INSTALL_CORRUPT) { + ui->SetBackground(RecoveryUI::ERROR); + } if (status != INSTALL_SUCCESS || ui->IsTextVisible()) { prompt_and_wait(device); } diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png new file mode 100644 index 000000000..f92119772 Binary files /dev/null and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png new file mode 100644 index 000000000..581347094 Binary files /dev/null and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png new file mode 100644 index 000000000..c48a45295 Binary files /dev/null and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png new file mode 100644 index 000000000..1d6a5b7cf Binary files /dev/null and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 3c6c3ae25..bb879dfac 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -94,7 +94,7 @@ void ScreenRecoveryUI::draw_install_overlay_locked(int frame) { int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); gr_blit(surface, 0, 0, iconWidth, iconHeight, - install_overlay_offset_x, install_overlay_offset_y); + overlay_offset_x, overlay_offset_y); } // Clear the screen and draw the currently selected background icon (if any). @@ -107,14 +107,26 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) if (icon) { gr_surface surface = backgroundIcon[icon]; + gr_surface text_surface = backgroundText[icon]; + int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); + int textWidth = gr_get_width(text_surface); + int textHeight = gr_get_height(text_surface); + int iconX = (gr_fb_width() - iconWidth) / 2; - int iconY = (gr_fb_height() - iconHeight) / 2; + int iconY = (gr_fb_height() - (iconHeight+textHeight+40)) / 2; + + int textX = (gr_fb_width() - textWidth) / 2; + int textY = ((gr_fb_height() - (iconHeight+textHeight+40)) / 2) + iconHeight + 40; + gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); - if (icon == INSTALLING) { + if (icon == INSTALLING_UPDATE || icon == ERASING) { draw_install_overlay_locked(installingFrame); } + + gr_color(255, 255, 255, 255); + gr_texticon(textX, textY, text_surface); } } @@ -124,12 +136,12 @@ void ScreenRecoveryUI::draw_progress_locked() { if (currentIcon == ERROR) return; - if (currentIcon == INSTALLING) { + if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { draw_install_overlay_locked(installingFrame); } if (progressBarType != EMPTY) { - int iconHeight = gr_get_height(backgroundIcon[INSTALLING]); + int iconHeight = gr_get_height(backgroundIcon[INSTALLING_UPDATE]); int width = gr_get_width(progressBarEmpty); int height = gr_get_height(progressBarEmpty); @@ -242,7 +254,8 @@ void ScreenRecoveryUI::progress_loop() { // update the installation animation, if active // skip this if we have a text overlay (too expensive to update) - if (currentIcon == INSTALLING && installing_frames > 0 && !show_text) { + if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) && + installing_frames > 0 && !show_text) { installingFrame = (installingFrame + 1) % installing_frames; redraw = 1; } @@ -283,6 +296,13 @@ void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) { } } +void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) { + int result = res_create_localized_surface(filename, surface); + if (result < 0) { + LOGE("missing bitmap %s\n(Code %d)\n", filename, result); + } +} + void ScreenRecoveryUI::Init() { gr_init(); @@ -295,11 +315,19 @@ void ScreenRecoveryUI::Init() text_cols = gr_fb_width() / CHAR_WIDTH; if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; - LoadBitmap("icon_installing", &backgroundIcon[INSTALLING]); + LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); + backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; LoadBitmap("icon_error", &backgroundIcon[ERROR]); + backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; + LoadBitmap("progress_empty", &progressBarEmpty); LoadBitmap("progress_fill", &progressBarFill); + LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]); + LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]); + LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]); + LoadLocalizedBitmap("error_text", &backgroundText[ERROR]); + int i; progressBarIndeterminate = (gr_surface*)malloc(indeterminate_frames * @@ -321,14 +349,6 @@ void ScreenRecoveryUI::Init() sprintf(filename, "icon_installing_overlay%02d", i+1); LoadBitmap(filename, installationOverlay+i); } - - // Adjust the offset to account for the positioning of the - // base image on the screen. - if (backgroundIcon[INSTALLING] != NULL) { - gr_surface bg = backgroundIcon[INSTALLING]; - install_overlay_offset_x += (gr_fb_width() - gr_get_width(bg)) / 2; - install_overlay_offset_y += (gr_fb_height() - gr_get_height(bg)) / 2; - } } else { installationOverlay = NULL; } @@ -343,6 +363,17 @@ void ScreenRecoveryUI::SetBackground(Icon icon) pthread_mutex_lock(&updateMutex); currentIcon = icon; update_screen_locked(); + + // Adjust the offset to account for the positioning of the + // base image on the screen. + if (backgroundIcon[icon] != NULL) { + gr_surface bg = backgroundIcon[icon]; + gr_surface text = backgroundText[icon]; + overlay_offset_x = install_overlay_offset_x + (gr_fb_width() - gr_get_width(bg)) / 2; + overlay_offset_y = install_overlay_offset_y + + (gr_fb_height() - (gr_get_height(bg) + gr_get_height(text) + 40)) / 2; + } + pthread_mutex_unlock(&updateMutex); } diff --git a/screen_ui.h b/screen_ui.h index 34929ee1a..16ee741b7 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -57,7 +57,8 @@ class ScreenRecoveryUI : public RecoveryUI { int installingFrame; pthread_mutex_t updateMutex; - gr_surface backgroundIcon[3]; + gr_surface backgroundIcon[5]; + gr_surface backgroundText[5]; gr_surface *installationOverlay; gr_surface *progressBarIndeterminate; gr_surface progressBarEmpty; @@ -92,6 +93,7 @@ class ScreenRecoveryUI : public RecoveryUI { int indeterminate_frames; int installing_frames; int install_overlay_offset_x, install_overlay_offset_y; + int overlay_offset_x, overlay_offset_y; void draw_install_overlay_locked(int frame); void draw_background_locked(Icon icon); @@ -104,7 +106,7 @@ class ScreenRecoveryUI : public RecoveryUI { void progress_loop(); void LoadBitmap(const char* filename, gr_surface* surface); - + void LoadLocalizedBitmap(const char* filename, gr_surface* surface); }; #endif // RECOVERY_UI_H diff --git a/ui.h b/ui.h index 0d3b7bb98..ccbb466ac 100644 --- a/ui.h +++ b/ui.h @@ -31,7 +31,7 @@ class RecoveryUI { virtual void Init(); // Set the overall recovery state ("background image"). - enum Icon { NONE, INSTALLING, ERROR }; + enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR }; virtual void SetBackground(Icon icon) = 0; // --- progress indicator --- -- cgit v1.2.3 From 4f33e55d1c38d2f72f3306a82c177850f3676408 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 23 Aug 2012 13:16:12 -0700 Subject: change recovery images to android with spinner Also make writing the locale a bit more robust. Change-Id: I803dd0aa0b9d6661fad74ea13fb085682402323c --- recovery.cpp | 21 ++++++++++++--------- res/images/icon_error.png | Bin 19306 -> 18244 bytes res/images/icon_installing.png | Bin 25261 -> 21072 bytes res/images/icon_installing_overlay01.png | Bin 10095 -> 8017 bytes res/images/icon_installing_overlay02.png | Bin 9990 -> 7803 bytes res/images/icon_installing_overlay03.png | Bin 9782 -> 7489 bytes res/images/icon_installing_overlay04.png | Bin 9817 -> 7150 bytes res/images/icon_installing_overlay05.png | Bin 9863 -> 7271 bytes res/images/icon_installing_overlay06.png | Bin 9944 -> 7400 bytes res/images/icon_installing_overlay07.png | Bin 10062 -> 7568 bytes res/images/icon_installing_overlay08.png | Bin 0 -> 7901 bytes res/images/icon_installing_overlay09.png | Bin 0 -> 8455 bytes res/images/icon_installing_overlay10.png | Bin 0 -> 8740 bytes res/images/icon_installing_overlay11.png | Bin 0 -> 8764 bytes res/images/icon_installing_overlay12.png | Bin 0 -> 8547 bytes res/images/icon_installing_overlay13.png | Bin 0 -> 8405 bytes res/images/icon_installing_overlay14.png | Bin 0 -> 8114 bytes res/images/icon_installing_overlay15.png | Bin 0 -> 7740 bytes res/images/icon_installing_overlay16.png | Bin 0 -> 7685 bytes res/images/icon_installing_overlay17.png | Bin 0 -> 7719 bytes res/images/icon_installing_overlay18.png | Bin 0 -> 7565 bytes res/images/icon_installing_overlay19.png | Bin 0 -> 7259 bytes res/images/icon_installing_overlay20.png | Bin 0 -> 6993 bytes res/images/icon_installing_overlay21.png | Bin 0 -> 7361 bytes res/images/icon_installing_overlay22.png | Bin 0 -> 7457 bytes res/images/icon_installing_overlay23.png | Bin 0 -> 7512 bytes res/images/icon_installing_overlay24.png | Bin 0 -> 7572 bytes res/images/icon_installing_overlay25.png | Bin 0 -> 7768 bytes res/images/icon_installing_overlay26.png | Bin 0 -> 8299 bytes res/images/icon_installing_overlay27.png | Bin 0 -> 8642 bytes res/images/icon_installing_overlay28.png | Bin 0 -> 8828 bytes res/images/icon_installing_overlay29.png | Bin 0 -> 8898 bytes res/images/icon_installing_overlay30.png | Bin 0 -> 8700 bytes res/images/icon_installing_overlay31.png | Bin 0 -> 8343 bytes res/images/icon_installing_overlay32.png | Bin 0 -> 7846 bytes res/images/icon_installing_overlay33.png | Bin 0 -> 7673 bytes res/images/icon_installing_overlay34.png | Bin 0 -> 7378 bytes res/images/icon_installing_overlay35.png | Bin 0 -> 7203 bytes res/images/icon_installing_overlay36.png | Bin 0 -> 7208 bytes res/images/icon_installing_overlay37.png | Bin 0 -> 7567 bytes res/images/icon_installing_overlay38.png | Bin 0 -> 7912 bytes res/images/icon_installing_overlay39.png | Bin 0 -> 8156 bytes res/images/icon_installing_overlay40.png | Bin 0 -> 8288 bytes res/images/icon_installing_overlay41.png | Bin 0 -> 8416 bytes res/images/icon_installing_overlay42.png | Bin 0 -> 8173 bytes res/images/icon_installing_overlay43.png | Bin 0 -> 7701 bytes res/images/icon_installing_overlay44.png | Bin 0 -> 7452 bytes res/images/icon_installing_overlay45.png | Bin 0 -> 7795 bytes res/images/icon_installing_overlay46.png | Bin 0 -> 8031 bytes res/images/icon_installing_overlay47.png | Bin 0 -> 8033 bytes res/images/icon_installing_overlay48.png | Bin 0 -> 8042 bytes res/images/indeterminate01.png | Bin 673 -> 592 bytes res/images/indeterminate02.png | Bin 687 -> 607 bytes res/images/indeterminate03.png | Bin 661 -> 559 bytes res/images/indeterminate04.png | Bin 665 -> 568 bytes res/images/indeterminate05.png | Bin 683 -> 559 bytes res/images/indeterminate06.png | Bin 676 -> 577 bytes res/images/indeterminate07.png | Bin 0 -> 590 bytes res/images/indeterminate08.png | Bin 0 -> 603 bytes res/images/indeterminate09.png | Bin 0 -> 597 bytes res/images/indeterminate10.png | Bin 0 -> 603 bytes res/images/indeterminate11.png | Bin 0 -> 603 bytes res/images/indeterminate12.png | Bin 0 -> 612 bytes res/images/indeterminate13.png | Bin 0 -> 616 bytes res/images/indeterminate14.png | Bin 0 -> 608 bytes res/images/indeterminate15.png | Bin 0 -> 627 bytes res/images/indeterminate16.png | Bin 0 -> 617 bytes screen_ui.cpp | 8 ++++---- 68 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 res/images/icon_installing_overlay08.png create mode 100644 res/images/icon_installing_overlay09.png create mode 100644 res/images/icon_installing_overlay10.png create mode 100644 res/images/icon_installing_overlay11.png create mode 100644 res/images/icon_installing_overlay12.png create mode 100644 res/images/icon_installing_overlay13.png create mode 100644 res/images/icon_installing_overlay14.png create mode 100644 res/images/icon_installing_overlay15.png create mode 100644 res/images/icon_installing_overlay16.png create mode 100644 res/images/icon_installing_overlay17.png create mode 100644 res/images/icon_installing_overlay18.png create mode 100644 res/images/icon_installing_overlay19.png create mode 100644 res/images/icon_installing_overlay20.png create mode 100644 res/images/icon_installing_overlay21.png create mode 100644 res/images/icon_installing_overlay22.png create mode 100644 res/images/icon_installing_overlay23.png create mode 100644 res/images/icon_installing_overlay24.png create mode 100644 res/images/icon_installing_overlay25.png create mode 100644 res/images/icon_installing_overlay26.png create mode 100644 res/images/icon_installing_overlay27.png create mode 100644 res/images/icon_installing_overlay28.png create mode 100644 res/images/icon_installing_overlay29.png create mode 100644 res/images/icon_installing_overlay30.png create mode 100644 res/images/icon_installing_overlay31.png create mode 100644 res/images/icon_installing_overlay32.png create mode 100644 res/images/icon_installing_overlay33.png create mode 100644 res/images/icon_installing_overlay34.png create mode 100644 res/images/icon_installing_overlay35.png create mode 100644 res/images/icon_installing_overlay36.png create mode 100644 res/images/icon_installing_overlay37.png create mode 100644 res/images/icon_installing_overlay38.png create mode 100644 res/images/icon_installing_overlay39.png create mode 100644 res/images/icon_installing_overlay40.png create mode 100644 res/images/icon_installing_overlay41.png create mode 100644 res/images/icon_installing_overlay42.png create mode 100644 res/images/icon_installing_overlay43.png create mode 100644 res/images/icon_installing_overlay44.png create mode 100644 res/images/icon_installing_overlay45.png create mode 100644 res/images/icon_installing_overlay46.png create mode 100644 res/images/icon_installing_overlay47.png create mode 100644 res/images/icon_installing_overlay48.png create mode 100644 res/images/indeterminate07.png create mode 100644 res/images/indeterminate08.png create mode 100644 res/images/indeterminate09.png create mode 100644 res/images/indeterminate10.png create mode 100644 res/images/indeterminate11.png create mode 100644 res/images/indeterminate12.png create mode 100644 res/images/indeterminate13.png create mode 100644 res/images/indeterminate14.png create mode 100644 res/images/indeterminate15.png create mode 100644 res/images/indeterminate16.png diff --git a/recovery.cpp b/recovery.cpp index e374c7d5a..70817d307 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -277,6 +277,18 @@ finish_recovery(const char *send_intent) { } } + // Save the locale to cache, so if recovery is next started up + // without a --locale argument (eg, directly from the bootloader) + // it will use the last-known locale. + if (locale != NULL) { + LOGI("Saving locale \"%s\"\n", locale); + FILE* fp = fopen_path(LOCALE_FILE, "w"); + fwrite(locale, 1, strlen(locale), fp); + fflush(fp); + fsync(fileno(fp)); + check_and_fclose(fp, LOCALE_FILE); + } + // Copy logs to cache so the system can find out what happened. copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true); copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false); @@ -286,15 +298,6 @@ finish_recovery(const char *send_intent) { chmod(LAST_LOG_FILE, 0640); chmod(LAST_INSTALL_FILE, 0644); - // Save the locale to cache, so if recovery is next started up - // without a --locale argument (eg, directly from the bootloader) - // it will use the last-known locale. - if (locale != NULL) { - FILE* fp = fopen(LOCALE_FILE, "w"); - fwrite(locale, 1, strlen(locale), fp); - fclose(fp); - } - // Reset to normal system boot so recovery won't cycle indefinitely. struct bootloader_message boot; memset(&boot, 0, sizeof(boot)); diff --git a/res/images/icon_error.png b/res/images/icon_error.png index cb3d1ab22..7000d4d8a 100644 Binary files a/res/images/icon_error.png and b/res/images/icon_error.png differ diff --git a/res/images/icon_installing.png b/res/images/icon_installing.png index 571eb8b0f..ad7927753 100644 Binary files a/res/images/icon_installing.png and b/res/images/icon_installing.png differ diff --git a/res/images/icon_installing_overlay01.png b/res/images/icon_installing_overlay01.png index e762d6cbe..c9f6125d9 100644 Binary files a/res/images/icon_installing_overlay01.png and b/res/images/icon_installing_overlay01.png differ diff --git a/res/images/icon_installing_overlay02.png b/res/images/icon_installing_overlay02.png index f7a853017..c87e5fa92 100644 Binary files a/res/images/icon_installing_overlay02.png and b/res/images/icon_installing_overlay02.png differ diff --git a/res/images/icon_installing_overlay03.png b/res/images/icon_installing_overlay03.png index 1a1d738e4..30e95803f 100644 Binary files a/res/images/icon_installing_overlay03.png and b/res/images/icon_installing_overlay03.png differ diff --git a/res/images/icon_installing_overlay04.png b/res/images/icon_installing_overlay04.png index a74903d33..6f1f9cf0d 100644 Binary files a/res/images/icon_installing_overlay04.png and b/res/images/icon_installing_overlay04.png differ diff --git a/res/images/icon_installing_overlay05.png b/res/images/icon_installing_overlay05.png index d17bdc006..8791abdbd 100644 Binary files a/res/images/icon_installing_overlay05.png and b/res/images/icon_installing_overlay05.png differ diff --git a/res/images/icon_installing_overlay06.png b/res/images/icon_installing_overlay06.png index 1200b75cb..08a0133b0 100644 Binary files a/res/images/icon_installing_overlay06.png and b/res/images/icon_installing_overlay06.png differ diff --git a/res/images/icon_installing_overlay07.png b/res/images/icon_installing_overlay07.png index 3838a85ad..15b53d9b7 100644 Binary files a/res/images/icon_installing_overlay07.png and b/res/images/icon_installing_overlay07.png differ diff --git a/res/images/icon_installing_overlay08.png b/res/images/icon_installing_overlay08.png new file mode 100644 index 000000000..bb4987894 Binary files /dev/null and b/res/images/icon_installing_overlay08.png differ diff --git a/res/images/icon_installing_overlay09.png b/res/images/icon_installing_overlay09.png new file mode 100644 index 000000000..e8715fcfa Binary files /dev/null and b/res/images/icon_installing_overlay09.png differ diff --git a/res/images/icon_installing_overlay10.png b/res/images/icon_installing_overlay10.png new file mode 100644 index 000000000..4ad81bf71 Binary files /dev/null and b/res/images/icon_installing_overlay10.png differ diff --git a/res/images/icon_installing_overlay11.png b/res/images/icon_installing_overlay11.png new file mode 100644 index 000000000..b3ae7e3ad Binary files /dev/null and b/res/images/icon_installing_overlay11.png differ diff --git a/res/images/icon_installing_overlay12.png b/res/images/icon_installing_overlay12.png new file mode 100644 index 000000000..5e7fd04a6 Binary files /dev/null and b/res/images/icon_installing_overlay12.png differ diff --git a/res/images/icon_installing_overlay13.png b/res/images/icon_installing_overlay13.png new file mode 100644 index 000000000..4e4dbe923 Binary files /dev/null and b/res/images/icon_installing_overlay13.png differ diff --git a/res/images/icon_installing_overlay14.png b/res/images/icon_installing_overlay14.png new file mode 100644 index 000000000..55e19b5e4 Binary files /dev/null and b/res/images/icon_installing_overlay14.png differ diff --git a/res/images/icon_installing_overlay15.png b/res/images/icon_installing_overlay15.png new file mode 100644 index 000000000..ac5fb991c Binary files /dev/null and b/res/images/icon_installing_overlay15.png differ diff --git a/res/images/icon_installing_overlay16.png b/res/images/icon_installing_overlay16.png new file mode 100644 index 000000000..6461d70f1 Binary files /dev/null and b/res/images/icon_installing_overlay16.png differ diff --git a/res/images/icon_installing_overlay17.png b/res/images/icon_installing_overlay17.png new file mode 100644 index 000000000..cc981d347 Binary files /dev/null and b/res/images/icon_installing_overlay17.png differ diff --git a/res/images/icon_installing_overlay18.png b/res/images/icon_installing_overlay18.png new file mode 100644 index 000000000..2b3221444 Binary files /dev/null and b/res/images/icon_installing_overlay18.png differ diff --git a/res/images/icon_installing_overlay19.png b/res/images/icon_installing_overlay19.png new file mode 100644 index 000000000..d379e51a1 Binary files /dev/null and b/res/images/icon_installing_overlay19.png differ diff --git a/res/images/icon_installing_overlay20.png b/res/images/icon_installing_overlay20.png new file mode 100644 index 000000000..362a8cabc Binary files /dev/null and b/res/images/icon_installing_overlay20.png differ diff --git a/res/images/icon_installing_overlay21.png b/res/images/icon_installing_overlay21.png new file mode 100644 index 000000000..0b6559222 Binary files /dev/null and b/res/images/icon_installing_overlay21.png differ diff --git a/res/images/icon_installing_overlay22.png b/res/images/icon_installing_overlay22.png new file mode 100644 index 000000000..51d5cbadf Binary files /dev/null and b/res/images/icon_installing_overlay22.png differ diff --git a/res/images/icon_installing_overlay23.png b/res/images/icon_installing_overlay23.png new file mode 100644 index 000000000..59148e5cc Binary files /dev/null and b/res/images/icon_installing_overlay23.png differ diff --git a/res/images/icon_installing_overlay24.png b/res/images/icon_installing_overlay24.png new file mode 100644 index 000000000..d315673b4 Binary files /dev/null and b/res/images/icon_installing_overlay24.png differ diff --git a/res/images/icon_installing_overlay25.png b/res/images/icon_installing_overlay25.png new file mode 100644 index 000000000..1eb7843e3 Binary files /dev/null and b/res/images/icon_installing_overlay25.png differ diff --git a/res/images/icon_installing_overlay26.png b/res/images/icon_installing_overlay26.png new file mode 100644 index 000000000..14a024dcf Binary files /dev/null and b/res/images/icon_installing_overlay26.png differ diff --git a/res/images/icon_installing_overlay27.png b/res/images/icon_installing_overlay27.png new file mode 100644 index 000000000..035c16340 Binary files /dev/null and b/res/images/icon_installing_overlay27.png differ diff --git a/res/images/icon_installing_overlay28.png b/res/images/icon_installing_overlay28.png new file mode 100644 index 000000000..75483864f Binary files /dev/null and b/res/images/icon_installing_overlay28.png differ diff --git a/res/images/icon_installing_overlay29.png b/res/images/icon_installing_overlay29.png new file mode 100644 index 000000000..836d3138f Binary files /dev/null and b/res/images/icon_installing_overlay29.png differ diff --git a/res/images/icon_installing_overlay30.png b/res/images/icon_installing_overlay30.png new file mode 100644 index 000000000..e470a7e1e Binary files /dev/null and b/res/images/icon_installing_overlay30.png differ diff --git a/res/images/icon_installing_overlay31.png b/res/images/icon_installing_overlay31.png new file mode 100644 index 000000000..bed0c65aa Binary files /dev/null and b/res/images/icon_installing_overlay31.png differ diff --git a/res/images/icon_installing_overlay32.png b/res/images/icon_installing_overlay32.png new file mode 100644 index 000000000..51811e0ac Binary files /dev/null and b/res/images/icon_installing_overlay32.png differ diff --git a/res/images/icon_installing_overlay33.png b/res/images/icon_installing_overlay33.png new file mode 100644 index 000000000..f1fc656d5 Binary files /dev/null and b/res/images/icon_installing_overlay33.png differ diff --git a/res/images/icon_installing_overlay34.png b/res/images/icon_installing_overlay34.png new file mode 100644 index 000000000..5791a7d16 Binary files /dev/null and b/res/images/icon_installing_overlay34.png differ diff --git a/res/images/icon_installing_overlay35.png b/res/images/icon_installing_overlay35.png new file mode 100644 index 000000000..0769ec9eb Binary files /dev/null and b/res/images/icon_installing_overlay35.png differ diff --git a/res/images/icon_installing_overlay36.png b/res/images/icon_installing_overlay36.png new file mode 100644 index 000000000..28a692bd2 Binary files /dev/null and b/res/images/icon_installing_overlay36.png differ diff --git a/res/images/icon_installing_overlay37.png b/res/images/icon_installing_overlay37.png new file mode 100644 index 000000000..12b21cfae Binary files /dev/null and b/res/images/icon_installing_overlay37.png differ diff --git a/res/images/icon_installing_overlay38.png b/res/images/icon_installing_overlay38.png new file mode 100644 index 000000000..f8ef9967d Binary files /dev/null and b/res/images/icon_installing_overlay38.png differ diff --git a/res/images/icon_installing_overlay39.png b/res/images/icon_installing_overlay39.png new file mode 100644 index 000000000..f929119ab Binary files /dev/null and b/res/images/icon_installing_overlay39.png differ diff --git a/res/images/icon_installing_overlay40.png b/res/images/icon_installing_overlay40.png new file mode 100644 index 000000000..ceed45759 Binary files /dev/null and b/res/images/icon_installing_overlay40.png differ diff --git a/res/images/icon_installing_overlay41.png b/res/images/icon_installing_overlay41.png new file mode 100644 index 000000000..34cf1aec4 Binary files /dev/null and b/res/images/icon_installing_overlay41.png differ diff --git a/res/images/icon_installing_overlay42.png b/res/images/icon_installing_overlay42.png new file mode 100644 index 000000000..d622417ac Binary files /dev/null and b/res/images/icon_installing_overlay42.png differ diff --git a/res/images/icon_installing_overlay43.png b/res/images/icon_installing_overlay43.png new file mode 100644 index 000000000..9902df1a7 Binary files /dev/null and b/res/images/icon_installing_overlay43.png differ diff --git a/res/images/icon_installing_overlay44.png b/res/images/icon_installing_overlay44.png new file mode 100644 index 000000000..b5d7911e1 Binary files /dev/null and b/res/images/icon_installing_overlay44.png differ diff --git a/res/images/icon_installing_overlay45.png b/res/images/icon_installing_overlay45.png new file mode 100644 index 000000000..dfbf408b6 Binary files /dev/null and b/res/images/icon_installing_overlay45.png differ diff --git a/res/images/icon_installing_overlay46.png b/res/images/icon_installing_overlay46.png new file mode 100644 index 000000000..495bb90df Binary files /dev/null and b/res/images/icon_installing_overlay46.png differ diff --git a/res/images/icon_installing_overlay47.png b/res/images/icon_installing_overlay47.png new file mode 100644 index 000000000..9d6937866 Binary files /dev/null and b/res/images/icon_installing_overlay47.png differ diff --git a/res/images/icon_installing_overlay48.png b/res/images/icon_installing_overlay48.png new file mode 100644 index 000000000..a5080af97 Binary files /dev/null and b/res/images/icon_installing_overlay48.png differ diff --git a/res/images/indeterminate01.png b/res/images/indeterminate01.png index 933528d6d..4db384337 100644 Binary files a/res/images/indeterminate01.png and b/res/images/indeterminate01.png differ diff --git a/res/images/indeterminate02.png b/res/images/indeterminate02.png index d760e2bdd..761b2332f 100644 Binary files a/res/images/indeterminate02.png and b/res/images/indeterminate02.png differ diff --git a/res/images/indeterminate03.png b/res/images/indeterminate03.png index 0e97399d1..e2617abcb 100644 Binary files a/res/images/indeterminate03.png and b/res/images/indeterminate03.png differ diff --git a/res/images/indeterminate04.png b/res/images/indeterminate04.png index c7d5b4e04..132940e50 100644 Binary files a/res/images/indeterminate04.png and b/res/images/indeterminate04.png differ diff --git a/res/images/indeterminate05.png b/res/images/indeterminate05.png index d6fb2a032..a17032c2d 100644 Binary files a/res/images/indeterminate05.png and b/res/images/indeterminate05.png differ diff --git a/res/images/indeterminate06.png b/res/images/indeterminate06.png index 44867619f..efaac42e6 100644 Binary files a/res/images/indeterminate06.png and b/res/images/indeterminate06.png differ diff --git a/res/images/indeterminate07.png b/res/images/indeterminate07.png new file mode 100644 index 000000000..6e84a5a0f Binary files /dev/null and b/res/images/indeterminate07.png differ diff --git a/res/images/indeterminate08.png b/res/images/indeterminate08.png new file mode 100644 index 000000000..58c112e38 Binary files /dev/null and b/res/images/indeterminate08.png differ diff --git a/res/images/indeterminate09.png b/res/images/indeterminate09.png new file mode 100644 index 000000000..b25145f12 Binary files /dev/null and b/res/images/indeterminate09.png differ diff --git a/res/images/indeterminate10.png b/res/images/indeterminate10.png new file mode 100644 index 000000000..4ff7e2527 Binary files /dev/null and b/res/images/indeterminate10.png differ diff --git a/res/images/indeterminate11.png b/res/images/indeterminate11.png new file mode 100644 index 000000000..4860c2a02 Binary files /dev/null and b/res/images/indeterminate11.png differ diff --git a/res/images/indeterminate12.png b/res/images/indeterminate12.png new file mode 100644 index 000000000..a249c225b Binary files /dev/null and b/res/images/indeterminate12.png differ diff --git a/res/images/indeterminate13.png b/res/images/indeterminate13.png new file mode 100644 index 000000000..1b70dc072 Binary files /dev/null and b/res/images/indeterminate13.png differ diff --git a/res/images/indeterminate14.png b/res/images/indeterminate14.png new file mode 100644 index 000000000..a5f779f73 Binary files /dev/null and b/res/images/indeterminate14.png differ diff --git a/res/images/indeterminate15.png b/res/images/indeterminate15.png new file mode 100644 index 000000000..018fa685c Binary files /dev/null and b/res/images/indeterminate15.png differ diff --git a/res/images/indeterminate16.png b/res/images/indeterminate16.png new file mode 100644 index 000000000..e8e05b6d3 Binary files /dev/null and b/res/images/indeterminate16.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index bb879dfac..1f2471ade 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -75,10 +75,10 @@ ScreenRecoveryUI::ScreenRecoveryUI() : // that overrides Init() to set these values appropriately and // then call the superclass Init(). animation_fps(20), - indeterminate_frames(6), - installing_frames(7), - install_overlay_offset_x(13), - install_overlay_offset_y(190) { + indeterminate_frames(16), + installing_frames(48), + install_overlay_offset_x(65), + install_overlay_offset_y(106) { pthread_mutex_init(&updateMutex, NULL); self = this; } -- cgit v1.2.3 From 91eb7219696a9bff72c3464c37798e70f7e605ee Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Thu, 23 Aug 2012 15:20:16 -0700 Subject: Add libm due to libpng dependency. Change-Id: I0bdc2df5ef358813587f613a1b50eaa850e95782 --- Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Android.mk b/Android.mk index 1c78b4287..215cfe569 100644 --- a/Android.mk +++ b/Android.mk @@ -47,6 +47,7 @@ LOCAL_STATIC_LIBRARIES := \ libpng \ libcutils \ libstdc++ \ + libm \ libc ifeq ($(TARGET_USERIMAGES_USE_EXT4), true) -- cgit v1.2.3 From 8b240ccca1ad32cbd09d3807614f3086914ceaaf Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 29 Aug 2012 15:19:29 -0700 Subject: recovery locale handling fixes - change locale filename to "last_locale" so the main system doesn't delete it - clean up some chatty logging - update images with real German (other languages TBD) Change-Id: I2ebb4ed4e054bd1808a3042d9efbb2c18f3a044d --- minui/resources.c | 8 -------- recovery.cpp | 2 +- res/images/erasing_text.png | Bin 4511 -> 1492 bytes res/images/error_text.png | Bin 3119 -> 844 bytes res/images/installing_text.png | Bin 6433 -> 6785 bytes res/images/no_command_text.png | Bin 2528 -> 1868 bytes 6 files changed, 1 insertion(+), 9 deletions(-) diff --git a/minui/resources.c b/minui/resources.c index af8720a56..b5c99517b 100644 --- a/minui/resources.c +++ b/minui/resources.c @@ -249,18 +249,13 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) { size_t height = info_ptr->height; size_t stride = 4 * width; - printf("image size is %d x %d\n", width, height); - int color_type = info_ptr->color_type; int bit_depth = info_ptr->bit_depth; int channels = info_ptr->channels; - printf("color_type %d bit_depth %d channels %d\n", - color_type, bit_depth, channels); if (!(bit_depth == 8 && (channels == 1 && color_type == PNG_COLOR_TYPE_GRAY))) { return -7; - printf("exiting -7\n"); goto exit; } @@ -276,8 +271,6 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) { printf("row %d: %s %d x %d\n", y, loc, w, h); if (y+1+h >= height || matches_locale(loc)) { - printf(" taking this one\n"); - surface = malloc(sizeof(GGLSurface)); if (surface == NULL) { result = -8; @@ -301,7 +294,6 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) { *pSurface = (gr_surface) surface; break; } else { - printf(" skipping\n"); int i; for (i = 0; i < h; ++i, ++y) { png_read_row(png_ptr, row, NULL); diff --git a/recovery.cpp b/recovery.cpp index 70817d307..6ced420d0 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -63,7 +63,7 @@ static const char *INTENT_FILE = "/cache/recovery/intent"; static const char *LOG_FILE = "/cache/recovery/log"; static const char *LAST_LOG_FILE = "/cache/recovery/last_log"; static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install"; -static const char *LOCALE_FILE = "/cache/recovery/locale"; +static const char *LOCALE_FILE = "/cache/recovery/last_locale"; static const char *CACHE_ROOT = "/cache"; static const char *SDCARD_ROOT = "/sdcard"; static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log"; diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index f92119772..2cd2e3825 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index 581347094..91be5fe54 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index c48a45295..0557350ef 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index 1d6a5b7cf..fbc20743f 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ -- cgit v1.2.3 From f4c6ec84c24611856374353bdef87baca5694cc0 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 30 Aug 2012 12:47:43 -0700 Subject: fix format of installing_text Was submitted in the wrong PNG format (color type 4 instead of 0). Change-Id: I8780c81eb92bdfc407b43948a92b37d93026325a --- res/images/installing_text.png | Bin 6785 -> 2747 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 0557350ef..42704b996 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ -- cgit v1.2.3 From 276657839e3ae2e3f263a6e46ce6c0c0dfa3dbaf Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 30 Aug 2012 12:47:43 -0700 Subject: fix format of installing_text Was submitted in the wrong PNG format (color type 4 instead of 0). Change-Id: I8780c81eb92bdfc407b43948a92b37d93026325a --- res/images/installing_text.png | Bin 6785 -> 2747 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 0557350ef..42704b996 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ -- cgit v1.2.3 From 52eeea4fa59c15ecb09c32b8e05653f4e55f5188 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 4 Sep 2012 14:28:25 -0700 Subject: minor recovery fixes - protect against missing/malformed bitmaps: fail to display them but don't crash. - don't draw animation overlays until the overlay offset is computed. - logging cleanup Change-Id: Ieb1c155cfbb11e643000bdb5d1a57900c8757739 --- minui/graphics.c | 5 ++++- minui/resources.c | 7 ++----- screen_ui.cpp | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/minui/graphics.c b/minui/graphics.c index 88572a878..287878e92 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -245,6 +245,9 @@ int gr_text(int x, int y, const char *s) } void gr_texticon(int x, int y, gr_surface icon) { + if (gr_context == NULL || icon == NULL) { + return; + } GGLContext* gl = gr_context; gl->bindTexture(gl, (GGLSurface*) icon); @@ -268,7 +271,7 @@ void gr_fill(int x, int y, int w, int h) } void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { - if (gr_context == NULL) { + if (gr_context == NULL || source == NULL) { return; } GGLContext *gl = gr_context; diff --git a/minui/resources.c b/minui/resources.c index ac7bdac4c..065f4317e 100644 --- a/minui/resources.c +++ b/minui/resources.c @@ -178,8 +178,6 @@ exit: static int matches_locale(const char* loc) { if (locale == NULL) return 0; - printf("matching loc=[%s] vs locale=[%s]\n", loc, locale); - if (strcmp(loc, locale) == 0) return 1; // if loc does *not* have an underscore, and it matches the start @@ -190,7 +188,6 @@ static int matches_locale(const char* loc) { int i; for (i = 0; loc[i] != 0 && loc[i] != '_'; ++i); if (loc[i] == '_') return 0; - printf(" partial match possible; i = %d\n", i); return (strncmp(locale, loc, i) == 0 && locale[i] == '_'); } @@ -268,9 +265,9 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) { int len = row[4]; char* loc = row+5; - printf("row %d: %s %d x %d\n", y, loc, w, h); - if (y+1+h >= height || matches_locale(loc)) { + printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); + surface = malloc(sizeof(GGLSurface)); if (surface == NULL) { result = -8; diff --git a/screen_ui.cpp b/screen_ui.cpp index 1f2471ade..0b3437547 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -78,7 +78,9 @@ ScreenRecoveryUI::ScreenRecoveryUI() : indeterminate_frames(16), installing_frames(48), install_overlay_offset_x(65), - install_overlay_offset_y(106) { + install_overlay_offset_y(106), + overlay_offset_x(-1), + overlay_offset_y(-1) { pthread_mutex_init(&updateMutex, NULL); self = this; } @@ -89,7 +91,7 @@ ScreenRecoveryUI::ScreenRecoveryUI() : // animation. Does nothing if no overlay animation is defined. // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_install_overlay_locked(int frame) { - if (installationOverlay == NULL) return; + if (installationOverlay == NULL || overlay_offset_x < 0) return; gr_surface surface = installationOverlay[frame]; int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); @@ -361,8 +363,6 @@ void ScreenRecoveryUI::Init() void ScreenRecoveryUI::SetBackground(Icon icon) { pthread_mutex_lock(&updateMutex); - currentIcon = icon; - update_screen_locked(); // Adjust the offset to account for the positioning of the // base image on the screen. @@ -374,6 +374,9 @@ void ScreenRecoveryUI::SetBackground(Icon icon) (gr_fb_height() - (gr_get_height(bg) + gr_get_height(text) + 40)) / 2; } + currentIcon = icon; + update_screen_locked(); + pthread_mutex_unlock(&updateMutex); } -- cgit v1.2.3 From 5fa8c23911759a9e81af0e7fb5eb431277b8e9a6 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 18 Sep 2012 12:37:02 -0700 Subject: localization for recovery messages Add images of text for all locales we support. Make the progress bar fill the correct way for RTL languages. (Flip the direction the spinner turns, too, just for good measure.) Bug: 7064142 Change-Id: I5dddb26e02ee5275c57c4dc4a03c6d68432ac7ba --- recovery.cpp | 3 ++- res/images/erasing_text.png | Bin 1492 -> 31490 bytes res/images/error_text.png | Bin 844 -> 17498 bytes res/images/installing_text.png | Bin 2747 -> 66587 bytes res/images/no_command_text.png | Bin 1868 -> 40633 bytes screen_ui.cpp | 52 ++++++++++++++++++++++++++++++++++++----- screen_ui.h | 2 ++ ui.h | 3 +++ 8 files changed, 53 insertions(+), 7 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 6ced420d0..3b5813876 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -781,7 +781,7 @@ load_locale_from_cache() { if (fp != NULL) { fgets(buffer, sizeof(buffer), fp); int j = 0; - int i; + unsigned int i; for (i = 0; i < sizeof(buffer) && buffer[i]; ++i) { if (!isspace(buffer[i])) { buffer[j++] = buffer[i]; @@ -849,6 +849,7 @@ main(int argc, char **argv) { ui = device->GetUI(); ui->Init(); + ui->SetLocale(locale); ui->SetBackground(RecoveryUI::NONE); if (show_text) ui->ShowText(true); diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index 2cd2e3825..8b9f265fb 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index 91be5fe54..b64b3d7ac 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 42704b996..9c16c7708 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index fbc20743f..2241259e2 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 0b3437547..64a5dcdd2 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -52,6 +52,7 @@ static double now() { ScreenRecoveryUI::ScreenRecoveryUI() : currentIcon(NONE), installingFrame(0), + rtl_locale(false), progressBarType(EMPTY), progressScopeStart(0), progressScopeSize(0), @@ -158,18 +159,35 @@ void ScreenRecoveryUI::draw_progress_locked() float p = progressScopeStart + progress * progressScopeSize; int pos = (int) (p * width); - if (pos > 0) { - gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); - } - if (pos < width-1) { - gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + if (rtl_locale) { + // Fill the progress bar from right to left. + if (pos > 0) { + gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy); + } + if (pos < width-1) { + gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy); + } + } else { + // Fill the progress bar from left to right. + if (pos > 0) { + gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); + } + if (pos < width-1) { + gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + } } } if (progressBarType == INDETERMINATE) { static int frame = 0; gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy); - frame = (frame + 1) % indeterminate_frames; + // in RTL locales, we run the animation backwards, which + // makes the spinner spin the other way. + if (rtl_locale) { + frame = (frame + indeterminate_frames - 1) % indeterminate_frames; + } else { + frame = (frame + 1) % indeterminate_frames; + } } } } @@ -360,6 +378,28 @@ void ScreenRecoveryUI::Init() RecoveryUI::Init(); } +void ScreenRecoveryUI::SetLocale(const char* locale) { + if (locale) { + char* lang = strdup(locale); + for (char* p = lang; *p; ++p) { + if (*p == '_') { + *p = '\0'; + break; + } + } + + // A bit cheesy: keep an explicit list of supported languages + // that are RTL. + if (strcmp(lang, "ar") == 0 || // Arabic + strcmp(lang, "fa") == 0 || // Persian (Farsi) + strcmp(lang, "he") == 0 || // Hebrew (new language code) + strcmp(lang, "iw") == 0) { // Hebrew (old language code) + rtl_locale = true; + } + free(lang); + } +} + void ScreenRecoveryUI::SetBackground(Icon icon) { pthread_mutex_lock(&updateMutex); diff --git a/screen_ui.h b/screen_ui.h index 16ee741b7..80051724b 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -29,6 +29,7 @@ class ScreenRecoveryUI : public RecoveryUI { ScreenRecoveryUI(); void Init(); + void SetLocale(const char* locale); // overall recovery state ("background image") void SetBackground(Icon icon); @@ -55,6 +56,7 @@ class ScreenRecoveryUI : public RecoveryUI { private: Icon currentIcon; int installingFrame; + bool rtl_locale; pthread_mutex_t updateMutex; gr_surface backgroundIcon[5]; diff --git a/ui.h b/ui.h index ccbb466ac..acb57663e 100644 --- a/ui.h +++ b/ui.h @@ -30,6 +30,9 @@ class RecoveryUI { // Initialize the object; called before anything else. virtual void Init(); + // After calling Init(), you can tell the UI what locale it is operating in. + virtual void SetLocale(const char* locale) { } + // Set the overall recovery state ("background image"). enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR }; virtual void SetBackground(Icon icon) = 0; -- cgit v1.2.3 From b66cb69e3933d5f56f06d88cd31817f49d87df5f Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 18 Sep 2012 14:52:18 -0700 Subject: tweak recovery text images Center and fix the extents for those locales that have multiple lines of text. Add Urdu as an RTL language. Bug: 7064142 Change-Id: I4c1aa1198be29cab01129dabf2c4a026b93719a6 --- res/images/erasing_text.png | Bin 31490 -> 31491 bytes res/images/error_text.png | Bin 17498 -> 17504 bytes res/images/installing_text.png | Bin 66587 -> 66592 bytes res/images/no_command_text.png | Bin 40633 -> 40632 bytes screen_ui.cpp | 3 ++- 5 files changed, 2 insertions(+), 1 deletion(-) diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index 8b9f265fb..441768a0c 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index b64b3d7ac..4ac6391ff 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 9c16c7708..e1ac819e6 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index 2241259e2..a688f0935 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 64a5dcdd2..ab7546d40 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -393,7 +393,8 @@ void ScreenRecoveryUI::SetLocale(const char* locale) { if (strcmp(lang, "ar") == 0 || // Arabic strcmp(lang, "fa") == 0 || // Persian (Farsi) strcmp(lang, "he") == 0 || // Hebrew (new language code) - strcmp(lang, "iw") == 0) { // Hebrew (old language code) + strcmp(lang, "iw") == 0 || // Hebrew (old language code) + strcmp(lang, "ur") == 0) { // Urdu rtl_locale = true; } free(lang); -- cgit v1.2.3 From ea6b2a7a85e1302b23ed0d9916e4b38015bc9a23 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 18 Sep 2012 12:37:02 -0700 Subject: localization for recovery messages Add images of text for all locales we support. Make the progress bar fill the correct way for RTL languages. (Flip the direction the spinner turns, too, just for good measure.) Bug: 7064142 Change-Id: I5dddb26e02ee5275c57c4dc4a03c6d68432ac7ba --- recovery.cpp | 3 ++- res/images/erasing_text.png | Bin 1492 -> 31490 bytes res/images/error_text.png | Bin 844 -> 17498 bytes res/images/installing_text.png | Bin 2747 -> 66587 bytes res/images/no_command_text.png | Bin 1868 -> 40633 bytes screen_ui.cpp | 52 ++++++++++++++++++++++++++++++++++++----- screen_ui.h | 2 ++ ui.h | 3 +++ 8 files changed, 53 insertions(+), 7 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 6ced420d0..3b5813876 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -781,7 +781,7 @@ load_locale_from_cache() { if (fp != NULL) { fgets(buffer, sizeof(buffer), fp); int j = 0; - int i; + unsigned int i; for (i = 0; i < sizeof(buffer) && buffer[i]; ++i) { if (!isspace(buffer[i])) { buffer[j++] = buffer[i]; @@ -849,6 +849,7 @@ main(int argc, char **argv) { ui = device->GetUI(); ui->Init(); + ui->SetLocale(locale); ui->SetBackground(RecoveryUI::NONE); if (show_text) ui->ShowText(true); diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index 2cd2e3825..8b9f265fb 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index 91be5fe54..b64b3d7ac 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 42704b996..9c16c7708 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index fbc20743f..2241259e2 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 0b3437547..64a5dcdd2 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -52,6 +52,7 @@ static double now() { ScreenRecoveryUI::ScreenRecoveryUI() : currentIcon(NONE), installingFrame(0), + rtl_locale(false), progressBarType(EMPTY), progressScopeStart(0), progressScopeSize(0), @@ -158,18 +159,35 @@ void ScreenRecoveryUI::draw_progress_locked() float p = progressScopeStart + progress * progressScopeSize; int pos = (int) (p * width); - if (pos > 0) { - gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); - } - if (pos < width-1) { - gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + if (rtl_locale) { + // Fill the progress bar from right to left. + if (pos > 0) { + gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy); + } + if (pos < width-1) { + gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy); + } + } else { + // Fill the progress bar from left to right. + if (pos > 0) { + gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); + } + if (pos < width-1) { + gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + } } } if (progressBarType == INDETERMINATE) { static int frame = 0; gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy); - frame = (frame + 1) % indeterminate_frames; + // in RTL locales, we run the animation backwards, which + // makes the spinner spin the other way. + if (rtl_locale) { + frame = (frame + indeterminate_frames - 1) % indeterminate_frames; + } else { + frame = (frame + 1) % indeterminate_frames; + } } } } @@ -360,6 +378,28 @@ void ScreenRecoveryUI::Init() RecoveryUI::Init(); } +void ScreenRecoveryUI::SetLocale(const char* locale) { + if (locale) { + char* lang = strdup(locale); + for (char* p = lang; *p; ++p) { + if (*p == '_') { + *p = '\0'; + break; + } + } + + // A bit cheesy: keep an explicit list of supported languages + // that are RTL. + if (strcmp(lang, "ar") == 0 || // Arabic + strcmp(lang, "fa") == 0 || // Persian (Farsi) + strcmp(lang, "he") == 0 || // Hebrew (new language code) + strcmp(lang, "iw") == 0) { // Hebrew (old language code) + rtl_locale = true; + } + free(lang); + } +} + void ScreenRecoveryUI::SetBackground(Icon icon) { pthread_mutex_lock(&updateMutex); diff --git a/screen_ui.h b/screen_ui.h index 16ee741b7..80051724b 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -29,6 +29,7 @@ class ScreenRecoveryUI : public RecoveryUI { ScreenRecoveryUI(); void Init(); + void SetLocale(const char* locale); // overall recovery state ("background image") void SetBackground(Icon icon); @@ -55,6 +56,7 @@ class ScreenRecoveryUI : public RecoveryUI { private: Icon currentIcon; int installingFrame; + bool rtl_locale; pthread_mutex_t updateMutex; gr_surface backgroundIcon[5]; diff --git a/ui.h b/ui.h index ccbb466ac..acb57663e 100644 --- a/ui.h +++ b/ui.h @@ -30,6 +30,9 @@ class RecoveryUI { // Initialize the object; called before anything else. virtual void Init(); + // After calling Init(), you can tell the UI what locale it is operating in. + virtual void SetLocale(const char* locale) { } + // Set the overall recovery state ("background image"). enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR }; virtual void SetBackground(Icon icon) = 0; -- cgit v1.2.3 From cda00bba51c6adbf95e451fd8c6cad7a5390503a Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 18 Sep 2012 14:52:18 -0700 Subject: tweak recovery text images Center and fix the extents for those locales that have multiple lines of text. Add Urdu as an RTL language. Bug: 7064142 Change-Id: I4c1aa1198be29cab01129dabf2c4a026b93719a6 --- res/images/erasing_text.png | Bin 31490 -> 31491 bytes res/images/error_text.png | Bin 17498 -> 17504 bytes res/images/installing_text.png | Bin 66587 -> 66592 bytes res/images/no_command_text.png | Bin 40633 -> 40632 bytes screen_ui.cpp | 3 ++- 5 files changed, 2 insertions(+), 1 deletion(-) diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index 8b9f265fb..441768a0c 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index b64b3d7ac..4ac6391ff 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 9c16c7708..e1ac819e6 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index 2241259e2..a688f0935 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 64a5dcdd2..ab7546d40 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -393,7 +393,8 @@ void ScreenRecoveryUI::SetLocale(const char* locale) { if (strcmp(lang, "ar") == 0 || // Arabic strcmp(lang, "fa") == 0 || // Persian (Farsi) strcmp(lang, "he") == 0 || // Hebrew (new language code) - strcmp(lang, "iw") == 0) { // Hebrew (old language code) + strcmp(lang, "iw") == 0 || // Hebrew (old language code) + strcmp(lang, "ur") == 0) { // Urdu rtl_locale = true; } free(lang); -- cgit v1.2.3 From 6c8553dda8b7fb45adc9f48a294c130b7e283f40 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 24 Sep 2012 10:40:47 -0700 Subject: display error state on OTA failure We need prompt_with_wait() to show either the ERROR or NO_COMMAND state as appropriate. Bug: 7221068 Change-Id: I191526cf12630d08b7a8250a2a81e724a4a5d972 --- recovery.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 3b5813876..5c1e3cd21 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -668,12 +668,22 @@ wipe_data(int confirm, Device* device) { } static void -prompt_and_wait(Device* device) { +prompt_and_wait(Device* device, int status) { const char* const* headers = prepend_title(device->GetMenuHeaders()); for (;;) { finish_recovery(NULL); - ui->SetBackground(RecoveryUI::NO_COMMAND); + switch (status) { + case INSTALL_SUCCESS: + case INSTALL_NONE: + ui->SetBackground(RecoveryUI::NO_COMMAND); + break; + + case INSTALL_ERROR: + case INSTALL_CORRUPT: + ui->SetBackground(RecoveryUI::ERROR); + break; + } ui->SetProgressType(RecoveryUI::EMPTY); int chosen_item = get_menu_selection(headers, device->GetMenuItems(), 0, 0, device); @@ -683,7 +693,6 @@ prompt_and_wait(Device* device) { // statement below. chosen_item = device->InvokeMenuItem(chosen_item); - int status; int wipe_cache; switch (chosen_item) { case Device::REBOOT: @@ -920,7 +929,7 @@ main(int argc, char **argv) { ui->SetBackground(RecoveryUI::ERROR); } if (status != INSTALL_SUCCESS || ui->IsTextVisible()) { - prompt_and_wait(device); + prompt_and_wait(device, status); } // Otherwise, get ready to boot the main system... -- cgit v1.2.3 From 8347cb2d813b9a8b7c9165aadaea0b699eb5082f Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 8 Oct 2012 08:38:16 -0700 Subject: revert to tacky 3D recovery animation Bug: 7204420 Change-Id: I16d3346ce54b1aa5a0e6a02839ae9fbd4718fffa --- res/images/icon_error.png | Bin 18244 -> 19306 bytes res/images/icon_installing.png | Bin 21072 -> 25261 bytes res/images/icon_installing_overlay01.png | Bin 8017 -> 10095 bytes res/images/icon_installing_overlay02.png | Bin 7803 -> 9990 bytes res/images/icon_installing_overlay03.png | Bin 7489 -> 9782 bytes res/images/icon_installing_overlay04.png | Bin 7150 -> 9817 bytes res/images/icon_installing_overlay05.png | Bin 7271 -> 9863 bytes res/images/icon_installing_overlay06.png | Bin 7400 -> 9944 bytes res/images/icon_installing_overlay07.png | Bin 7568 -> 10062 bytes res/images/icon_installing_overlay08.png | Bin 7901 -> 0 bytes res/images/icon_installing_overlay09.png | Bin 8455 -> 0 bytes res/images/icon_installing_overlay10.png | Bin 8740 -> 0 bytes res/images/icon_installing_overlay11.png | Bin 8764 -> 0 bytes res/images/icon_installing_overlay12.png | Bin 8547 -> 0 bytes res/images/icon_installing_overlay13.png | Bin 8405 -> 0 bytes res/images/icon_installing_overlay14.png | Bin 8114 -> 0 bytes res/images/icon_installing_overlay15.png | Bin 7740 -> 0 bytes res/images/icon_installing_overlay16.png | Bin 7685 -> 0 bytes res/images/icon_installing_overlay17.png | Bin 7719 -> 0 bytes res/images/icon_installing_overlay18.png | Bin 7565 -> 0 bytes res/images/icon_installing_overlay19.png | Bin 7259 -> 0 bytes res/images/icon_installing_overlay20.png | Bin 6993 -> 0 bytes res/images/icon_installing_overlay21.png | Bin 7361 -> 0 bytes res/images/icon_installing_overlay22.png | Bin 7457 -> 0 bytes res/images/icon_installing_overlay23.png | Bin 7512 -> 0 bytes res/images/icon_installing_overlay24.png | Bin 7572 -> 0 bytes res/images/icon_installing_overlay25.png | Bin 7768 -> 0 bytes res/images/icon_installing_overlay26.png | Bin 8299 -> 0 bytes res/images/icon_installing_overlay27.png | Bin 8642 -> 0 bytes res/images/icon_installing_overlay28.png | Bin 8828 -> 0 bytes res/images/icon_installing_overlay29.png | Bin 8898 -> 0 bytes res/images/icon_installing_overlay30.png | Bin 8700 -> 0 bytes res/images/icon_installing_overlay31.png | Bin 8343 -> 0 bytes res/images/icon_installing_overlay32.png | Bin 7846 -> 0 bytes res/images/icon_installing_overlay33.png | Bin 7673 -> 0 bytes res/images/icon_installing_overlay34.png | Bin 7378 -> 0 bytes res/images/icon_installing_overlay35.png | Bin 7203 -> 0 bytes res/images/icon_installing_overlay36.png | Bin 7208 -> 0 bytes res/images/icon_installing_overlay37.png | Bin 7567 -> 0 bytes res/images/icon_installing_overlay38.png | Bin 7912 -> 0 bytes res/images/icon_installing_overlay39.png | Bin 8156 -> 0 bytes res/images/icon_installing_overlay40.png | Bin 8288 -> 0 bytes res/images/icon_installing_overlay41.png | Bin 8416 -> 0 bytes res/images/icon_installing_overlay42.png | Bin 8173 -> 0 bytes res/images/icon_installing_overlay43.png | Bin 7701 -> 0 bytes res/images/icon_installing_overlay44.png | Bin 7452 -> 0 bytes res/images/icon_installing_overlay45.png | Bin 7795 -> 0 bytes res/images/icon_installing_overlay46.png | Bin 8031 -> 0 bytes res/images/icon_installing_overlay47.png | Bin 8033 -> 0 bytes res/images/icon_installing_overlay48.png | Bin 8042 -> 0 bytes res/images/indeterminate01.png | Bin 592 -> 673 bytes res/images/indeterminate02.png | Bin 607 -> 687 bytes res/images/indeterminate03.png | Bin 559 -> 661 bytes res/images/indeterminate04.png | Bin 568 -> 665 bytes res/images/indeterminate05.png | Bin 559 -> 683 bytes res/images/indeterminate06.png | Bin 577 -> 676 bytes res/images/indeterminate07.png | Bin 590 -> 0 bytes res/images/indeterminate08.png | Bin 603 -> 0 bytes res/images/indeterminate09.png | Bin 597 -> 0 bytes res/images/indeterminate10.png | Bin 603 -> 0 bytes res/images/indeterminate11.png | Bin 603 -> 0 bytes res/images/indeterminate12.png | Bin 612 -> 0 bytes res/images/indeterminate13.png | Bin 616 -> 0 bytes res/images/indeterminate14.png | Bin 608 -> 0 bytes res/images/indeterminate15.png | Bin 627 -> 0 bytes res/images/indeterminate16.png | Bin 617 -> 0 bytes screen_ui.cpp | 8 ++++---- 67 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 res/images/icon_installing_overlay08.png delete mode 100644 res/images/icon_installing_overlay09.png delete mode 100644 res/images/icon_installing_overlay10.png delete mode 100644 res/images/icon_installing_overlay11.png delete mode 100644 res/images/icon_installing_overlay12.png delete mode 100644 res/images/icon_installing_overlay13.png delete mode 100644 res/images/icon_installing_overlay14.png delete mode 100644 res/images/icon_installing_overlay15.png delete mode 100644 res/images/icon_installing_overlay16.png delete mode 100644 res/images/icon_installing_overlay17.png delete mode 100644 res/images/icon_installing_overlay18.png delete mode 100644 res/images/icon_installing_overlay19.png delete mode 100644 res/images/icon_installing_overlay20.png delete mode 100644 res/images/icon_installing_overlay21.png delete mode 100644 res/images/icon_installing_overlay22.png delete mode 100644 res/images/icon_installing_overlay23.png delete mode 100644 res/images/icon_installing_overlay24.png delete mode 100644 res/images/icon_installing_overlay25.png delete mode 100644 res/images/icon_installing_overlay26.png delete mode 100644 res/images/icon_installing_overlay27.png delete mode 100644 res/images/icon_installing_overlay28.png delete mode 100644 res/images/icon_installing_overlay29.png delete mode 100644 res/images/icon_installing_overlay30.png delete mode 100644 res/images/icon_installing_overlay31.png delete mode 100644 res/images/icon_installing_overlay32.png delete mode 100644 res/images/icon_installing_overlay33.png delete mode 100644 res/images/icon_installing_overlay34.png delete mode 100644 res/images/icon_installing_overlay35.png delete mode 100644 res/images/icon_installing_overlay36.png delete mode 100644 res/images/icon_installing_overlay37.png delete mode 100644 res/images/icon_installing_overlay38.png delete mode 100644 res/images/icon_installing_overlay39.png delete mode 100644 res/images/icon_installing_overlay40.png delete mode 100644 res/images/icon_installing_overlay41.png delete mode 100644 res/images/icon_installing_overlay42.png delete mode 100644 res/images/icon_installing_overlay43.png delete mode 100644 res/images/icon_installing_overlay44.png delete mode 100644 res/images/icon_installing_overlay45.png delete mode 100644 res/images/icon_installing_overlay46.png delete mode 100644 res/images/icon_installing_overlay47.png delete mode 100644 res/images/icon_installing_overlay48.png delete mode 100644 res/images/indeterminate07.png delete mode 100644 res/images/indeterminate08.png delete mode 100644 res/images/indeterminate09.png delete mode 100644 res/images/indeterminate10.png delete mode 100644 res/images/indeterminate11.png delete mode 100644 res/images/indeterminate12.png delete mode 100644 res/images/indeterminate13.png delete mode 100644 res/images/indeterminate14.png delete mode 100644 res/images/indeterminate15.png delete mode 100644 res/images/indeterminate16.png diff --git a/res/images/icon_error.png b/res/images/icon_error.png index 7000d4d8a..cb3d1ab22 100644 Binary files a/res/images/icon_error.png and b/res/images/icon_error.png differ diff --git a/res/images/icon_installing.png b/res/images/icon_installing.png index ad7927753..571eb8b0f 100644 Binary files a/res/images/icon_installing.png and b/res/images/icon_installing.png differ diff --git a/res/images/icon_installing_overlay01.png b/res/images/icon_installing_overlay01.png index c9f6125d9..e762d6cbe 100644 Binary files a/res/images/icon_installing_overlay01.png and b/res/images/icon_installing_overlay01.png differ diff --git a/res/images/icon_installing_overlay02.png b/res/images/icon_installing_overlay02.png index c87e5fa92..f7a853017 100644 Binary files a/res/images/icon_installing_overlay02.png and b/res/images/icon_installing_overlay02.png differ diff --git a/res/images/icon_installing_overlay03.png b/res/images/icon_installing_overlay03.png index 30e95803f..1a1d738e4 100644 Binary files a/res/images/icon_installing_overlay03.png and b/res/images/icon_installing_overlay03.png differ diff --git a/res/images/icon_installing_overlay04.png b/res/images/icon_installing_overlay04.png index 6f1f9cf0d..a74903d33 100644 Binary files a/res/images/icon_installing_overlay04.png and b/res/images/icon_installing_overlay04.png differ diff --git a/res/images/icon_installing_overlay05.png b/res/images/icon_installing_overlay05.png index 8791abdbd..d17bdc006 100644 Binary files a/res/images/icon_installing_overlay05.png and b/res/images/icon_installing_overlay05.png differ diff --git a/res/images/icon_installing_overlay06.png b/res/images/icon_installing_overlay06.png index 08a0133b0..1200b75cb 100644 Binary files a/res/images/icon_installing_overlay06.png and b/res/images/icon_installing_overlay06.png differ diff --git a/res/images/icon_installing_overlay07.png b/res/images/icon_installing_overlay07.png index 15b53d9b7..3838a85ad 100644 Binary files a/res/images/icon_installing_overlay07.png and b/res/images/icon_installing_overlay07.png differ diff --git a/res/images/icon_installing_overlay08.png b/res/images/icon_installing_overlay08.png deleted file mode 100644 index bb4987894..000000000 Binary files a/res/images/icon_installing_overlay08.png and /dev/null differ diff --git a/res/images/icon_installing_overlay09.png b/res/images/icon_installing_overlay09.png deleted file mode 100644 index e8715fcfa..000000000 Binary files a/res/images/icon_installing_overlay09.png and /dev/null differ diff --git a/res/images/icon_installing_overlay10.png b/res/images/icon_installing_overlay10.png deleted file mode 100644 index 4ad81bf71..000000000 Binary files a/res/images/icon_installing_overlay10.png and /dev/null differ diff --git a/res/images/icon_installing_overlay11.png b/res/images/icon_installing_overlay11.png deleted file mode 100644 index b3ae7e3ad..000000000 Binary files a/res/images/icon_installing_overlay11.png and /dev/null differ diff --git a/res/images/icon_installing_overlay12.png b/res/images/icon_installing_overlay12.png deleted file mode 100644 index 5e7fd04a6..000000000 Binary files a/res/images/icon_installing_overlay12.png and /dev/null differ diff --git a/res/images/icon_installing_overlay13.png b/res/images/icon_installing_overlay13.png deleted file mode 100644 index 4e4dbe923..000000000 Binary files a/res/images/icon_installing_overlay13.png and /dev/null differ diff --git a/res/images/icon_installing_overlay14.png b/res/images/icon_installing_overlay14.png deleted file mode 100644 index 55e19b5e4..000000000 Binary files a/res/images/icon_installing_overlay14.png and /dev/null differ diff --git a/res/images/icon_installing_overlay15.png b/res/images/icon_installing_overlay15.png deleted file mode 100644 index ac5fb991c..000000000 Binary files a/res/images/icon_installing_overlay15.png and /dev/null differ diff --git a/res/images/icon_installing_overlay16.png b/res/images/icon_installing_overlay16.png deleted file mode 100644 index 6461d70f1..000000000 Binary files a/res/images/icon_installing_overlay16.png and /dev/null differ diff --git a/res/images/icon_installing_overlay17.png b/res/images/icon_installing_overlay17.png deleted file mode 100644 index cc981d347..000000000 Binary files a/res/images/icon_installing_overlay17.png and /dev/null differ diff --git a/res/images/icon_installing_overlay18.png b/res/images/icon_installing_overlay18.png deleted file mode 100644 index 2b3221444..000000000 Binary files a/res/images/icon_installing_overlay18.png and /dev/null differ diff --git a/res/images/icon_installing_overlay19.png b/res/images/icon_installing_overlay19.png deleted file mode 100644 index d379e51a1..000000000 Binary files a/res/images/icon_installing_overlay19.png and /dev/null differ diff --git a/res/images/icon_installing_overlay20.png b/res/images/icon_installing_overlay20.png deleted file mode 100644 index 362a8cabc..000000000 Binary files a/res/images/icon_installing_overlay20.png and /dev/null differ diff --git a/res/images/icon_installing_overlay21.png b/res/images/icon_installing_overlay21.png deleted file mode 100644 index 0b6559222..000000000 Binary files a/res/images/icon_installing_overlay21.png and /dev/null differ diff --git a/res/images/icon_installing_overlay22.png b/res/images/icon_installing_overlay22.png deleted file mode 100644 index 51d5cbadf..000000000 Binary files a/res/images/icon_installing_overlay22.png and /dev/null differ diff --git a/res/images/icon_installing_overlay23.png b/res/images/icon_installing_overlay23.png deleted file mode 100644 index 59148e5cc..000000000 Binary files a/res/images/icon_installing_overlay23.png and /dev/null differ diff --git a/res/images/icon_installing_overlay24.png b/res/images/icon_installing_overlay24.png deleted file mode 100644 index d315673b4..000000000 Binary files a/res/images/icon_installing_overlay24.png and /dev/null differ diff --git a/res/images/icon_installing_overlay25.png b/res/images/icon_installing_overlay25.png deleted file mode 100644 index 1eb7843e3..000000000 Binary files a/res/images/icon_installing_overlay25.png and /dev/null differ diff --git a/res/images/icon_installing_overlay26.png b/res/images/icon_installing_overlay26.png deleted file mode 100644 index 14a024dcf..000000000 Binary files a/res/images/icon_installing_overlay26.png and /dev/null differ diff --git a/res/images/icon_installing_overlay27.png b/res/images/icon_installing_overlay27.png deleted file mode 100644 index 035c16340..000000000 Binary files a/res/images/icon_installing_overlay27.png and /dev/null differ diff --git a/res/images/icon_installing_overlay28.png b/res/images/icon_installing_overlay28.png deleted file mode 100644 index 75483864f..000000000 Binary files a/res/images/icon_installing_overlay28.png and /dev/null differ diff --git a/res/images/icon_installing_overlay29.png b/res/images/icon_installing_overlay29.png deleted file mode 100644 index 836d3138f..000000000 Binary files a/res/images/icon_installing_overlay29.png and /dev/null differ diff --git a/res/images/icon_installing_overlay30.png b/res/images/icon_installing_overlay30.png deleted file mode 100644 index e470a7e1e..000000000 Binary files a/res/images/icon_installing_overlay30.png and /dev/null differ diff --git a/res/images/icon_installing_overlay31.png b/res/images/icon_installing_overlay31.png deleted file mode 100644 index bed0c65aa..000000000 Binary files a/res/images/icon_installing_overlay31.png and /dev/null differ diff --git a/res/images/icon_installing_overlay32.png b/res/images/icon_installing_overlay32.png deleted file mode 100644 index 51811e0ac..000000000 Binary files a/res/images/icon_installing_overlay32.png and /dev/null differ diff --git a/res/images/icon_installing_overlay33.png b/res/images/icon_installing_overlay33.png deleted file mode 100644 index f1fc656d5..000000000 Binary files a/res/images/icon_installing_overlay33.png and /dev/null differ diff --git a/res/images/icon_installing_overlay34.png b/res/images/icon_installing_overlay34.png deleted file mode 100644 index 5791a7d16..000000000 Binary files a/res/images/icon_installing_overlay34.png and /dev/null differ diff --git a/res/images/icon_installing_overlay35.png b/res/images/icon_installing_overlay35.png deleted file mode 100644 index 0769ec9eb..000000000 Binary files a/res/images/icon_installing_overlay35.png and /dev/null differ diff --git a/res/images/icon_installing_overlay36.png b/res/images/icon_installing_overlay36.png deleted file mode 100644 index 28a692bd2..000000000 Binary files a/res/images/icon_installing_overlay36.png and /dev/null differ diff --git a/res/images/icon_installing_overlay37.png b/res/images/icon_installing_overlay37.png deleted file mode 100644 index 12b21cfae..000000000 Binary files a/res/images/icon_installing_overlay37.png and /dev/null differ diff --git a/res/images/icon_installing_overlay38.png b/res/images/icon_installing_overlay38.png deleted file mode 100644 index f8ef9967d..000000000 Binary files a/res/images/icon_installing_overlay38.png and /dev/null differ diff --git a/res/images/icon_installing_overlay39.png b/res/images/icon_installing_overlay39.png deleted file mode 100644 index f929119ab..000000000 Binary files a/res/images/icon_installing_overlay39.png and /dev/null differ diff --git a/res/images/icon_installing_overlay40.png b/res/images/icon_installing_overlay40.png deleted file mode 100644 index ceed45759..000000000 Binary files a/res/images/icon_installing_overlay40.png and /dev/null differ diff --git a/res/images/icon_installing_overlay41.png b/res/images/icon_installing_overlay41.png deleted file mode 100644 index 34cf1aec4..000000000 Binary files a/res/images/icon_installing_overlay41.png and /dev/null differ diff --git a/res/images/icon_installing_overlay42.png b/res/images/icon_installing_overlay42.png deleted file mode 100644 index d622417ac..000000000 Binary files a/res/images/icon_installing_overlay42.png and /dev/null differ diff --git a/res/images/icon_installing_overlay43.png b/res/images/icon_installing_overlay43.png deleted file mode 100644 index 9902df1a7..000000000 Binary files a/res/images/icon_installing_overlay43.png and /dev/null differ diff --git a/res/images/icon_installing_overlay44.png b/res/images/icon_installing_overlay44.png deleted file mode 100644 index b5d7911e1..000000000 Binary files a/res/images/icon_installing_overlay44.png and /dev/null differ diff --git a/res/images/icon_installing_overlay45.png b/res/images/icon_installing_overlay45.png deleted file mode 100644 index dfbf408b6..000000000 Binary files a/res/images/icon_installing_overlay45.png and /dev/null differ diff --git a/res/images/icon_installing_overlay46.png b/res/images/icon_installing_overlay46.png deleted file mode 100644 index 495bb90df..000000000 Binary files a/res/images/icon_installing_overlay46.png and /dev/null differ diff --git a/res/images/icon_installing_overlay47.png b/res/images/icon_installing_overlay47.png deleted file mode 100644 index 9d6937866..000000000 Binary files a/res/images/icon_installing_overlay47.png and /dev/null differ diff --git a/res/images/icon_installing_overlay48.png b/res/images/icon_installing_overlay48.png deleted file mode 100644 index a5080af97..000000000 Binary files a/res/images/icon_installing_overlay48.png and /dev/null differ diff --git a/res/images/indeterminate01.png b/res/images/indeterminate01.png index 4db384337..933528d6d 100644 Binary files a/res/images/indeterminate01.png and b/res/images/indeterminate01.png differ diff --git a/res/images/indeterminate02.png b/res/images/indeterminate02.png index 761b2332f..d760e2bdd 100644 Binary files a/res/images/indeterminate02.png and b/res/images/indeterminate02.png differ diff --git a/res/images/indeterminate03.png b/res/images/indeterminate03.png index e2617abcb..0e97399d1 100644 Binary files a/res/images/indeterminate03.png and b/res/images/indeterminate03.png differ diff --git a/res/images/indeterminate04.png b/res/images/indeterminate04.png index 132940e50..c7d5b4e04 100644 Binary files a/res/images/indeterminate04.png and b/res/images/indeterminate04.png differ diff --git a/res/images/indeterminate05.png b/res/images/indeterminate05.png index a17032c2d..d6fb2a032 100644 Binary files a/res/images/indeterminate05.png and b/res/images/indeterminate05.png differ diff --git a/res/images/indeterminate06.png b/res/images/indeterminate06.png index efaac42e6..44867619f 100644 Binary files a/res/images/indeterminate06.png and b/res/images/indeterminate06.png differ diff --git a/res/images/indeterminate07.png b/res/images/indeterminate07.png deleted file mode 100644 index 6e84a5a0f..000000000 Binary files a/res/images/indeterminate07.png and /dev/null differ diff --git a/res/images/indeterminate08.png b/res/images/indeterminate08.png deleted file mode 100644 index 58c112e38..000000000 Binary files a/res/images/indeterminate08.png and /dev/null differ diff --git a/res/images/indeterminate09.png b/res/images/indeterminate09.png deleted file mode 100644 index b25145f12..000000000 Binary files a/res/images/indeterminate09.png and /dev/null differ diff --git a/res/images/indeterminate10.png b/res/images/indeterminate10.png deleted file mode 100644 index 4ff7e2527..000000000 Binary files a/res/images/indeterminate10.png and /dev/null differ diff --git a/res/images/indeterminate11.png b/res/images/indeterminate11.png deleted file mode 100644 index 4860c2a02..000000000 Binary files a/res/images/indeterminate11.png and /dev/null differ diff --git a/res/images/indeterminate12.png b/res/images/indeterminate12.png deleted file mode 100644 index a249c225b..000000000 Binary files a/res/images/indeterminate12.png and /dev/null differ diff --git a/res/images/indeterminate13.png b/res/images/indeterminate13.png deleted file mode 100644 index 1b70dc072..000000000 Binary files a/res/images/indeterminate13.png and /dev/null differ diff --git a/res/images/indeterminate14.png b/res/images/indeterminate14.png deleted file mode 100644 index a5f779f73..000000000 Binary files a/res/images/indeterminate14.png and /dev/null differ diff --git a/res/images/indeterminate15.png b/res/images/indeterminate15.png deleted file mode 100644 index 018fa685c..000000000 Binary files a/res/images/indeterminate15.png and /dev/null differ diff --git a/res/images/indeterminate16.png b/res/images/indeterminate16.png deleted file mode 100644 index e8e05b6d3..000000000 Binary files a/res/images/indeterminate16.png and /dev/null differ diff --git a/screen_ui.cpp b/screen_ui.cpp index ab7546d40..e36fa3d8f 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -76,10 +76,10 @@ ScreenRecoveryUI::ScreenRecoveryUI() : // that overrides Init() to set these values appropriately and // then call the superclass Init(). animation_fps(20), - indeterminate_frames(16), - installing_frames(48), - install_overlay_offset_x(65), - install_overlay_offset_y(106), + indeterminate_frames(6), + installing_frames(7), + install_overlay_offset_x(13), + install_overlay_offset_y(190), overlay_offset_x(-1), overlay_offset_y(-1) { pthread_mutex_init(&updateMutex, NULL); -- cgit v1.2.3 From 6016d08b0c3b682f1f7000b42a9ea4b6b6d74f22 Mon Sep 17 00:00:00 2001 From: Devin Kim Date: Mon, 8 Oct 2012 09:47:37 -0700 Subject: recovery: fix failure to unmount "/cache" At load_locale_from_cache() function, LOCALE_FILE must get closed after it is opened and used. Otherwise it causes a failure to unmount "/cache" after load_locale_from_cache() function is called. Change-Id: I9cec0f29a8ec4452c8a6a52e2f3c8ce9930d5372 Signed-off-by: Iliyan Malchev --- recovery.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/recovery.cpp b/recovery.cpp index 5c1e3cd21..594774f5a 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -798,6 +798,7 @@ load_locale_from_cache() { } buffer[j] = 0; locale = strdup(buffer); + check_and_fclose(fp, LOCALE_FILE); } } -- cgit v1.2.3 From 7eb7567aa3faebfb22bd052f3505d485ee23d585 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 16 Oct 2012 10:47:27 -0700 Subject: Remove HAVE_SELINUX guards Change-Id: Ia96201f20f7838d7d9e8926208977d3f8318ced4 --- Android.mk | 13 +------------ minzip/Android.mk | 8 ++------ minzip/DirUtil.c | 5 ----- minzip/DirUtil.h | 4 ---- minzip/Zip.c | 4 ---- minzip/Zip.h | 4 ---- recovery.cpp | 2 -- updater/Android.mk | 7 +------ updater/install.c | 4 ---- updater/updater.c | 2 -- updater/updater.h | 4 ---- 11 files changed, 4 insertions(+), 53 deletions(-) diff --git a/Android.mk b/Android.mk index 1c78b4287..cd368a006 100644 --- a/Android.mk +++ b/Android.mk @@ -46,6 +46,7 @@ LOCAL_STATIC_LIBRARIES := \ libpixelflinger_static \ libpng \ libcutils \ + libselinux \ libstdc++ \ libc @@ -55,12 +56,6 @@ ifeq ($(TARGET_USERIMAGES_USE_EXT4), true) LOCAL_STATIC_LIBRARIES += libext4_utils_static libz endif -ifeq ($(HAVE_SELINUX), true) - LOCAL_C_INCLUDES += external/libselinux/include - LOCAL_STATIC_LIBRARIES += libselinux - LOCAL_CFLAGS += -DHAVE_SELINUX -endif # HAVE_SELINUX - # This binary is in the recovery ramdisk, which is otherwise a copy of root. # It gets copied there in config/Makefile. LOCAL_MODULE_TAGS suppresses # a (redundant) copy of the binary in /system/bin for user builds. @@ -73,12 +68,6 @@ else LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UI_LIB) endif -ifeq ($(HAVE_SELINUX),true) - LOCAL_C_INCLUDES += external/libselinux/include - LOCAL_STATIC_LIBRARIES += libselinux - LOCAL_CFLAGS += -DHAVE_SELINUX -endif # HAVE_SELINUX - LOCAL_C_INCLUDES += system/extras/ext4_utils include $(BUILD_EXECUTABLE) diff --git a/minzip/Android.mk b/minzip/Android.mk index 6c1d0969c..045f35570 100644 --- a/minzip/Android.mk +++ b/minzip/Android.mk @@ -8,15 +8,11 @@ LOCAL_SRC_FILES := \ Inlines.c \ Zip.c -LOCAL_C_INCLUDES += \ +LOCAL_C_INCLUDES := \ external/zlib \ external/safe-iop/include -ifeq ($(HAVE_SELINUX),true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_STATIC_LIBRARIES += libselinux -LOCAL_CFLAGS += -DHAVE_SELINUX -endif +LOCAL_STATIC_LIBRARIES := libselinux LOCAL_MODULE := libminzip diff --git a/minzip/DirUtil.c b/minzip/DirUtil.c index 0d49b5780..8dd5da1da 100644 --- a/minzip/DirUtil.c +++ b/minzip/DirUtil.c @@ -145,24 +145,19 @@ dirCreateHierarchy(const char *path, int mode, } else if (ds == DMISSING) { int err; -#ifdef HAVE_SELINUX char *secontext = NULL; if (sehnd) { selabel_lookup(sehnd, &secontext, cpath, mode); setfscreatecon(secontext); } -#endif err = mkdir(cpath, mode); -#ifdef HAVE_SELINUX - if (secontext) { freecon(secontext); setfscreatecon(NULL); } -#endif if (err != 0) { free(cpath); diff --git a/minzip/DirUtil.h b/minzip/DirUtil.h index f8be64026..a5cfa761b 100644 --- a/minzip/DirUtil.h +++ b/minzip/DirUtil.h @@ -24,12 +24,8 @@ extern "C" { #endif -#ifdef HAVE_SELINUX #include #include -#else -struct selabel_handle; -#endif /* Like "mkdir -p", try to guarantee that all directories * specified in path are present, creating as many directories diff --git a/minzip/Zip.c b/minzip/Zip.c index 54d5d55a3..c87f038c5 100644 --- a/minzip/Zip.c +++ b/minzip/Zip.c @@ -1115,23 +1115,19 @@ bool mzExtractRecursive(const ZipArchive *pArchive, * Open the target for writing. */ -#ifdef HAVE_SELINUX char *secontext = NULL; if (sehnd) { selabel_lookup(sehnd, &secontext, targetFile, UNZIP_FILEMODE); setfscreatecon(secontext); } -#endif int fd = creat(targetFile, UNZIP_FILEMODE); -#ifdef HAVE_SELINUX if (secontext) { freecon(secontext); setfscreatecon(NULL); } -#endif if (fd < 0) { LOGE("Can't create target file \"%s\": %s\n", diff --git a/minzip/Zip.h b/minzip/Zip.h index 4bb9ef6a4..c94282827 100644 --- a/minzip/Zip.h +++ b/minzip/Zip.h @@ -18,12 +18,8 @@ extern "C" { #endif -#ifdef HAVE_SELINUX #include #include -#else -struct selabel_handle; -#endif /* * One entry in the Zip archive. Treat this as opaque -- use accessors below. diff --git a/recovery.cpp b/recovery.cpp index ce4358a53..707eec354 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -809,7 +809,6 @@ main(int argc, char **argv) { } } -#ifdef HAVE_SELINUX struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "/file_contexts" } }; @@ -820,7 +819,6 @@ main(int argc, char **argv) { fprintf(stderr, "Warning: No file_contexts\n"); ui->Print("Warning: No file_contexts\n"); } -#endif device->StartRecovery(); diff --git a/updater/Android.mk b/updater/Android.mk index 8876120b0..4271371e9 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -27,17 +27,12 @@ LOCAL_STATIC_LIBRARIES += \ libz endif -ifeq ($(HAVE_SELINUX), true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_STATIC_LIBRARIES += libselinux -LOCAL_CFLAGS += -DHAVE_SELINUX -endif # HAVE_SELINUX - LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS) LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz LOCAL_STATIC_LIBRARIES += libmincrypt libbz LOCAL_STATIC_LIBRARIES += libminelf LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc +LOCAL_STATIC_LIBRARIES += libselinux LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. # Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function diff --git a/updater/install.c b/updater/install.c index f981017bf..9ace12541 100644 --- a/updater/install.c +++ b/updater/install.c @@ -78,23 +78,19 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { goto done; } -#ifdef HAVE_SELINUX char *secontext = NULL; if (sehandle) { selabel_lookup(sehandle, &secontext, mount_point, 0755); setfscreatecon(secontext); } -#endif mkdir(mount_point, 0755); -#ifdef HAVE_SELINUX if (secontext) { freecon(secontext); setfscreatecon(NULL); } -#endif if (strcmp(partition_type, "MTD") == 0) { mtd_scan_partitions(); diff --git a/updater/updater.c b/updater/updater.c index 5f1580870..58ac27f9e 100644 --- a/updater/updater.c +++ b/updater/updater.c @@ -105,7 +105,6 @@ int main(int argc, char** argv) { return 6; } -#ifdef HAVE_SELINUX struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "/file_contexts" } }; @@ -116,7 +115,6 @@ int main(int argc, char** argv) { fprintf(stderr, "Warning: No file_contexts\n"); fprintf(cmd_pipe, "ui_print Warning: No file_contexts\n"); } -#endif // Evaluate the parsed script. diff --git a/updater/updater.h b/updater/updater.h index a00872ca4..d2e901141 100644 --- a/updater/updater.h +++ b/updater/updater.h @@ -20,12 +20,8 @@ #include #include "minzip/Zip.h" -#ifdef HAVE_SELINUX #include #include -#else -struct selabel_handle; -#endif typedef struct { FILE* cmd_pipe; -- cgit v1.2.3 From bf80f49edcec6b22ad7b1219e6ed6eda1e930c8c Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 19 Oct 2012 12:24:26 -0700 Subject: reduce some recovery logging Make minzip log only a count of files when extracting, not individual filenames. Make patching only chatter about free space if there's not enough and compact the other messages. Only the last 8k of the recovery log gets uploaded; this makes it more likely that we will get all of it. Change-Id: I529cb4947fe2185df82b9da5fae450a7480dcecd --- applypatch/applypatch.c | 27 +++++++++++++++++++++------ minzip/Zip.c | 6 +++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 7b8a010e3..69f8633ab 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -585,6 +585,14 @@ int CacheSizeCheck(size_t bytes) { } } +static void print_short_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]) { + int i; + const char* hex = "0123456789abcdef"; + for (i = 0; i < 4; ++i) { + putchar(hex[(sha1[i]>>4) & 0xf]); + putchar(hex[sha1[i] & 0xf]); + } +} // This function applies binary patches to files in a way that is safe // (the original file is not touched until we have the desired @@ -620,7 +628,7 @@ int applypatch(const char* source_filename, char** const patch_sha1_str, Value** patch_data, Value* bonus_data) { - printf("\napplying patch to %s\n", source_filename); + printf("patch %s: ", source_filename); if (target_filename[0] == '-' && target_filename[1] == '\0') { @@ -646,8 +654,9 @@ int applypatch(const char* source_filename, if (memcmp(source_file.sha1, target_sha1, SHA_DIGEST_SIZE) == 0) { // The early-exit case: the patch was already applied, this file // has the desired hash, nothing for us to do. - printf("\"%s\" is already target; no patch needed\n", - target_filename); + printf("already "); + print_short_sha1(target_sha1); + putchar('\n'); free(source_file.data); return 0; } @@ -769,8 +778,10 @@ static int GenerateTarget(FileContents* source_file, enough_space = (free_space > (256 << 10)) && // 256k (two-block) minimum (free_space > (target_size * 3 / 2)); // 50% margin of error - printf("target %ld bytes; free space %ld bytes; retry %d; enough %d\n", - (long)target_size, (long)free_space, retry, enough_space); + if (!enough_space) { + printf("target %ld bytes; free space %ld bytes; retry %d; enough %d\n", + (long)target_size, (long)free_space, retry, enough_space); + } } if (!enough_space) { @@ -805,7 +816,7 @@ static int GenerateTarget(FileContents* source_file, unlink(source_filename); size_t free_space = FreeSpaceForFile(target_fs); - printf("(now %ld bytes free for target)\n", (long)free_space); + printf("(now %ld bytes free for target) ", (long)free_space); } } @@ -901,6 +912,10 @@ static int GenerateTarget(FileContents* source_file, if (memcmp(current_target_sha1, target_sha1, SHA_DIGEST_SIZE) != 0) { printf("patch did not produce expected sha1\n"); return 1; + } else { + printf("now "); + print_short_sha1(target_sha1); + putchar('\n'); } if (output < 0) { diff --git a/minzip/Zip.c b/minzip/Zip.c index c87f038c5..439e5d9cd 100644 --- a/minzip/Zip.c +++ b/minzip/Zip.c @@ -985,6 +985,7 @@ bool mzExtractRecursive(const ZipArchive *pArchive, unsigned int i; bool seenMatch = false; int ok = true; + int extractCount = 0; for (i = 0; i < pArchive->numEntries; i++) { ZipEntry *pEntry = pArchive->pEntries + i; if (pEntry->fileNameLen < zipDirLen) { @@ -1150,13 +1151,16 @@ bool mzExtractRecursive(const ZipArchive *pArchive, break; } - LOGD("Extracted file \"%s\"\n", targetFile); + LOGV("Extracted file \"%s\"\n", targetFile); + ++extractCount; } } if (callback != NULL) callback(targetFile, cookie); } + LOGD("Extracted %d file(s)\n", extractCount); + free(helper.buf); free(zpath); -- cgit v1.2.3 From 6c249f7ae890694f061bfde7a3ab52bf367be110 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 2 Nov 2012 15:04:05 -0700 Subject: move key loading to verifier code Add an option to verifier_test to load keys from a file, the way the recovery does. Change-Id: Icba0e391164f2c1a9fefeab4b0bcb878e91d17b4 --- install.cpp | 100 ---------------------------------------------------- verifier.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ verifier.h | 2 ++ verifier_test.cpp | 11 ++++-- 4 files changed, 112 insertions(+), 103 deletions(-) diff --git a/install.cpp b/install.cpp index b8f478130..0f3298f1d 100644 --- a/install.cpp +++ b/install.cpp @@ -174,106 +174,6 @@ try_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) { return INSTALL_SUCCESS; } -// Reads a file containing one or more public keys as produced by -// DumpPublicKey: this is an RSAPublicKey struct as it would appear -// as a C source literal, eg: -// -// "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" -// -// For key versions newer than the original 2048-bit e=3 keys -// supported by Android, the string is preceded by a version -// identifier, eg: -// -// "v2 {64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" -// -// (Note that the braces and commas in this example are actual -// characters the parser expects to find in the file; the ellipses -// indicate more numbers omitted from this example.) -// -// The file may contain multiple keys in this format, separated by -// commas. The last key must not be followed by a comma. -// -// Returns NULL if the file failed to parse, or if it contain zero keys. -static RSAPublicKey* -load_keys(const char* filename, int* numKeys) { - RSAPublicKey* out = NULL; - *numKeys = 0; - - FILE* f = fopen(filename, "r"); - if (f == NULL) { - LOGE("opening %s: %s\n", filename, strerror(errno)); - goto exit; - } - - { - int i; - bool done = false; - while (!done) { - ++*numKeys; - out = (RSAPublicKey*)realloc(out, *numKeys * sizeof(RSAPublicKey)); - RSAPublicKey* key = out + (*numKeys - 1); - - char start_char; - if (fscanf(f, " %c", &start_char) != 1) goto exit; - if (start_char == '{') { - // a version 1 key has no version specifier. - key->exponent = 3; - } else if (start_char == 'v') { - int version; - if (fscanf(f, "%d {", &version) != 1) goto exit; - if (version == 2) { - key->exponent = 65537; - } else { - goto exit; - } - } - - if (fscanf(f, " %i , 0x%x , { %u", - &(key->len), &(key->n0inv), &(key->n[0])) != 3) { - goto exit; - } - if (key->len != RSANUMWORDS) { - LOGE("key length (%d) does not match expected size\n", key->len); - goto exit; - } - for (i = 1; i < key->len; ++i) { - if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit; - } - if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit; - for (i = 1; i < key->len; ++i) { - if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit; - } - fscanf(f, " } } "); - - // if the line ends in a comma, this file has more keys. - switch (fgetc(f)) { - case ',': - // more keys to come. - break; - - case EOF: - done = true; - break; - - default: - LOGE("unexpected character between keys\n"); - goto exit; - } - - LOGI("read key e=%d\n", key->exponent); - } - } - - fclose(f); - return out; - -exit: - if (f) fclose(f); - free(out); - *numKeys = 0; - return NULL; -} - static int really_install_package(const char *path, int* wipe_cache) { diff --git a/verifier.cpp b/verifier.cpp index 1c5a41d1b..5f4c981e5 100644 --- a/verifier.cpp +++ b/verifier.cpp @@ -179,9 +179,111 @@ int verify_file(const char* path, const RSAPublicKey *pKeys, unsigned int numKey LOGI("whole-file signature verified against key %d\n", i); free(eocd); return VERIFY_SUCCESS; + } else { + LOGI("failed to verify against key %d\n", i); } } free(eocd); LOGE("failed to verify whole-file signature\n"); return VERIFY_FAILURE; } + +// Reads a file containing one or more public keys as produced by +// DumpPublicKey: this is an RSAPublicKey struct as it would appear +// as a C source literal, eg: +// +// "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" +// +// For key versions newer than the original 2048-bit e=3 keys +// supported by Android, the string is preceded by a version +// identifier, eg: +// +// "v2 {64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" +// +// (Note that the braces and commas in this example are actual +// characters the parser expects to find in the file; the ellipses +// indicate more numbers omitted from this example.) +// +// The file may contain multiple keys in this format, separated by +// commas. The last key must not be followed by a comma. +// +// Returns NULL if the file failed to parse, or if it contain zero keys. +RSAPublicKey* +load_keys(const char* filename, int* numKeys) { + RSAPublicKey* out = NULL; + *numKeys = 0; + + FILE* f = fopen(filename, "r"); + if (f == NULL) { + LOGE("opening %s: %s\n", filename, strerror(errno)); + goto exit; + } + + { + int i; + bool done = false; + while (!done) { + ++*numKeys; + out = (RSAPublicKey*)realloc(out, *numKeys * sizeof(RSAPublicKey)); + RSAPublicKey* key = out + (*numKeys - 1); + + char start_char; + if (fscanf(f, " %c", &start_char) != 1) goto exit; + if (start_char == '{') { + // a version 1 key has no version specifier. + key->exponent = 3; + } else if (start_char == 'v') { + int version; + if (fscanf(f, "%d {", &version) != 1) goto exit; + if (version == 2) { + key->exponent = 65537; + } else { + goto exit; + } + } + + if (fscanf(f, " %i , 0x%x , { %u", + &(key->len), &(key->n0inv), &(key->n[0])) != 3) { + goto exit; + } + if (key->len != RSANUMWORDS) { + LOGE("key length (%d) does not match expected size\n", key->len); + goto exit; + } + for (i = 1; i < key->len; ++i) { + if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit; + } + if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit; + for (i = 1; i < key->len; ++i) { + if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit; + } + fscanf(f, " } } "); + + // if the line ends in a comma, this file has more keys. + switch (fgetc(f)) { + case ',': + // more keys to come. + break; + + case EOF: + done = true; + break; + + default: + LOGE("unexpected character between keys\n"); + goto exit; + } + + LOGI("read key e=%d\n", key->exponent); + } + } + + fclose(f); + return out; + +exit: + if (f) fclose(f); + free(out); + *numKeys = 0; + return NULL; +} diff --git a/verifier.h b/verifier.h index 1bdfca6dd..e9ef3b722 100644 --- a/verifier.h +++ b/verifier.h @@ -24,6 +24,8 @@ */ int verify_file(const char* path, const RSAPublicKey *pKeys, unsigned int numKeys); +RSAPublicKey* load_keys(const char* filename, int* numKeys); + #define VERIFY_SUCCESS 0 #define VERIFY_FAILURE 1 diff --git a/verifier_test.cpp b/verifier_test.cpp index 01d092680..79c55783d 100644 --- a/verifier_test.cpp +++ b/verifier_test.cpp @@ -129,21 +129,26 @@ class FakeUI : public RecoveryUI { }; int main(int argc, char **argv) { - if (argc != 2 && argc != 3) { - fprintf(stderr, "Usage: %s [-f4] \n", argv[0]); + if (argc < 2 || argc > 4) { + fprintf(stderr, "Usage: %s [-f4 | -file ] \n", argv[0]); return 2; } RSAPublicKey* key = &test_key; + int num_keys = 1; ++argv; if (strcmp(argv[0], "-f4") == 0) { ++argv; key = &test_f4_key; + } else if (strcmp(argv[0], "-file") == 0) { + ++argv; + key = load_keys(argv[0], &num_keys); + ++argv; } ui = new FakeUI(); - int result = verify_file(*argv, key, 1); + int result = verify_file(*argv, key, num_keys); if (result == VERIFY_SUCCESS) { printf("SUCCESS\n"); return 0; -- cgit v1.2.3 From c86f22c131ef72bd3350720d2029766c4f0721f3 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 17 Dec 2012 09:26:50 -0800 Subject: Pass the correct pointer to munmap on failure. This won't ever happen, and you're probably screwed anyway if it does, but that's no excuse... Change-Id: I2c56f607e351e84308a72b41b834d13aaa98fc62 --- minzip/SysUtil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/minzip/SysUtil.c b/minzip/SysUtil.c index 49a2522d6..31c76d6d4 100644 --- a/minzip/SysUtil.c +++ b/minzip/SysUtil.c @@ -95,16 +95,16 @@ int sysLoadFileInShmem(int fd, MemMapping* pMap) if (memPtr == NULL) return -1; - actual = read(fd, memPtr, length); + pMap->baseAddr = pMap->addr = memPtr; + pMap->baseLength = pMap->length = length; + + actual = TEMP_FAILURE_RETRY(read(fd, memPtr, length)); if (actual != length) { LOGE("only read %d of %d bytes\n", (int) actual, (int) length); sysReleaseShmem(pMap); return -1; } - pMap->baseAddr = pMap->addr = memPtr; - pMap->baseLength = pMap->length = length; - return 0; } -- cgit v1.2.3 From bb01d0c12b29e6ff4a9169c21c95408e7eb882c5 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 17 Dec 2012 10:52:58 -0800 Subject: add NextCheckKeyIsLong() and EnqueueKey() methods NextCheckKeyIsLong() is called right before each call to CheckKey() to tell the implementation if the key is a long-press or not. (To be used on devices with few buttons.) It's done as a separate method (rather than a parameter to CheckKey) to not break existing recovery UI implementations. EnqueueKey() can be called from CheckKey() to put arbitrary code codes in the synchronous queue (to be processed by HandleMenuKey). Change-Id: If8a83d66efe0bbc9e2dc178e5ebe12acd216324b --- ui.cpp | 37 ++++++++++++++++++++++++++++--------- ui.h | 7 +++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ui.cpp b/ui.cpp index bd0fcae62..65f402821 100644 --- a/ui.cpp +++ b/ui.cpp @@ -45,7 +45,8 @@ static RecoveryUI* self = NULL; RecoveryUI::RecoveryUI() : key_queue_len(0), - key_last_down(-1) { + key_last_down(-1), + key_down_time(0) { pthread_mutex_init(&key_queue_mutex, NULL); pthread_cond_init(&key_queue_cond, NULL); self = this; @@ -109,19 +110,29 @@ int RecoveryUI::input_callback(int fd, short revents, void* data) // updown == 1 for key down events; 0 for key up events void RecoveryUI::process_key(int key_code, int updown) { bool register_key = false; + bool long_press = false; + + const long long_threshold = CLOCKS_PER_SEC * 750 / 1000; pthread_mutex_lock(&key_queue_mutex); key_pressed[key_code] = updown; if (updown) { key_last_down = key_code; + key_down_time = clock(); } else { - if (key_last_down == key_code) + if (key_last_down == key_code) { + long duration = clock() - key_down_time; + if (duration > long_threshold) { + long_press = true; + } register_key = true; + } key_last_down = -1; } pthread_mutex_unlock(&key_queue_mutex); if (register_key) { + NextCheckKeyIsLong(long_press); switch (CheckKey(key_code)) { case RecoveryUI::IGNORE: break; @@ -135,18 +146,23 @@ void RecoveryUI::process_key(int key_code, int updown) { break; case RecoveryUI::ENQUEUE: - pthread_mutex_lock(&key_queue_mutex); - const int queue_max = sizeof(key_queue) / sizeof(key_queue[0]); - if (key_queue_len < queue_max) { - key_queue[key_queue_len++] = key_code; - pthread_cond_signal(&key_queue_cond); - } - pthread_mutex_unlock(&key_queue_mutex); + EnqueueKey(key_code); break; } } } +void RecoveryUI::EnqueueKey(int key_code) { + pthread_mutex_lock(&key_queue_mutex); + const int queue_max = sizeof(key_queue) / sizeof(key_queue[0]); + if (key_queue_len < queue_max) { + key_queue[key_queue_len++] = key_code; + pthread_cond_signal(&key_queue_cond); + } + pthread_mutex_unlock(&key_queue_mutex); +} + + // Reads input events, handles special hot keys, and adds to the key queue. void* RecoveryUI::input_thread(void *cookie) { @@ -223,3 +239,6 @@ void RecoveryUI::FlushKeys() { RecoveryUI::KeyAction RecoveryUI::CheckKey(int key) { return RecoveryUI::ENQUEUE; } + +void RecoveryUI::NextCheckKeyIsLong(bool is_long_press) { +} diff --git a/ui.h b/ui.h index acb57663e..aca7b7b87 100644 --- a/ui.h +++ b/ui.h @@ -19,6 +19,7 @@ #include #include +#include // Abstract class for controlling the user interface during recovery. class RecoveryUI { @@ -79,6 +80,8 @@ class RecoveryUI { enum KeyAction { ENQUEUE, TOGGLE, REBOOT, IGNORE }; virtual KeyAction CheckKey(int key); + virtual void NextCheckKeyIsLong(bool is_long_press); + // --- menu display --- // Display some header text followed by a menu of items, which appears @@ -95,6 +98,9 @@ class RecoveryUI { // statements will be displayed. virtual void EndMenu() = 0; +protected: + void EnqueueKey(int key_code); + private: // Key event input queue pthread_mutex_t key_queue_mutex; @@ -102,6 +108,7 @@ private: int key_queue[256], key_queue_len; char key_pressed[KEY_MAX + 1]; // under key_queue_mutex int key_last_down; // under key_queue_mutex + clock_t key_down_time; // under key_queue_mutex int rel_sum; pthread_t input_t; -- cgit v1.2.3 From c560a67b12350102ba237fa70cedc7c972ad4e4b Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 18 Dec 2012 16:31:27 -0800 Subject: add optional overscan compensation to recovery graphics If your screen is a TV, it may not actually be displaying the edges of the framebuffer. Allow specifying an overscan percentage, and move each edge of the framebuffer in by that percent of the width/height. (The gr_* layer just lies to the caller about the size of the framebuffer, telling the caller it's smaller than it really is, and offsets all drawing commands to match.) Change-Id: I11bb2feb39ae522bd3e957a14ebdecf3609e0fdc --- minui/Android.mk | 6 ++++++ minui/graphics.c | 29 +++++++++++++++++++++++++---- minui/minui.h | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/minui/Android.mk b/minui/Android.mk index 285ac62bf..43e0ad33b 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -20,4 +20,10 @@ ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888) LOCAL_CFLAGS += -DRECOVERY_BGRA endif +ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),) + LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT) +else + LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0 +endif + include $(BUILD_STATIC_LIBRARY) diff --git a/minui/graphics.c b/minui/graphics.c index 287878e92..747b2dbc6 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -60,6 +60,9 @@ static GGLSurface gr_framebuffer[NUM_BUFFERS]; static GGLSurface gr_mem_surface; static unsigned gr_active_fb = 0; static unsigned double_buffering = 0; +static int overscan_percent = OVERSCAN_PERCENT; +static int overscan_offset_x = 0; +static int overscan_offset_y = 0; static int gr_fb_fd = -1; static int gr_vt_fd = -1; @@ -132,6 +135,9 @@ static int get_framebuffer(GGLSurface *fb) return -1; } + overscan_offset_x = vi.xres * overscan_percent / 100; + overscan_offset_y = vi.yres * overscan_percent / 100; + fb->version = sizeof(*fb); fb->width = vi.xres; fb->height = vi.yres; @@ -224,6 +230,9 @@ int gr_text(int x, int y, const char *s) GRFont *font = gr_font; unsigned off; + x += overscan_offset_x; + y += overscan_offset_y; + y -= font->ascent; gl->bindTexture(gl, &font->texture); @@ -250,6 +259,9 @@ void gr_texticon(int x, int y, gr_surface icon) { } GGLContext* gl = gr_context; + x += overscan_offset_x; + y += overscan_offset_y; + gl->bindTexture(gl, (GGLSurface*) icon); gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); @@ -263,11 +275,17 @@ void gr_texticon(int x, int y, gr_surface icon) { gl->recti(gl, x, y, x+gr_get_width(icon), y+gr_get_height(icon)); } -void gr_fill(int x, int y, int w, int h) +void gr_fill(int x1, int y1, int x2, int y2) { + x1 += overscan_offset_x; + y1 += overscan_offset_y; + + x2 += overscan_offset_x; + y2 += overscan_offset_y; + GGLContext *gl = gr_context; gl->disable(gl, GGL_TEXTURE_2D); - gl->recti(gl, x, y, w, h); + gl->recti(gl, x1, y1, x2, y2); } void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { @@ -276,6 +294,9 @@ void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { } GGLContext *gl = gr_context; + dx += overscan_offset_x; + dy += overscan_offset_y; + gl->bindTexture(gl, (GGLSurface*) source); gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); @@ -385,12 +406,12 @@ void gr_exit(void) int gr_fb_width(void) { - return gr_framebuffer[0].width; + return gr_framebuffer[0].width - 2*overscan_offset_x; } int gr_fb_height(void) { - return gr_framebuffer[0].height; + return gr_framebuffer[0].height - 2*overscan_offset_y; } gr_pixel *gr_fb_data(void) diff --git a/minui/minui.h b/minui/minui.h index 767ffcb50..bc43bb596 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -36,7 +36,7 @@ void gr_flip(void); void gr_fb_blank(bool blank); void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void gr_fill(int x, int y, int w, int h); +void gr_fill(int x1, int y1, int x2, int y2); int gr_text(int x, int y, const char *s); void gr_texticon(int x, int y, gr_surface icon); int gr_measure(const char *s); -- cgit v1.2.3 From f35d1cef7c19db975a1295e8c23c7fb8bd2489f9 Mon Sep 17 00:00:00 2001 From: Ken Sumrall Date: Wed, 13 Feb 2013 12:59:35 -0800 Subject: Move to using the new unified fstab in recovery. Instead of reading it's own fstab, have recovery invoke fs_mgr to read the unified fstab. Change-Id: I80c75d2c53b809ac60a4a69f0ef7ebfa707c39e9 --- Android.mk | 2 + bootloader.cpp | 43 +++++++++--------- common.h | 19 +------- roots.cpp | 140 +++++++++++++-------------------------------------------- 4 files changed, 55 insertions(+), 149 deletions(-) diff --git a/Android.mk b/Android.mk index f4ecdb5dd..35151ee70 100644 --- a/Android.mk +++ b/Android.mk @@ -32,6 +32,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true RECOVERY_API_VERSION := 3 +RECOVERY_FSTAB_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) LOCAL_STATIC_LIBRARIES := \ @@ -45,6 +46,7 @@ LOCAL_STATIC_LIBRARIES := \ libminui \ libpixelflinger_static \ libpng \ + libfs_mgr \ libcutils \ libselinux \ libstdc++ \ diff --git a/bootloader.cpp b/bootloader.cpp index baaddc55f..600d238f5 100644 --- a/bootloader.cpp +++ b/bootloader.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "bootloader.h" #include "common.h" #include "mtdutils/mtdutils.h" @@ -71,22 +72,22 @@ static int get_bootloader_message_mtd(struct bootloader_message *out, const Volume* v) { size_t write_size; mtd_scan_partitions(); - const MtdPartition *part = mtd_find_partition_by_name(v->device); + const MtdPartition *part = mtd_find_partition_by_name(v->blk_device); if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) { - LOGE("Can't find %s\n", v->device); + LOGE("Can't find %s\n", v->blk_device); return -1; } MtdReadContext *read = mtd_read_partition(part); if (read == NULL) { - LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } const ssize_t size = write_size * MISC_PAGES; char data[size]; ssize_t r = mtd_read_data(read, data, size); - if (r != size) LOGE("Can't read %s\n(%s)\n", v->device, strerror(errno)); + if (r != size) LOGE("Can't read %s\n(%s)\n", v->blk_device, strerror(errno)); mtd_read_close(read); if (r != size) return -1; @@ -97,22 +98,22 @@ static int set_bootloader_message_mtd(const struct bootloader_message *in, const Volume* v) { size_t write_size; mtd_scan_partitions(); - const MtdPartition *part = mtd_find_partition_by_name(v->device); + const MtdPartition *part = mtd_find_partition_by_name(v->blk_device); if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) { - LOGE("Can't find %s\n", v->device); + LOGE("Can't find %s\n", v->blk_device); return -1; } MtdReadContext *read = mtd_read_partition(part); if (read == NULL) { - LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } ssize_t size = write_size * MISC_PAGES; char data[size]; ssize_t r = mtd_read_data(read, data, size); - if (r != size) LOGE("Can't read %s\n(%s)\n", v->device, strerror(errno)); + if (r != size) LOGE("Can't read %s\n(%s)\n", v->blk_device, strerror(errno)); mtd_read_close(read); if (r != size) return -1; @@ -120,16 +121,16 @@ static int set_bootloader_message_mtd(const struct bootloader_message *in, MtdWriteContext *write = mtd_write_partition(part); if (write == NULL) { - LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } if (mtd_write_data(write, data, size) != size) { - LOGE("Can't write %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't write %s\n(%s)\n", v->blk_device, strerror(errno)); mtd_write_close(write); return -1; } if (mtd_write_close(write)) { - LOGE("Can't finish %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't finish %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } @@ -161,20 +162,20 @@ static void wait_for_device(const char* fn) { static int get_bootloader_message_block(struct bootloader_message *out, const Volume* v) { - wait_for_device(v->device); - FILE* f = fopen(v->device, "rb"); + wait_for_device(v->blk_device); + FILE* f = fopen(v->blk_device, "rb"); if (f == NULL) { - LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } struct bootloader_message temp; int count = fread(&temp, sizeof(temp), 1, f); if (count != 1) { - LOGE("Failed reading %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Failed reading %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } if (fclose(f) != 0) { - LOGE("Failed closing %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Failed closing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } memcpy(out, &temp, sizeof(temp)); @@ -183,19 +184,19 @@ static int get_bootloader_message_block(struct bootloader_message *out, static int set_bootloader_message_block(const struct bootloader_message *in, const Volume* v) { - wait_for_device(v->device); - FILE* f = fopen(v->device, "wb"); + wait_for_device(v->blk_device); + FILE* f = fopen(v->blk_device, "wb"); if (f == NULL) { - LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } int count = fwrite(in, sizeof(*in), 1, f); if (count != 1) { - LOGE("Failed writing %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Failed writing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } if (fclose(f) != 0) { - LOGE("Failed closing %s\n(%s)\n", v->device, strerror(errno)); + LOGE("Failed closing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } return 0; diff --git a/common.h b/common.h index a1168cdbb..3587a31f2 100644 --- a/common.h +++ b/common.h @@ -39,24 +39,7 @@ extern "C" { #define STRINGIFY(x) #x #define EXPAND(x) STRINGIFY(x) -typedef struct { - const char* mount_point; // eg. "/cache". must live in the root directory. - - const char* fs_type; // "yaffs2" or "ext4" or "vfat" - - const char* device; // MTD partition name if fs_type == "yaffs" - // block device if fs_type == "ext4" or "vfat" - - const char* device2; // alternative device to try if fs_type - // == "ext4" or "vfat" and mounting - // 'device' fails - - long long length; // (ext4 partition only) when - // formatting, size to use for the - // partition. 0 or negative number - // means to format all but the last - // (that much). -} Volume; +typedef struct fstab_rec Volume; // fopen a file, mounting volumes and making parent dirs as necessary. FILE* fopen_path(const char *path, const char *mode); diff --git a/roots.cpp b/roots.cpp index ca37cf149..09471225d 100644 --- a/roots.cpp +++ b/roots.cpp @@ -22,120 +22,48 @@ #include #include +#include #include "mtdutils/mtdutils.h" #include "mtdutils/mounts.h" #include "roots.h" #include "common.h" #include "make_ext4fs.h" -static int num_volumes = 0; -static Volume* device_volumes = NULL; +static struct fstab *fstab = NULL; extern struct selabel_handle *sehandle; -static int parse_options(char* options, Volume* volume) { - char* option; - while ((option = strtok(options, ","))) { - options = NULL; - - if (strncmp(option, "length=", 7) == 0) { - volume->length = strtoll(option+7, NULL, 10); - } else { - LOGE("bad option \"%s\"\n", option); - return -1; - } - } - return 0; -} - -void load_volume_table() { - int alloc = 2; - device_volumes = (Volume*)malloc(alloc * sizeof(Volume)); - - // Insert an entry for /tmp, which is the ramdisk and is always mounted. - device_volumes[0].mount_point = "/tmp"; - device_volumes[0].fs_type = "ramdisk"; - device_volumes[0].device = NULL; - device_volumes[0].device2 = NULL; - device_volumes[0].length = 0; - num_volumes = 1; +void load_volume_table() +{ + int i; + int ret; - FILE* fstab = fopen("/etc/recovery.fstab", "r"); - if (fstab == NULL) { - LOGE("failed to open /etc/recovery.fstab (%s)\n", strerror(errno)); + fstab = fs_mgr_read_fstab("/etc/recovery.fstab"); + if (!fstab) { + LOGE("failed to read /etc/recovery.fstab\n"); return; } - char buffer[1024]; - int i; - while (fgets(buffer, sizeof(buffer)-1, fstab)) { - for (i = 0; buffer[i] && isspace(buffer[i]); ++i); - if (buffer[i] == '\0' || buffer[i] == '#') continue; - - char* original = strdup(buffer); - - char* mount_point = strtok(buffer+i, " \t\n"); - char* fs_type = strtok(NULL, " \t\n"); - char* device = strtok(NULL, " \t\n"); - // lines may optionally have a second device, to use if - // mounting the first one fails. - char* options = NULL; - char* device2 = strtok(NULL, " \t\n"); - if (device2) { - if (device2[0] == '/') { - options = strtok(NULL, " \t\n"); - } else { - options = device2; - device2 = NULL; - } - } - - if (mount_point && fs_type && device) { - while (num_volumes >= alloc) { - alloc *= 2; - device_volumes = (Volume*)realloc(device_volumes, alloc*sizeof(Volume)); - } - device_volumes[num_volumes].mount_point = strdup(mount_point); - device_volumes[num_volumes].fs_type = strdup(fs_type); - device_volumes[num_volumes].device = strdup(device); - device_volumes[num_volumes].device2 = - device2 ? strdup(device2) : NULL; - - device_volumes[num_volumes].length = 0; - if (parse_options(options, device_volumes + num_volumes) != 0) { - LOGE("skipping malformed recovery.fstab line: %s\n", original); - } else { - ++num_volumes; - } - } else { - LOGE("skipping malformed recovery.fstab line: %s\n", original); - } - free(original); + ret = fs_mgr_add_entry(fstab, "/tmp", "ramdisk", "ramdisk", 0); + if (ret < 0 ) { + LOGE("failed to add /tmp entry to fstab\n"); + fs_mgr_free_fstab(fstab); + fstab = NULL; + return; } - fclose(fstab); - printf("recovery filesystem table\n"); printf("=========================\n"); - for (i = 0; i < num_volumes; ++i) { - Volume* v = &device_volumes[i]; - printf(" %d %s %s %s %s %lld\n", i, v->mount_point, v->fs_type, - v->device, v->device2, v->length); + for (i = 0; i < fstab->num_entries; ++i) { + Volume* v = &fstab->recs[i]; + printf(" %d %s %s %s %lld\n", i, v->mount_point, v->fs_type, + v->blk_device, v->length); } printf("\n"); } Volume* volume_for_path(const char* path) { - int i; - for (i = 0; i < num_volumes; ++i) { - Volume* v = device_volumes+i; - int len = strlen(v->mount_point); - if (strncmp(path, v->mount_point, len) == 0 && - (path[len] == '\0' || path[len] == '/')) { - return v; - } - } - return NULL; + return fs_mgr_get_entry_for_mount_point(fstab, path); } int ensure_path_mounted(const char* path) { @@ -169,27 +97,19 @@ int ensure_path_mounted(const char* path) { // mount an MTD partition as a YAFFS2 filesystem. mtd_scan_partitions(); const MtdPartition* partition; - partition = mtd_find_partition_by_name(v->device); + partition = mtd_find_partition_by_name(v->blk_device); if (partition == NULL) { LOGE("failed to find \"%s\" partition to mount at \"%s\"\n", - v->device, v->mount_point); + v->blk_device, v->mount_point); return -1; } return mtd_mount_partition(partition, v->mount_point, v->fs_type, 0); } else if (strcmp(v->fs_type, "ext4") == 0 || strcmp(v->fs_type, "vfat") == 0) { - result = mount(v->device, v->mount_point, v->fs_type, + result = mount(v->blk_device, v->mount_point, v->fs_type, MS_NOATIME | MS_NODEV | MS_NODIRATIME, ""); if (result == 0) return 0; - if (v->device2) { - LOGW("failed to mount %s (%s); trying %s\n", - v->device, strerror(errno), v->device2); - result = mount(v->device2, v->mount_point, v->fs_type, - MS_NOATIME | MS_NODEV | MS_NODIRATIME, ""); - if (result == 0) return 0; - } - LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno)); return -1; } @@ -249,31 +169,31 @@ int format_volume(const char* volume) { if (strcmp(v->fs_type, "yaffs2") == 0 || strcmp(v->fs_type, "mtd") == 0) { mtd_scan_partitions(); - const MtdPartition* partition = mtd_find_partition_by_name(v->device); + const MtdPartition* partition = mtd_find_partition_by_name(v->blk_device); if (partition == NULL) { - LOGE("format_volume: no MTD partition \"%s\"\n", v->device); + LOGE("format_volume: no MTD partition \"%s\"\n", v->blk_device); return -1; } MtdWriteContext *write = mtd_write_partition(partition); if (write == NULL) { - LOGW("format_volume: can't open MTD \"%s\"\n", v->device); + LOGW("format_volume: can't open MTD \"%s\"\n", v->blk_device); return -1; } else if (mtd_erase_blocks(write, -1) == (off_t) -1) { - LOGW("format_volume: can't erase MTD \"%s\"\n", v->device); + LOGW("format_volume: can't erase MTD \"%s\"\n", v->blk_device); mtd_write_close(write); return -1; } else if (mtd_write_close(write)) { - LOGW("format_volume: can't close MTD \"%s\"\n", v->device); + LOGW("format_volume: can't close MTD \"%s\"\n", v->blk_device); return -1; } return 0; } if (strcmp(v->fs_type, "ext4") == 0) { - int result = make_ext4fs(v->device, v->length, volume, sehandle); + int result = make_ext4fs(v->blk_device, v->length, volume, sehandle); if (result != 0) { - LOGE("format_volume: make_extf4fs failed on %s\n", v->device); + LOGE("format_volume: make_extf4fs failed on %s\n", v->blk_device); return -1; } return 0; -- cgit v1.2.3 From e729bac228cff119062be58f847f8bbda1f2599a Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Fri, 22 Feb 2013 11:29:02 +0000 Subject: Add a CleanSpec for bootable/recovery Change-Id: Ifa7a3aa5e2e3fd5d13266115d592bbfd0aa309c5 --- CleanSpec.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/CleanSpec.mk b/CleanSpec.mk index b84e1b65e..ecf89ae75 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -47,3 +47,4 @@ # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/recovery_intermediates) -- cgit v1.2.3 From 05aa743493279f9637cf52581b9b4729c7141f1e Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Fri, 1 Mar 2013 09:16:26 -0800 Subject: minadbd: remove unnecessary header files. Change-Id: Iff2b53d9e63b279d0262cd2e9cfb11e0ca4d6b42 --- minadbd/adb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/minadbd/adb.c b/minadbd/adb.c index 0e8fd2a7e..948f4b755 100644 --- a/minadbd/adb.c +++ b/minadbd/adb.c @@ -29,8 +29,6 @@ #include "adb.h" #include -#include -#include #if ADB_TRACE ADB_MUTEX_DEFINE( D_lock ); -- cgit v1.2.3 From 55a36ac1e01205f2cd461cd2f89d92e3b64cddd2 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 4 Mar 2013 15:49:02 -0800 Subject: recovery: change font for menus to be an image Instead of representing the font used for menus and log messages in the recovery binary, load it from a resource PNG image. This allows different devices to substitute their own font images. Change-Id: Ib36b86db3d01298aa7ae2b62a26ca29e6ef18014 --- minui/font_10x18.h | 214 ---------------------------------------------------- minui/graphics.c | 39 ++++------ minui/resources.c | 20 +++-- res/images/font.png | Bin 0 -> 5198 bytes screen_ui.cpp | 20 ++--- 5 files changed, 38 insertions(+), 255 deletions(-) delete mode 100644 minui/font_10x18.h create mode 100644 res/images/font.png diff --git a/minui/font_10x18.h b/minui/font_10x18.h deleted file mode 100644 index 7f96465cc..000000000 --- a/minui/font_10x18.h +++ /dev/null @@ -1,214 +0,0 @@ -struct { - unsigned width; - unsigned height; - unsigned cwidth; - unsigned cheight; - unsigned char rundata[]; -} font = { - .width = 960, - .height = 18, - .cwidth = 10, - .cheight = 18, - .rundata = { -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x55,0x82,0x06,0x82,0x02,0x82,0x10,0x82, -0x11,0x83,0x08,0x82,0x0a,0x82,0x04,0x82,0x46,0x82,0x08,0x82,0x07,0x84,0x06, -0x84,0x0a,0x81,0x03,0x88,0x04,0x84,0x04,0x88,0x04,0x84,0x06,0x84,0x1e,0x81, -0x0e,0x81,0x0a,0x84,0x06,0x84,0x07,0x82,0x05,0x85,0x07,0x84,0x04,0x86,0x04, -0x88,0x02,0x88,0x04,0x84,0x04,0x82,0x04,0x82,0x02,0x88,0x05,0x86,0x01,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x84,0x04, -0x86,0x06,0x84,0x04,0x86,0x06,0x84,0x04,0x88,0x02,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, -0x88,0x03,0x86,0x0e,0x86,0x06,0x82,0x11,0x82,0x10,0x82,0x18,0x82,0x0f,0x84, -0x0d,0x82,0x1c,0x82,0x09,0x84,0x7f,0x16,0x84,0x05,0x82,0x05,0x84,0x07,0x83, -0x02,0x82,0x19,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x82,0x03,0x86,0x04, -0x83,0x02,0x82,0x03,0x82,0x01,0x82,0x07,0x82,0x09,0x82,0x06,0x82,0x3e,0x82, -0x04,0x84,0x06,0x83,0x06,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x03, -0x82,0x09,0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82, -0x1c,0x82,0x0e,0x82,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x05,0x84,0x04, -0x82,0x02,0x82,0x05,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82, -0x09,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x04, -0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x03,0x82,0x02,0x82, -0x03,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x02, -0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x03,0x82,0x08,0x82,0x0c, -0x82,0x05,0x84,0x11,0x82,0x0f,0x82,0x18,0x82,0x0e,0x82,0x02,0x82,0x0c,0x82, -0x1c,0x82,0x0b,0x82,0x7f,0x15,0x82,0x08,0x82,0x08,0x82,0x05,0x82,0x01,0x82, -0x01,0x82,0x19,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x82,0x02,0x82,0x01, -0x82,0x01,0x82,0x02,0x82,0x01,0x82,0x01,0x82,0x03,0x82,0x01,0x82,0x07,0x82, -0x08,0x82,0x08,0x82,0x3d,0x82,0x03,0x82,0x02,0x82,0x04,0x84,0x05,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x06,0x83,0x03,0x82,0x08,0x82,0x04,0x81,0x09,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x1a,0x82,0x10,0x82,0x06,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x83, -0x02,0x83,0x02,0x83,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x08,0x82,0x0c,0x82,0x04,0x82,0x02,0x82, -0x11,0x82,0x0e,0x82,0x18,0x82,0x0e,0x82,0x02,0x82,0x0c,0x82,0x0b,0x82,0x0b, -0x82,0x02,0x82,0x0b,0x82,0x4d,0x82,0x45,0x82,0x08,0x82,0x08,0x82,0x05,0x82, -0x02,0x83,0x1a,0x82,0x07,0x81,0x02,0x81,0x07,0x82,0x01,0x82,0x02,0x82,0x01, -0x82,0x05,0x82,0x01,0x84,0x04,0x82,0x01,0x82,0x07,0x82,0x08,0x82,0x08,0x82, -0x06,0x82,0x02,0x82,0x06,0x82,0x28,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x01, -0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x84,0x03,0x82,0x08,0x82, -0x0d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x19,0x82,0x12,0x82,0x05, -0x82,0x04,0x82,0x02,0x82,0x02,0x84,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82, -0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x04, -0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x83,0x02,0x83, -0x02,0x84,0x02,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x0b,0x82,0x05,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08, -0x82,0x04,0x82,0x09,0x82,0x0b,0x82,0x03,0x82,0x04,0x82,0x20,0x82,0x18,0x82, -0x0e,0x82,0x10,0x82,0x0b,0x82,0x0b,0x82,0x02,0x82,0x0b,0x82,0x4d,0x82,0x45, -0x82,0x08,0x82,0x08,0x82,0x26,0x82,0x10,0x88,0x01,0x82,0x01,0x82,0x06,0x83, -0x01,0x82,0x04,0x84,0x08,0x81,0x08,0x82,0x0a,0x82,0x05,0x82,0x02,0x82,0x06, -0x82,0x28,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x08,0x82,0x04,0x82, -0x01,0x82,0x03,0x82,0x08,0x82,0x0d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x18,0x82,0x06,0x88,0x06,0x82,0x04,0x82,0x04,0x82,0x02,0x82,0x01,0x85, -0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x04,0x82,0x02, -0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82, -0x02,0x82,0x04,0x82,0x08,0x88,0x02,0x84,0x02,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x0b,0x82, -0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x04,0x84,0x06, -0x84,0x08,0x82,0x05,0x82,0x09,0x82,0x0b,0x82,0x2b,0x82,0x18,0x82,0x0e,0x82, -0x10,0x82,0x1c,0x82,0x0b,0x82,0x4d,0x82,0x45,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x11,0x82,0x01,0x82,0x03,0x82,0x01,0x82,0x09,0x82,0x06,0x82,0x12,0x82, -0x0a,0x82,0x06,0x84,0x07,0x82,0x27,0x82,0x04,0x82,0x04,0x82,0x05,0x82,0x0b, -0x82,0x07,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x01,0x83,0x04,0x82,0x01,0x83, -0x08,0x82,0x05,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x05,0x83,0x07,0x83,0x05, -0x82,0x16,0x82,0x08,0x82,0x03,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08, -0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82, -0x08,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82, -0x0a,0x82,0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01, -0x82,0x04,0x84,0x06,0x84,0x08,0x82,0x05,0x82,0x0a,0x82,0x0a,0x82,0x23,0x85, -0x03,0x82,0x01,0x83,0x06,0x85,0x05,0x83,0x01,0x82,0x04,0x84,0x04,0x86,0x05, -0x85,0x01,0x81,0x02,0x82,0x01,0x83,0x05,0x84,0x09,0x84,0x02,0x82,0x03,0x82, -0x06,0x82,0x05,0x81,0x01,0x82,0x01,0x82,0x03,0x82,0x01,0x83,0x06,0x84,0x04, -0x82,0x01,0x83,0x06,0x83,0x01,0x82,0x02,0x82,0x01,0x84,0x04,0x86,0x03,0x86, -0x04,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x03,0x87,0x05,0x82,0x08,0x82,0x08,0x82,0x26,0x82, -0x11,0x82,0x01,0x82,0x04,0x86,0x07,0x82,0x05,0x83,0x12,0x82,0x0a,0x82,0x04, -0x88,0x02,0x88,0x0c,0x88,0x10,0x82,0x04,0x82,0x04,0x82,0x05,0x82,0x0a,0x82, -0x06,0x83,0x04,0x82,0x03,0x82,0x03,0x83,0x02,0x82,0x03,0x83,0x02,0x82,0x07, -0x82,0x06,0x84,0x05,0x82,0x02,0x83,0x05,0x83,0x07,0x83,0x04,0x82,0x18,0x82, -0x06,0x82,0x04,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x86,0x04, -0x82,0x08,0x82,0x04,0x82,0x02,0x86,0x04,0x86,0x04,0x82,0x02,0x84,0x02,0x88, -0x05,0x82,0x0a,0x82,0x03,0x85,0x05,0x82,0x08,0x82,0x01,0x82,0x01,0x82,0x02, -0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x02,0x82,0x03,0x82,0x05,0x84,0x07,0x82,0x05,0x82,0x04,0x82,0x03, -0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01,0x82,0x05,0x82,0x08,0x82,0x08,0x82, -0x06,0x82,0x0a,0x82,0x0a,0x82,0x22,0x82,0x03,0x82,0x02,0x83,0x02,0x82,0x04, -0x82,0x03,0x82,0x03,0x82,0x02,0x83,0x03,0x82,0x02,0x82,0x05,0x82,0x06,0x82, -0x03,0x83,0x02,0x83,0x02,0x82,0x06,0x82,0x0b,0x82,0x02,0x82,0x02,0x82,0x07, -0x82,0x05,0x88,0x02,0x83,0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x82, -0x04,0x82,0x02,0x83,0x03,0x83,0x02,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82, -0x03,0x82,0x04,0x82,0x08,0x82,0x02,0x84,0x09,0x82,0x09,0x84,0x23,0x82,0x11, -0x82,0x01,0x82,0x06,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x01,0x82,0x11,0x82, -0x0a,0x82,0x06,0x84,0x07,0x82,0x26,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x08, -0x83,0x09,0x82,0x03,0x82,0x03,0x82,0x09,0x82,0x02,0x82,0x04,0x82,0x05,0x82, -0x06,0x82,0x02,0x82,0x05,0x83,0x01,0x82,0x17,0x82,0x16,0x82,0x06,0x82,0x05, -0x82,0x01,0x82,0x01,0x82,0x02,0x88,0x02,0x82,0x03,0x82,0x03,0x82,0x08,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, -0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x01,0x82,0x01,0x82, -0x02,0x82,0x02,0x84,0x02,0x82,0x04,0x82,0x02,0x86,0x04,0x82,0x04,0x82,0x02, -0x86,0x09,0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x82, -0x01,0x82,0x04,0x84,0x07,0x82,0x07,0x82,0x07,0x82,0x0b,0x82,0x09,0x82,0x27, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02, -0x82,0x01,0x82,0x08,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x07, -0x82,0x0a,0x82,0x06,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x04,0x82, -0x04,0x84,0x04,0x82,0x04,0x82,0x07,0x82,0x06,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x0f,0x88,0x05,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x02,0x82,0x01,0x82, -0x0d,0x82,0x0a,0x82,0x05,0x82,0x02,0x82,0x06,0x82,0x26,0x82,0x05,0x82,0x04, -0x82,0x05,0x82,0x07,0x82,0x0c,0x82,0x02,0x88,0x08,0x82,0x02,0x82,0x04,0x82, -0x05,0x82,0x05,0x82,0x04,0x82,0x08,0x82,0x18,0x82,0x14,0x82,0x07,0x82,0x05, -0x82,0x01,0x84,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, -0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x01,0x82,0x01,0x82, -0x02,0x82,0x02,0x84,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02, -0x82,0x02,0x82,0x0a,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x82, -0x01,0x82,0x01,0x82,0x04,0x84,0x07,0x82,0x07,0x82,0x07,0x82,0x0b,0x82,0x09, -0x82,0x22,0x87,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x88, -0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02, -0x84,0x09,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x08,0x86,0x05, -0x82,0x06,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01,0x82, -0x05,0x82,0x05,0x82,0x04,0x82,0x06,0x82,0x07,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x10,0x82,0x01,0x82,0x07,0x82,0x01,0x82,0x04,0x82,0x01,0x83,0x02,0x82, -0x03,0x83,0x0f,0x82,0x08,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x25,0x82,0x07, -0x82,0x02,0x82,0x06,0x82,0x06,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x09,0x82, -0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x04,0x82,0x08,0x82,0x19,0x82,0x05, -0x88,0x05,0x82,0x08,0x82,0x05,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x03,0x82,0x03,0x82,0x03,0x82, -0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02, -0x82,0x08,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x03,0x82,0x09,0x82,0x05,0x82, -0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x83,0x02,0x83,0x03,0x82,0x02,0x82,0x06, -0x82,0x06,0x82,0x08,0x82,0x0c,0x82,0x08,0x82,0x21,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a,0x82,0x06,0x82,0x03, -0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x85,0x08,0x82,0x05,0x82, -0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0d,0x82,0x04,0x82,0x06,0x82,0x04,0x82, -0x04,0x84,0x04,0x82,0x01,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x05, -0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x38,0x82,0x01,0x82,0x04,0x82,0x01,0x82, -0x01,0x82,0x04,0x84,0x01,0x82,0x01,0x82,0x03,0x82,0x10,0x82,0x08,0x82,0x30, -0x83,0x06,0x82,0x07,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x08,0x82,0x04,0x82, -0x07,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x04, -0x82,0x03,0x81,0x04,0x82,0x1a,0x82,0x10,0x82,0x10,0x82,0x08,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08, -0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x03,0x82, -0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02, -0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x02,0x84,0x02,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x05,0x83,0x02,0x83,0x03, -0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x09,0x82,0x0c,0x82,0x08,0x82,0x21,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a, -0x82,0x07,0x85,0x04,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x82,0x02,0x82, -0x07,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0d,0x82,0x04,0x82, -0x06,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x82,0x01,0x82,0x04,0x84,0x04, -0x82,0x04,0x82,0x04,0x82,0x09,0x82,0x08,0x82,0x08,0x82,0x26,0x82,0x10,0x82, -0x01,0x82,0x05,0x86,0x04,0x82,0x01,0x82,0x01,0x82,0x01,0x83,0x01,0x84,0x10, -0x82,0x06,0x82,0x1d,0x83,0x11,0x83,0x05,0x82,0x09,0x84,0x07,0x82,0x05,0x82, -0x09,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x06,0x83,0x07,0x83,0x09,0x82, -0x0e,0x82,0x0a,0x82,0x06,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x03, -0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x09,0x82, -0x02,0x83,0x02,0x82,0x04,0x82,0x05,0x82,0x06,0x82,0x01,0x82,0x04,0x82,0x04, -0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82, -0x03,0x82,0x09,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x06, -0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x05,0x82,0x05,0x82,0x09,0x82,0x0d,0x82,0x07,0x82,0x21,0x82,0x04,0x82,0x02, -0x83,0x02,0x82,0x04,0x82,0x03,0x82,0x03,0x82,0x02,0x83,0x03,0x82,0x03,0x82, -0x04,0x82,0x06,0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x82,0x03, -0x82,0x06,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x03,0x82, -0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x07,0x82,0x04, -0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x02,0x83,0x05,0x82,0x05,0x88,0x03,0x82, -0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x0a,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x1c,0x82,0x06,0x82,0x02,0x83,0x03,0x84,0x02,0x82,0x10,0x82,0x04,0x82, -0x1e,0x83,0x11,0x83,0x05,0x82,0x0a,0x82,0x05,0x88,0x02,0x88,0x04,0x84,0x09, -0x82,0x05,0x84,0x06,0x84,0x05,0x82,0x09,0x84,0x06,0x84,0x07,0x83,0x07,0x83, -0x0a,0x81,0x0e,0x81,0x0b,0x82,0x07,0x85,0x03,0x82,0x04,0x82,0x02,0x86,0x06, -0x84,0x04,0x86,0x04,0x88,0x02,0x82,0x0a,0x84,0x01,0x81,0x02,0x82,0x04,0x82, -0x02,0x88,0x04,0x83,0x05,0x82,0x04,0x82,0x02,0x88,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x0a,0x85,0x03,0x82,0x04,0x82,0x04,0x84, -0x07,0x82,0x07,0x84,0x07,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, -0x82,0x05,0x88,0x03,0x86,0x09,0x82,0x03,0x86,0x22,0x85,0x01,0x81,0x02,0x82, -0x01,0x83,0x06,0x85,0x05,0x83,0x01,0x82,0x04,0x85,0x05,0x82,0x07,0x86,0x03, -0x82,0x04,0x82,0x02,0x88,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x88,0x02,0x82, -0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x83,0x06, -0x83,0x01,0x82,0x03,0x82,0x08,0x86,0x06,0x84,0x05,0x83,0x01,0x82,0x05,0x82, -0x06,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x04,0x83,0x01,0x82,0x03,0x87,0x06, -0x84,0x05,0x82,0x05,0x84,0x7f,0x15,0x83,0x7f,0x14,0x83,0x7f,0x5e,0x82,0x7f, -0x05,0x89,0x47,0x82,0x04,0x82,0x17,0x82,0x03,0x82,0x34,0x82,0x0e,0x82,0x4e, -0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0a,0x82,0x04,0x82,0x17,0x82,0x03,0x82, -0x34,0x82,0x0e,0x82,0x48,0x82,0x04,0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0a, -0x82,0x04,0x82,0x17,0x82,0x03,0x82,0x34,0x82,0x0e,0x82,0x49,0x82,0x02,0x82, -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0c,0x86,0x19,0x85,0x35,0x82,0x0e,0x82,0x4a, -0x84,0x3f, -0x00, - } -}; diff --git a/minui/graphics.c b/minui/graphics.c index 747b2dbc6..ba68a9538 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -30,7 +30,6 @@ #include -#include "font_10x18.h" #include "minui.h" #if defined(RECOVERY_BGRA) @@ -47,7 +46,7 @@ #define NUM_BUFFERS 2 typedef struct { - GGLSurface texture; + GGLSurface* texture; unsigned cwidth; unsigned cheight; unsigned ascent; @@ -230,12 +229,14 @@ int gr_text(int x, int y, const char *s) GRFont *font = gr_font; unsigned off; + if (!font->texture) return x; + x += overscan_offset_x; y += overscan_offset_y; y -= font->ascent; - gl->bindTexture(gl, &font->texture); + gl->bindTexture(gl, font->texture); gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); @@ -322,31 +323,21 @@ unsigned int gr_get_height(gr_surface surface) { static void gr_init_font(void) { - GGLSurface *ftex; - unsigned char *bits, *rle; - unsigned char *in, data; - gr_font = calloc(sizeof(*gr_font), 1); - ftex = &gr_font->texture; - - bits = malloc(font.width * font.height); - ftex->version = sizeof(*ftex); - ftex->width = font.width; - ftex->height = font.height; - ftex->stride = font.width; - ftex->data = (void*) bits; - ftex->format = GGL_PIXEL_FORMAT_A_8; - - in = font.rundata; - while((data = *in++)) { - memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); - bits += (data & 0x7f); + int res = res_create_surface("font", (void**)&(gr_font->texture)); + if (res != 0) { + printf("failed to read font: res=%d\n", res); + gr_font->texture = NULL; + return; } - gr_font->cwidth = font.cwidth; - gr_font->cheight = font.cheight; - gr_font->ascent = font.cheight - 2; + // interpret the grayscale as alpha + gr_font->texture->format = GGL_PIXEL_FORMAT_A_8; + + gr_font->cwidth = gr_font->texture->width / 96; + gr_font->cheight = gr_font->texture->height; + gr_font->ascent = gr_font->cheight - 2; } int gr_init(void) diff --git a/minui/resources.c b/minui/resources.c index 065f4317e..72f39fbaa 100644 --- a/minui/resources.c +++ b/minui/resources.c @@ -93,22 +93,23 @@ int res_create_surface(const char* name, gr_surface* pSurface) { png_set_sig_bytes(png_ptr, sizeof(header)); png_read_info(png_ptr, info_ptr); - size_t width = info_ptr->width; - size_t height = info_ptr->height; - size_t stride = 4 * width; - size_t pixelSize = stride * height; - int color_type = info_ptr->color_type; int bit_depth = info_ptr->bit_depth; int channels = info_ptr->channels; if (!(bit_depth == 8 && ((channels == 3 && color_type == PNG_COLOR_TYPE_RGB) || (channels == 4 && color_type == PNG_COLOR_TYPE_RGBA) || - (channels == 1 && color_type == PNG_COLOR_TYPE_PALETTE)))) { + (channels == 1 && (color_type == PNG_COLOR_TYPE_PALETTE || + color_type == PNG_COLOR_TYPE_GRAY))))) { return -7; goto exit; } + size_t width = info_ptr->width; + size_t height = info_ptr->height; + size_t stride = (color_type == PNG_COLOR_TYPE_GRAY ? 1 : 4) * width; + size_t pixelSize = stride * height; + surface = malloc(sizeof(GGLSurface) + pixelSize); if (surface == NULL) { result = -8; @@ -120,8 +121,8 @@ int res_create_surface(const char* name, gr_surface* pSurface) { surface->height = height; surface->stride = width; /* Yes, pixels, not bytes */ surface->data = pData; - surface->format = (channels == 3) ? - GGL_PIXEL_FORMAT_RGBX_8888 : GGL_PIXEL_FORMAT_RGBA_8888; + surface->format = (channels == 3) ? GGL_PIXEL_FORMAT_RGBX_8888 : + ((color_type == PNG_COLOR_TYPE_PALETTE ? GGL_PIXEL_FORMAT_RGBA_8888 : GGL_PIXEL_FORMAT_L_8)); int alpha = 0; if (color_type == PNG_COLOR_TYPE_PALETTE) { @@ -131,6 +132,9 @@ int res_create_surface(const char* name, gr_surface* pSurface) { png_set_tRNS_to_alpha(png_ptr); alpha = 1; } + if (color_type == PNG_COLOR_TYPE_GRAY) { + alpha = 1; + } unsigned int y; if (channels == 3 || (channels == 1 && !alpha)) { diff --git a/res/images/font.png b/res/images/font.png new file mode 100644 index 000000000..14a15fbaa Binary files /dev/null and b/res/images/font.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index e36fa3d8f..12af082cc 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -34,8 +34,8 @@ #include "screen_ui.h" #include "ui.h" -#define CHAR_WIDTH 10 -#define CHAR_HEIGHT 18 +static int char_width; +static int char_height; // There's only (at most) one of these objects, and global callbacks // (for pthread_create, and the input event system) need to find it, @@ -194,7 +194,7 @@ void ScreenRecoveryUI::draw_progress_locked() void ScreenRecoveryUI::draw_text_line(int row, const char* t) { if (t[0] != '\0') { - gr_text(0, (row+1)*CHAR_HEIGHT-1, t); + gr_text(0, (row+1)*char_height-1, t); } } @@ -212,8 +212,8 @@ void ScreenRecoveryUI::draw_screen_locked() int i = 0; if (show_menu) { gr_color(64, 96, 255, 255); - gr_fill(0, (menu_top+menu_sel) * CHAR_HEIGHT, - gr_fb_width(), (menu_top+menu_sel+1)*CHAR_HEIGHT+1); + gr_fill(0, (menu_top+menu_sel) * char_height, + gr_fb_width(), (menu_top+menu_sel+1)*char_height+1); for (; i < menu_top + menu_items; ++i) { if (i == menu_top + menu_sel) { @@ -224,8 +224,8 @@ void ScreenRecoveryUI::draw_screen_locked() draw_text_line(i, menu[i]); } } - gr_fill(0, i*CHAR_HEIGHT+CHAR_HEIGHT/2-1, - gr_fb_width(), i*CHAR_HEIGHT+CHAR_HEIGHT/2+1); + gr_fill(0, i*char_height+char_height/2-1, + gr_fb_width(), i*char_height+char_height/2+1); ++i; } @@ -327,12 +327,14 @@ void ScreenRecoveryUI::Init() { gr_init(); + gr_font_size(&char_width, &char_height); + text_col = text_row = 0; - text_rows = gr_fb_height() / CHAR_HEIGHT; + text_rows = gr_fb_height() / char_height; if (text_rows > kMaxRows) text_rows = kMaxRows; text_top = 1; - text_cols = gr_fb_width() / CHAR_WIDTH; + text_cols = gr_fb_width() / char_width; if (text_cols > kMaxCols - 1) text_cols = kMaxCols - 1; LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); -- cgit v1.2.3 From 6fd59ac07d91eb373f4269a40e688aa82a6ccc6e Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 6 Mar 2013 15:01:11 -0800 Subject: more font improvements and cleanup Get rid of the notion of a font's "ascent"; the reference point for drawing is the top-left corner of the character box rather than the baseline. Add some more space between the menu entries and make the highlight bar around the text. Replace the default font.png with two images; the build system will include one or the other based on the resolutions of the device. Restore the original compiled-in bitmap font, to fall back on when font.png can't be found (eg, in the charger binary). Add support for bold text (when a font.png image is used). Change-Id: I6d211a486a3636f20208502b1cd2aeae8b9f5b02 --- fonts/12x22.png | Bin 0 -> 14431 bytes fonts/18x32.png | Bin 0 -> 24437 bytes fonts/OFL.txt | 93 +++++++++++++++++++++++ fonts/README | 6 ++ minui/font_10x18.h | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++ minui/graphics.c | 44 ++++++++--- minui/minui.h | 2 +- recovery.cpp | 1 - res/images/font.png | Bin 5198 -> 0 bytes screen_ui.cpp | 48 +++++++----- screen_ui.h | 3 +- 11 files changed, 378 insertions(+), 33 deletions(-) create mode 100644 fonts/12x22.png create mode 100644 fonts/18x32.png create mode 100644 fonts/OFL.txt create mode 100644 fonts/README create mode 100644 minui/font_10x18.h delete mode 100644 res/images/font.png diff --git a/fonts/12x22.png b/fonts/12x22.png new file mode 100644 index 000000000..ae826bebe Binary files /dev/null and b/fonts/12x22.png differ diff --git a/fonts/18x32.png b/fonts/18x32.png new file mode 100644 index 000000000..d95408a93 Binary files /dev/null and b/fonts/18x32.png differ diff --git a/fonts/OFL.txt b/fonts/OFL.txt new file mode 100644 index 000000000..b14edde76 --- /dev/null +++ b/fonts/OFL.txt @@ -0,0 +1,93 @@ +Copyright (c) 2011, Raph Levien (firstname.lastname@gmail.com), Copyright (c) 2012, Cyreal (cyreal.org) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/fonts/README b/fonts/README new file mode 100644 index 000000000..d0748d2f7 --- /dev/null +++ b/fonts/README @@ -0,0 +1,6 @@ +The images in this directory were generated using the font +Inconsolata, which is released under the OFL license and was obtained +from: + + https://code.google.com/p/googlefontdirectory/source/browse/ofl/inconsolata/ + diff --git a/minui/font_10x18.h b/minui/font_10x18.h new file mode 100644 index 000000000..7f96465cc --- /dev/null +++ b/minui/font_10x18.h @@ -0,0 +1,214 @@ +struct { + unsigned width; + unsigned height; + unsigned cwidth; + unsigned cheight; + unsigned char rundata[]; +} font = { + .width = 960, + .height = 18, + .cwidth = 10, + .cheight = 18, + .rundata = { +0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x55,0x82,0x06,0x82,0x02,0x82,0x10,0x82, +0x11,0x83,0x08,0x82,0x0a,0x82,0x04,0x82,0x46,0x82,0x08,0x82,0x07,0x84,0x06, +0x84,0x0a,0x81,0x03,0x88,0x04,0x84,0x04,0x88,0x04,0x84,0x06,0x84,0x1e,0x81, +0x0e,0x81,0x0a,0x84,0x06,0x84,0x07,0x82,0x05,0x85,0x07,0x84,0x04,0x86,0x04, +0x88,0x02,0x88,0x04,0x84,0x04,0x82,0x04,0x82,0x02,0x88,0x05,0x86,0x01,0x82, +0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x84,0x04, +0x86,0x06,0x84,0x04,0x86,0x06,0x84,0x04,0x88,0x02,0x82,0x04,0x82,0x02,0x82, +0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, +0x88,0x03,0x86,0x0e,0x86,0x06,0x82,0x11,0x82,0x10,0x82,0x18,0x82,0x0f,0x84, +0x0d,0x82,0x1c,0x82,0x09,0x84,0x7f,0x16,0x84,0x05,0x82,0x05,0x84,0x07,0x83, +0x02,0x82,0x19,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x82,0x03,0x86,0x04, +0x83,0x02,0x82,0x03,0x82,0x01,0x82,0x07,0x82,0x09,0x82,0x06,0x82,0x3e,0x82, +0x04,0x84,0x06,0x83,0x06,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x03, +0x82,0x09,0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82, +0x1c,0x82,0x0e,0x82,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x05,0x84,0x04, +0x82,0x02,0x82,0x05,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82, +0x09,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x04, +0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x03,0x82,0x02,0x82, +0x03,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x02, +0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82, +0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x03,0x82,0x08,0x82,0x0c, +0x82,0x05,0x84,0x11,0x82,0x0f,0x82,0x18,0x82,0x0e,0x82,0x02,0x82,0x0c,0x82, +0x1c,0x82,0x0b,0x82,0x7f,0x15,0x82,0x08,0x82,0x08,0x82,0x05,0x82,0x01,0x82, +0x01,0x82,0x19,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x82,0x02,0x82,0x01, +0x82,0x01,0x82,0x02,0x82,0x01,0x82,0x01,0x82,0x03,0x82,0x01,0x82,0x07,0x82, +0x08,0x82,0x08,0x82,0x3d,0x82,0x03,0x82,0x02,0x82,0x04,0x84,0x05,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x06,0x83,0x03,0x82,0x08,0x82,0x04,0x81,0x09,0x82, +0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x1a,0x82,0x10,0x82,0x06,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82, +0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02, +0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x83, +0x02,0x83,0x02,0x83,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, +0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82, +0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x04, +0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x08,0x82,0x0c,0x82,0x04,0x82,0x02,0x82, +0x11,0x82,0x0e,0x82,0x18,0x82,0x0e,0x82,0x02,0x82,0x0c,0x82,0x0b,0x82,0x0b, +0x82,0x02,0x82,0x0b,0x82,0x4d,0x82,0x45,0x82,0x08,0x82,0x08,0x82,0x05,0x82, +0x02,0x83,0x1a,0x82,0x07,0x81,0x02,0x81,0x07,0x82,0x01,0x82,0x02,0x82,0x01, +0x82,0x05,0x82,0x01,0x84,0x04,0x82,0x01,0x82,0x07,0x82,0x08,0x82,0x08,0x82, +0x06,0x82,0x02,0x82,0x06,0x82,0x28,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x01, +0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x84,0x03,0x82,0x08,0x82, +0x0d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x19,0x82,0x12,0x82,0x05, +0x82,0x04,0x82,0x02,0x82,0x02,0x84,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82, +0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x04, +0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x83,0x02,0x83, +0x02,0x84,0x02,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x0b,0x82,0x05,0x82,0x04,0x82,0x02,0x82, +0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08, +0x82,0x04,0x82,0x09,0x82,0x0b,0x82,0x03,0x82,0x04,0x82,0x20,0x82,0x18,0x82, +0x0e,0x82,0x10,0x82,0x0b,0x82,0x0b,0x82,0x02,0x82,0x0b,0x82,0x4d,0x82,0x45, +0x82,0x08,0x82,0x08,0x82,0x26,0x82,0x10,0x88,0x01,0x82,0x01,0x82,0x06,0x83, +0x01,0x82,0x04,0x84,0x08,0x81,0x08,0x82,0x0a,0x82,0x05,0x82,0x02,0x82,0x06, +0x82,0x28,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x08,0x82,0x04,0x82, +0x01,0x82,0x03,0x82,0x08,0x82,0x0d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04, +0x82,0x18,0x82,0x06,0x88,0x06,0x82,0x04,0x82,0x04,0x82,0x02,0x82,0x01,0x85, +0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x04,0x82,0x02, +0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82, +0x02,0x82,0x04,0x82,0x08,0x88,0x02,0x84,0x02,0x82,0x02,0x82,0x04,0x82,0x02, +0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x0b,0x82, +0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x04,0x84,0x06, +0x84,0x08,0x82,0x05,0x82,0x09,0x82,0x0b,0x82,0x2b,0x82,0x18,0x82,0x0e,0x82, +0x10,0x82,0x1c,0x82,0x0b,0x82,0x4d,0x82,0x45,0x82,0x08,0x82,0x08,0x82,0x26, +0x82,0x11,0x82,0x01,0x82,0x03,0x82,0x01,0x82,0x09,0x82,0x06,0x82,0x12,0x82, +0x0a,0x82,0x06,0x84,0x07,0x82,0x27,0x82,0x04,0x82,0x04,0x82,0x05,0x82,0x0b, +0x82,0x07,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x01,0x83,0x04,0x82,0x01,0x83, +0x08,0x82,0x05,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x05,0x83,0x07,0x83,0x05, +0x82,0x16,0x82,0x08,0x82,0x03,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82, +0x02,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08, +0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82, +0x08,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82, +0x0a,0x82,0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01, +0x82,0x04,0x84,0x06,0x84,0x08,0x82,0x05,0x82,0x0a,0x82,0x0a,0x82,0x23,0x85, +0x03,0x82,0x01,0x83,0x06,0x85,0x05,0x83,0x01,0x82,0x04,0x84,0x04,0x86,0x05, +0x85,0x01,0x81,0x02,0x82,0x01,0x83,0x05,0x84,0x09,0x84,0x02,0x82,0x03,0x82, +0x06,0x82,0x05,0x81,0x01,0x82,0x01,0x82,0x03,0x82,0x01,0x83,0x06,0x84,0x04, +0x82,0x01,0x83,0x06,0x83,0x01,0x82,0x02,0x82,0x01,0x84,0x04,0x86,0x03,0x86, +0x04,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x03,0x87,0x05,0x82,0x08,0x82,0x08,0x82,0x26,0x82, +0x11,0x82,0x01,0x82,0x04,0x86,0x07,0x82,0x05,0x83,0x12,0x82,0x0a,0x82,0x04, +0x88,0x02,0x88,0x0c,0x88,0x10,0x82,0x04,0x82,0x04,0x82,0x05,0x82,0x0a,0x82, +0x06,0x83,0x04,0x82,0x03,0x82,0x03,0x83,0x02,0x82,0x03,0x83,0x02,0x82,0x07, +0x82,0x06,0x84,0x05,0x82,0x02,0x83,0x05,0x83,0x07,0x83,0x04,0x82,0x18,0x82, +0x06,0x82,0x04,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x86,0x04, +0x82,0x08,0x82,0x04,0x82,0x02,0x86,0x04,0x86,0x04,0x82,0x02,0x84,0x02,0x88, +0x05,0x82,0x0a,0x82,0x03,0x85,0x05,0x82,0x08,0x82,0x01,0x82,0x01,0x82,0x02, +0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82, +0x04,0x82,0x02,0x82,0x03,0x82,0x05,0x84,0x07,0x82,0x05,0x82,0x04,0x82,0x03, +0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01,0x82,0x05,0x82,0x08,0x82,0x08,0x82, +0x06,0x82,0x0a,0x82,0x0a,0x82,0x22,0x82,0x03,0x82,0x02,0x83,0x02,0x82,0x04, +0x82,0x03,0x82,0x03,0x82,0x02,0x83,0x03,0x82,0x02,0x82,0x05,0x82,0x06,0x82, +0x03,0x83,0x02,0x83,0x02,0x82,0x06,0x82,0x0b,0x82,0x02,0x82,0x02,0x82,0x07, +0x82,0x05,0x88,0x02,0x83,0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x82, +0x04,0x82,0x02,0x83,0x03,0x83,0x02,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06, +0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82, +0x03,0x82,0x04,0x82,0x08,0x82,0x02,0x84,0x09,0x82,0x09,0x84,0x23,0x82,0x11, +0x82,0x01,0x82,0x06,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x01,0x82,0x11,0x82, +0x0a,0x82,0x06,0x84,0x07,0x82,0x26,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x08, +0x83,0x09,0x82,0x03,0x82,0x03,0x82,0x09,0x82,0x02,0x82,0x04,0x82,0x05,0x82, +0x06,0x82,0x02,0x82,0x05,0x83,0x01,0x82,0x17,0x82,0x16,0x82,0x06,0x82,0x05, +0x82,0x01,0x82,0x01,0x82,0x02,0x88,0x02,0x82,0x03,0x82,0x03,0x82,0x08,0x82, +0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, +0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x01,0x82,0x01,0x82, +0x02,0x82,0x02,0x84,0x02,0x82,0x04,0x82,0x02,0x86,0x04,0x82,0x04,0x82,0x02, +0x86,0x09,0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x82, +0x01,0x82,0x04,0x84,0x07,0x82,0x07,0x82,0x07,0x82,0x0b,0x82,0x09,0x82,0x27, +0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82, +0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02, +0x82,0x01,0x82,0x08,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82, +0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x07, +0x82,0x0a,0x82,0x06,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x04,0x82, +0x04,0x84,0x04,0x82,0x04,0x82,0x07,0x82,0x06,0x82,0x08,0x82,0x08,0x82,0x26, +0x82,0x0f,0x88,0x05,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x02,0x82,0x01,0x82, +0x0d,0x82,0x0a,0x82,0x05,0x82,0x02,0x82,0x06,0x82,0x26,0x82,0x05,0x82,0x04, +0x82,0x05,0x82,0x07,0x82,0x0c,0x82,0x02,0x88,0x08,0x82,0x02,0x82,0x04,0x82, +0x05,0x82,0x05,0x82,0x04,0x82,0x08,0x82,0x18,0x82,0x14,0x82,0x07,0x82,0x05, +0x82,0x01,0x84,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82, +0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, +0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x01,0x82,0x01,0x82, +0x02,0x82,0x02,0x84,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02, +0x82,0x02,0x82,0x0a,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x82, +0x01,0x82,0x01,0x82,0x04,0x84,0x07,0x82,0x07,0x82,0x07,0x82,0x0b,0x82,0x09, +0x82,0x22,0x87,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x88, +0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02, +0x84,0x09,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82, +0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x08,0x86,0x05, +0x82,0x06,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01,0x82, +0x05,0x82,0x05,0x82,0x04,0x82,0x06,0x82,0x07,0x82,0x08,0x82,0x08,0x82,0x26, +0x82,0x10,0x82,0x01,0x82,0x07,0x82,0x01,0x82,0x04,0x82,0x01,0x83,0x02,0x82, +0x03,0x83,0x0f,0x82,0x08,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x25,0x82,0x07, +0x82,0x02,0x82,0x06,0x82,0x06,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x09,0x82, +0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x04,0x82,0x08,0x82,0x19,0x82,0x05, +0x88,0x05,0x82,0x08,0x82,0x05,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x02,0x82, +0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x03,0x82,0x03,0x82,0x03,0x82, +0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02, +0x82,0x08,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x03,0x82,0x09,0x82,0x05,0x82, +0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x83,0x02,0x83,0x03,0x82,0x02,0x82,0x06, +0x82,0x06,0x82,0x08,0x82,0x0c,0x82,0x08,0x82,0x21,0x82,0x04,0x82,0x02,0x82, +0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a,0x82,0x06,0x82,0x03, +0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x85,0x08,0x82,0x05,0x82, +0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0d,0x82,0x04,0x82,0x06,0x82,0x04,0x82, +0x04,0x84,0x04,0x82,0x01,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x05, +0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x38,0x82,0x01,0x82,0x04,0x82,0x01,0x82, +0x01,0x82,0x04,0x84,0x01,0x82,0x01,0x82,0x03,0x82,0x10,0x82,0x08,0x82,0x30, +0x83,0x06,0x82,0x07,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x08,0x82,0x04,0x82, +0x07,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x04, +0x82,0x03,0x81,0x04,0x82,0x1a,0x82,0x10,0x82,0x10,0x82,0x08,0x82,0x04,0x82, +0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08, +0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x03,0x82, +0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02, +0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x02,0x84,0x02,0x82,0x03,0x82,0x03,0x82, +0x04,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x05,0x83,0x02,0x83,0x03, +0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x09,0x82,0x0c,0x82,0x08,0x82,0x21,0x82, +0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a, +0x82,0x07,0x85,0x04,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x82,0x02,0x82, +0x07,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, +0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0d,0x82,0x04,0x82, +0x06,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x82,0x01,0x82,0x04,0x84,0x04, +0x82,0x04,0x82,0x04,0x82,0x09,0x82,0x08,0x82,0x08,0x82,0x26,0x82,0x10,0x82, +0x01,0x82,0x05,0x86,0x04,0x82,0x01,0x82,0x01,0x82,0x01,0x83,0x01,0x84,0x10, +0x82,0x06,0x82,0x1d,0x83,0x11,0x83,0x05,0x82,0x09,0x84,0x07,0x82,0x05,0x82, +0x09,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, +0x82,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x06,0x83,0x07,0x83,0x09,0x82, +0x0e,0x82,0x0a,0x82,0x06,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x03, +0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x09,0x82, +0x02,0x83,0x02,0x82,0x04,0x82,0x05,0x82,0x06,0x82,0x01,0x82,0x04,0x82,0x04, +0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82, +0x03,0x82,0x09,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x06, +0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82, +0x05,0x82,0x05,0x82,0x09,0x82,0x0d,0x82,0x07,0x82,0x21,0x82,0x04,0x82,0x02, +0x83,0x02,0x82,0x04,0x82,0x03,0x82,0x03,0x82,0x02,0x83,0x03,0x82,0x03,0x82, +0x04,0x82,0x06,0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x82,0x03, +0x82,0x06,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x03,0x82, +0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x07,0x82,0x04, +0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x02,0x83,0x05,0x82,0x05,0x88,0x03,0x82, +0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x0a,0x82,0x08,0x82,0x08,0x82,0x26, +0x82,0x1c,0x82,0x06,0x82,0x02,0x83,0x03,0x84,0x02,0x82,0x10,0x82,0x04,0x82, +0x1e,0x83,0x11,0x83,0x05,0x82,0x0a,0x82,0x05,0x88,0x02,0x88,0x04,0x84,0x09, +0x82,0x05,0x84,0x06,0x84,0x05,0x82,0x09,0x84,0x06,0x84,0x07,0x83,0x07,0x83, +0x0a,0x81,0x0e,0x81,0x0b,0x82,0x07,0x85,0x03,0x82,0x04,0x82,0x02,0x86,0x06, +0x84,0x04,0x86,0x04,0x88,0x02,0x82,0x0a,0x84,0x01,0x81,0x02,0x82,0x04,0x82, +0x02,0x88,0x04,0x83,0x05,0x82,0x04,0x82,0x02,0x88,0x02,0x82,0x04,0x82,0x02, +0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x0a,0x85,0x03,0x82,0x04,0x82,0x04,0x84, +0x07,0x82,0x07,0x84,0x07,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, +0x82,0x05,0x88,0x03,0x86,0x09,0x82,0x03,0x86,0x22,0x85,0x01,0x81,0x02,0x82, +0x01,0x83,0x06,0x85,0x05,0x83,0x01,0x82,0x04,0x85,0x05,0x82,0x07,0x86,0x03, +0x82,0x04,0x82,0x02,0x88,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x88,0x02,0x82, +0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x83,0x06, +0x83,0x01,0x82,0x03,0x82,0x08,0x86,0x06,0x84,0x05,0x83,0x01,0x82,0x05,0x82, +0x06,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x04,0x83,0x01,0x82,0x03,0x87,0x06, +0x84,0x05,0x82,0x05,0x84,0x7f,0x15,0x83,0x7f,0x14,0x83,0x7f,0x5e,0x82,0x7f, +0x05,0x89,0x47,0x82,0x04,0x82,0x17,0x82,0x03,0x82,0x34,0x82,0x0e,0x82,0x4e, +0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0a,0x82,0x04,0x82,0x17,0x82,0x03,0x82, +0x34,0x82,0x0e,0x82,0x48,0x82,0x04,0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0a, +0x82,0x04,0x82,0x17,0x82,0x03,0x82,0x34,0x82,0x0e,0x82,0x49,0x82,0x02,0x82, +0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0c,0x86,0x19,0x85,0x35,0x82,0x0e,0x82,0x4a, +0x84,0x3f, +0x00, + } +}; diff --git a/minui/graphics.c b/minui/graphics.c index ba68a9538..4968eac7a 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -30,6 +30,7 @@ #include +#include "font_10x18.h" #include "minui.h" #if defined(RECOVERY_BGRA) @@ -49,7 +50,6 @@ typedef struct { GGLSurface* texture; unsigned cwidth; unsigned cheight; - unsigned ascent; } GRFont; static GRFont *gr_font = 0; @@ -223,7 +223,7 @@ void gr_font_size(int *x, int *y) *y = gr_font->cheight; } -int gr_text(int x, int y, const char *s) +int gr_text(int x, int y, const char *s, int bold) { GGLContext *gl = gr_context; GRFont *font = gr_font; @@ -231,11 +231,11 @@ int gr_text(int x, int y, const char *s) if (!font->texture) return x; + bold = bold && (font->texture->height != font->cheight); + x += overscan_offset_x; y += overscan_offset_y; - y -= font->ascent; - gl->bindTexture(gl, font->texture); gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); @@ -245,7 +245,8 @@ int gr_text(int x, int y, const char *s) while((off = *s++)) { off -= 32; if (off < 96) { - gl->texCoord2i(gl, (off * font->cwidth) - x, 0 - y); + gl->texCoord2i(gl, (off * font->cwidth) - x, + (bold ? font->cheight : 0) - y); gl->recti(gl, x, y, x + font->cwidth, y + font->cheight); } x += font->cwidth; @@ -326,18 +327,37 @@ static void gr_init_font(void) gr_font = calloc(sizeof(*gr_font), 1); int res = res_create_surface("font", (void**)&(gr_font->texture)); - if (res != 0) { + if (res == 0) { + // The font image should be a 96x2 array of character images. The + // columns are the printable ASCII characters 0x20 - 0x7f. The + // top row is regular text; the bottom row is bold. + gr_font->cwidth = gr_font->texture->width / 96; + gr_font->cheight = gr_font->texture->height / 2; + } else { printf("failed to read font: res=%d\n", res); - gr_font->texture = NULL; - return; + + // fall back to the compiled-in font. + gr_font->texture = malloc(sizeof(*gr_font->texture)); + gr_font->texture->width = font.width; + gr_font->texture->height = font.height; + gr_font->texture->stride = font.width; + + unsigned char* bits = malloc(font.width * font.height); + gr_font->texture->data = (void*) bits; + + unsigned char data; + unsigned char* in = font.rundata; + while((data = *in++)) { + memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); + bits += (data & 0x7f); + } + + gr_font->cwidth = font.cwidth; + gr_font->cheight = font.cheight; } // interpret the grayscale as alpha gr_font->texture->format = GGL_PIXEL_FORMAT_A_8; - - gr_font->cwidth = gr_font->texture->width / 96; - gr_font->cheight = gr_font->texture->height; - gr_font->ascent = gr_font->cheight - 2; } int gr_init(void) diff --git a/minui/minui.h b/minui/minui.h index bc43bb596..1b8dd059b 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -37,7 +37,7 @@ void gr_fb_blank(bool blank); void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); void gr_fill(int x1, int y1, int x2, int y2); -int gr_text(int x, int y, const char *s); +int gr_text(int x, int y, const char *s, int bold); void gr_texticon(int x, int y, gr_surface icon); int gr_measure(const char *s); void gr_font_size(int *x, int *y); diff --git a/recovery.cpp b/recovery.cpp index 92aa50372..7002cb8a4 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -704,7 +704,6 @@ prompt_and_wait(Device* device, int status) { break; case Device::WIPE_CACHE: - ui->ShowText(false); ui->Print("\n-- Wiping cache...\n"); erase_volume("/cache"); ui->Print("Cache wipe complete.\n"); diff --git a/res/images/font.png b/res/images/font.png deleted file mode 100644 index 14a15fbaa..000000000 Binary files a/res/images/font.png and /dev/null differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 12af082cc..222de00ee 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -192,11 +192,9 @@ void ScreenRecoveryUI::draw_progress_locked() } } -void ScreenRecoveryUI::draw_text_line(int row, const char* t) { - if (t[0] != '\0') { - gr_text(0, (row+1)*char_height-1, t); - } -} +#define C_HEADER 247,0,6 +#define C_MENU 0,106,157 +#define C_LOG 249,194,0 // Redraw everything on the screen. Does not flip pages. // Should only be called with updateMutex locked. @@ -209,30 +207,46 @@ void ScreenRecoveryUI::draw_screen_locked() gr_color(0, 0, 0, 160); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); + int y = 0; int i = 0; if (show_menu) { - gr_color(64, 96, 255, 255); - gr_fill(0, (menu_top+menu_sel) * char_height, - gr_fb_width(), (menu_top+menu_sel+1)*char_height+1); + gr_color(C_HEADER, 255); for (; i < menu_top + menu_items; ++i) { + if (i == menu_top) gr_color(C_MENU, 255); + if (i == menu_top + menu_sel) { + // draw the highlight bar + gr_fill(0, y-2, gr_fb_width(), y+char_height+2); + // white text of selected item gr_color(255, 255, 255, 255); - draw_text_line(i, menu[i]); - gr_color(64, 96, 255, 255); + if (menu[i][0]) gr_text(4, y, menu[i], 1); + gr_color(C_MENU, 255); } else { - draw_text_line(i, menu[i]); + if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top); } + y += char_height+4; } - gr_fill(0, i*char_height+char_height/2-1, - gr_fb_width(), i*char_height+char_height/2+1); + gr_color(C_MENU, 255); + y += 4; + gr_fill(0, y, gr_fb_width(), y+2); + y += 4; ++i; } - gr_color(255, 255, 0, 255); - - for (; i < text_rows; ++i) { - draw_text_line(i, text[(i+text_top) % text_rows]); + gr_color(C_LOG, 255); + + // display from the bottom up, until we hit the top of the + // screen, the bottom of the menu, or we've displayed the + // entire text buffer. + int ty; + int row = (text_top+text_rows-1) % text_rows; + for (int ty = gr_fb_height() - char_height, count = 0; + ty > y+2 && count < text_rows; + ty -= char_height, ++count) { + gr_text(4, ty, text[row], 0); + --row; + if (row < 0) row = text_rows-1; } } } diff --git a/screen_ui.h b/screen_ui.h index 80051724b..fe0de46e8 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -76,7 +76,7 @@ class ScreenRecoveryUI : public RecoveryUI { bool pagesIdentical; static const int kMaxCols = 96; - static const int kMaxRows = 32; + static const int kMaxRows = 96; // Log text overlay, displayed when a magic key is pressed char text[kMaxRows][kMaxCols]; @@ -100,7 +100,6 @@ class ScreenRecoveryUI : public RecoveryUI { void draw_install_overlay_locked(int frame); void draw_background_locked(Icon icon); void draw_progress_locked(); - void draw_text_line(int row, const char* t); void draw_screen_locked(); void update_screen_locked(); void update_progress_locked(); -- cgit v1.2.3 From 4e21482d979f6f81b34f92e664adf137555d4504 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 9 Apr 2013 21:41:29 -0700 Subject: Add liblog Bug: 8580410 Change-Id: Ie60dade81c06589cb0daee431611ded34adef8e6 --- Android.mk | 1 + mtdutils/Android.mk | 2 +- updater/Android.mk | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Android.mk b/Android.mk index 35151ee70..075fa2cfe 100644 --- a/Android.mk +++ b/Android.mk @@ -48,6 +48,7 @@ LOCAL_STATIC_LIBRARIES := \ libpng \ libfs_mgr \ libcutils \ + liblog \ libselinux \ libstdc++ \ libm \ diff --git a/mtdutils/Android.mk b/mtdutils/Android.mk index ef417fa19..f04355b5e 100644 --- a/mtdutils/Android.mk +++ b/mtdutils/Android.mk @@ -14,5 +14,5 @@ LOCAL_SRC_FILES := flash_image.c LOCAL_MODULE := flash_image LOCAL_MODULE_TAGS := eng LOCAL_STATIC_LIBRARIES := libmtdutils -LOCAL_SHARED_LIBRARIES := libcutils libc +LOCAL_SHARED_LIBRARIES := libcutils liblog libc include $(BUILD_EXECUTABLE) diff --git a/updater/Android.mk b/updater/Android.mk index 4271371e9..67e98ecd4 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -31,7 +31,7 @@ LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDA LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz LOCAL_STATIC_LIBRARIES += libmincrypt libbz LOCAL_STATIC_LIBRARIES += libminelf -LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc +LOCAL_STATIC_LIBRARIES += libcutils liblog libstdc++ libc LOCAL_STATIC_LIBRARIES += libselinux LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. -- cgit v1.2.3 From 7c3ae45ef9306d2ff4b491e0488c8849bf15ce90 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 14 May 2013 11:03:02 -0700 Subject: recovery: turn on text display for install errors in debug builds Hopefully this will reduce the number of OTA "bugs" reported that are really just someone having changed their system partition, invalidating future incremental OTAs. Also fixes a longstanding TODO about putting LOGE() output in the on-screen display. Change-Id: I44e5be65b2dee7ebce2cce28ccd920dc3d6e522e --- common.h | 6 ++++-- recovery.cpp | 35 +++++++++++++++++++++++++++++++++-- verifier_test.cpp | 14 ++++++++++---- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/common.h b/common.h index 3587a31f2..768f499f9 100644 --- a/common.h +++ b/common.h @@ -18,13 +18,13 @@ #define RECOVERY_COMMON_H #include +#include #ifdef __cplusplus extern "C" { #endif -// TODO: restore ui_print for LOGE -#define LOGE(...) fprintf(stdout, "E:" __VA_ARGS__) +#define LOGE(...) ui_print("E:" __VA_ARGS__) #define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__) #define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__) @@ -44,6 +44,8 @@ typedef struct fstab_rec Volume; // fopen a file, mounting volumes and making parent dirs as necessary. FILE* fopen_path(const char *path, const char *mode); +void ui_print(const char* format, ...); + #ifdef __cplusplus } #endif diff --git a/recovery.cpp b/recovery.cpp index 7002cb8a4..a84d8333a 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -15,11 +15,13 @@ */ #include +#include #include #include #include #include #include +#include #include #include #include @@ -27,7 +29,6 @@ #include #include #include -#include #include "bootloader.h" #include "common.h" @@ -801,6 +802,24 @@ load_locale_from_cache() { } } +static RecoveryUI* gCurrentUI = NULL; + +void +ui_print(const char* format, ...) { + char buffer[256]; + + va_list ap; + va_start(ap, format); + vsnprintf(buffer, sizeof(buffer), format, ap); + va_end(ap); + + if (gCurrentUI != NULL) { + gCurrentUI->Print("%s", buffer); + } else { + fputs(buffer, stdout); + } +} + int main(int argc, char **argv) { time_t start = time(NULL); @@ -856,6 +875,7 @@ main(int argc, char **argv) { Device* device = make_device(); ui = device->GetUI(); + gCurrentUI = ui; ui->Init(); ui->SetLocale(locale); @@ -909,7 +929,18 @@ main(int argc, char **argv) { LOGE("Cache wipe (requested by package) failed."); } } - if (status != INSTALL_SUCCESS) ui->Print("Installation aborted.\n"); + if (status != INSTALL_SUCCESS) { + ui->Print("Installation aborted.\n"); + + // If this is an eng or userdebug build, then automatically + // turn the text display on if the script fails so the error + // message is visible. + char buffer[PROPERTY_VALUE_MAX+1]; + property_get("ro.build.fingerprint", buffer, ""); + if (strstr(buffer, ":userdebug/") || strstr(buffer, ":eng/")) { + ui->ShowText(true); + } + } } else if (wipe_data) { if (device->WipeData()) status = INSTALL_ERROR; if (erase_volume("/data")) status = INSTALL_ERROR; diff --git a/verifier_test.cpp b/verifier_test.cpp index 79c55783d..2ef52a0f7 100644 --- a/verifier_test.cpp +++ b/verifier_test.cpp @@ -18,6 +18,7 @@ #include #include +#include "common.h" #include "verifier.h" #include "ui.h" @@ -113,13 +114,10 @@ class FakeUI : public RecoveryUI { bool IsTextVisible() { return false; } bool WasTextEverVisible() { return false; } void Print(const char* fmt, ...) { - char buf[256]; va_list ap; va_start(ap, fmt); - vsnprintf(buf, 256, fmt, ap); + vfprintf(stderr, fmt, ap); va_end(ap); - - fputs(buf, stderr); } void StartMenu(const char* const * headers, const char* const * items, @@ -128,6 +126,14 @@ class FakeUI : public RecoveryUI { void EndMenu() { } }; +void +ui_print(const char* format, ...) { + va_list ap; + va_start(ap, format); + vfprintf(stdout, format, ap); + va_end(ap); +} + int main(int argc, char **argv) { if (argc < 2 || argc > 4) { fprintf(stderr, "Usage: %s [-f4 | -file ] \n", argv[0]); -- cgit v1.2.3 From da1ebaef0aa8e38db6edf8bfc3d96290461a424f Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 16 May 2013 11:23:48 -0700 Subject: recovery: save logs from the last few invocations of recovery Extends the last_log mechanism to save logs from the last six invocations of recovery, so that we're more likely to have useful logs even if the device has repeatedly booted into recovery. Change-Id: I08ae7a09553ada45f9e0733fe1e55e5a22efd9f9 --- recovery.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/recovery.cpp b/recovery.cpp index a84d8333a..840e63c42 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -59,10 +59,11 @@ static const struct option OPTIONS[] = { { NULL, 0, NULL, 0 }, }; +#define LAST_LOG_FILE "/cache/recovery/last_log" + static const char *COMMAND_FILE = "/cache/recovery/command"; static const char *INTENT_FILE = "/cache/recovery/intent"; static const char *LOG_FILE = "/cache/recovery/log"; -static const char *LAST_LOG_FILE = "/cache/recovery/last_log"; static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install"; static const char *LOCALE_FILE = "/cache/recovery/last_locale"; static const char *CACHE_ROOT = "/cache"; @@ -260,6 +261,21 @@ copy_log_file(const char* source, const char* destination, int append) { } } +// Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max +// Overwrites any existing last_log.$max. +static void +rotate_last_logs(int max) { + char oldfn[256]; + char newfn[256]; + + int i; + for (i = max-1; i >= 0; --i) { + snprintf(oldfn, sizeof(oldfn), (i==0) ? LAST_LOG_FILE : (LAST_LOG_FILE ".%d"), i); + snprintf(newfn, sizeof(newfn), LAST_LOG_FILE ".%d", i+1); + // ignore errors + rename(oldfn, newfn); + } +} // clear the recovery command and prepare to boot a (hopefully working) system, // copy our log file to cache as well (for the system to read), and @@ -843,6 +859,8 @@ main(int argc, char **argv) { printf("Starting recovery on %s", ctime(&start)); load_volume_table(); + ensure_path_mounted(LAST_LOG_FILE); + rotate_last_logs(5); get_args(&argc, &argv); int previous_runs = 0; -- cgit v1.2.3 From 93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8 Mon Sep 17 00:00:00 2001 From: Jin Feng Date: Tue, 4 Jun 2013 17:46:24 +0800 Subject: Fix the potential segmentation fault Extral newline can trigger recovery segmentation fault Test case: host$ adb shell 'echo -en "--update_package=ota_update.zip\n--show_text\n\n" > /cache/recovery/command' host$ adb reboot recovery Change-Id: If1781c1f5ad94a273f1cb122b67cedd9fb562433 Signed-off-by: Jin Feng --- recovery.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/recovery.cpp b/recovery.cpp index 92aa50372..2541e54d8 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -198,6 +198,7 @@ get_args(int *argc, char ***argv) { if (*argc <= 1) { FILE *fp = fopen_path(COMMAND_FILE, "r"); if (fp != NULL) { + char *token; char *argv0 = (*argv)[0]; *argv = (char **) malloc(sizeof(char *) * MAX_ARGS); (*argv)[0] = argv0; // use the same program name @@ -205,7 +206,12 @@ get_args(int *argc, char ***argv) { char buf[MAX_ARG_LENGTH]; for (*argc = 1; *argc < MAX_ARGS; ++*argc) { if (!fgets(buf, sizeof(buf), fp)) break; - (*argv)[*argc] = strdup(strtok(buf, "\r\n")); // Strip newline. + token = strtok(buf, "\r\n"); + if (token != NULL) { + (*argv)[*argc] = strdup(token); // Strip newline. + } else { + --*argc; + } } check_and_fclose(fp, COMMAND_FILE); -- cgit v1.2.3 From 2f6877a0220475303907203308c018d789ea1a53 Mon Sep 17 00:00:00 2001 From: yetta_wu Date: Tue, 25 Jun 2013 15:03:11 +0800 Subject: recovery: init backgroundIcon properly to avoid recovery mode crash We met factory issue that some devices would crash in recovery mode because the backgroundIcon array did not reset to NULL when initializing. Bug: 9568624 Change-Id: I13c7a7cc1053a7ffdbadd71740c1a2b4a2af6bba Signed-off-by: yetta_wu Signed-off-by: Iliyan Malchev --- screen_ui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/screen_ui.cpp b/screen_ui.cpp index 222de00ee..93e260936 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -82,6 +82,10 @@ ScreenRecoveryUI::ScreenRecoveryUI() : install_overlay_offset_y(190), overlay_offset_x(-1), overlay_offset_y(-1) { + + for (int i = 0; i < 5; i++) + backgroundIcon[i] = NULL; + pthread_mutex_init(&updateMutex, NULL); self = this; } -- cgit v1.2.3 From 044a0b4d49a11edfa13471ce20914b0514eb7e0e Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 8 Jul 2013 09:42:54 -0700 Subject: recovery: try to write EMMC partitions more reliably Nexus 4 has flash errors that manifest during large writes (eg, of the radio partition). Writes of some blocks seem to be dropped silently, without any errors being returned to the user level. Make two changes to the partition-writing code: - break it up into 1MB writes instead of writing partitions with a single fwrite() call. Pause for 50ms in between every chunk. - read the partition back after writing and verify that we read what we wrote. Drop caches before reading so we (hopefully) are reading off the actual flash and not some cache. Neither of these should be necessary. Bug: 9602014 Change-Id: Ice2e24dd4c11f1a57968277b5eb1468c772f6f63 --- applypatch/applypatch.c | 78 +++++++++++++++++++++++++++++++++++++++++++++---- applypatch/applypatch.h | 2 +- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 69f8633ab..2f134df05 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -421,18 +421,84 @@ int WriteToPartition(unsigned char* data, size_t len, break; case EMMC: - ; - FILE* f = fopen(partition, "wb"); - if (fwrite(data, 1, len, f) != len) { - printf("short write writing to %s (%s)\n", - partition, strerror(errno)); + { + size_t start = 0; + int success = 0; + FILE* f = fopen(partition, "r+b"); + if (f == NULL) { + printf("failed to open %s: %s\n", partition, strerror(errno)); return -1; } + int attempt; + + for (attempt = 0; attempt < 3; ++attempt) { + printf("write %s attempt %d start at %d\n", partition, attempt+1, start); + fseek(f, start, SEEK_SET); + while (start < len) { + size_t to_write = len - start; + if (to_write > (1<<20)) to_write = 1<<20; + + if (fwrite(data+start, 1, to_write, f) != to_write) { + printf("short write writing to %s (%s)\n", + partition, strerror(errno)); + return -1; + } + start += to_write; + if (start < len) { + usleep(50000); // 50 ms + } + } + + // drop caches so our subsequent verification read + // won't just be reading the cache. + sync(); + FILE* dc = fopen("/proc/sys/vm/drop_caches", "w"); + fwrite("3\n", 2, 1, dc); + fclose(dc); + sleep(1); + printf(" caches dropped\n"); + + // verify + fseek(f, 0, SEEK_SET); + unsigned char buffer[4096]; + start = len; + size_t p; + for (p = 0; p < len; p += sizeof(buffer)) { + size_t to_read = len - p; + if (to_read > sizeof(buffer)) to_read = sizeof(buffer); + + if (fread(buffer, 1, to_read, f) != to_read) { + printf("short verify read %s at %d: %s\n", + partition, p, strerror(errno)); + start = p; + break; + } + + if (memcmp(buffer, data+p, to_read)) { + printf("verification failed starting at %d\n", p); + start = p; + break; + } + } + + if (start == len) { + printf("verification read succeeded (attempt %d)\n", attempt+1); + success = true; + break; + } + } + + if (!success) { + printf("failed to verify after all attempts\n"); + return -1; + } + if (fclose(f) != 0) { printf("error closing %s (%s)\n", partition, strerror(errno)); return -1; } break; + } } free(copy); @@ -473,7 +539,7 @@ int ParseSha1(const char* str, uint8_t* digest) { // Search an array of sha1 strings for one matching the given sha1. // Return the index of the match on success, or -1 if no match is // found. -int FindMatchingPatch(uint8_t* sha1, const char** patch_sha1_str, +int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str, int num_patches) { int i; uint8_t patch_sha1[SHA_DIGEST_SIZE]; diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index d1a023293..f1f13a100 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -65,7 +65,7 @@ int LoadFileContents(const char* filename, FileContents* file, int retouch_flag); int SaveFileContents(const char* filename, const FileContents* file); void FreeFileContents(FileContents* file); -int FindMatchingPatch(uint8_t* sha1, const char** patch_sha1_str, +int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str, int num_patches); // bsdiff.c -- cgit v1.2.3 From c870a99c4aeb9e232ee68951e666b5fa670d1680 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 9 Jul 2013 10:34:46 -0700 Subject: recovery: write partitions more conservatively Write and verify partitions using write(2) and read(2) rather than the stdio functions. Read and write in 4kb blocks. When writing, fsync() every 1MB. Bug: 9602014 Change-Id: Ie98ce38e857786fc0f4ebf36bb5ffc93b41bc96f --- applypatch/applypatch.c | 70 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 2f134df05..3f67c32df 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -424,42 +424,50 @@ int WriteToPartition(unsigned char* data, size_t len, { size_t start = 0; int success = 0; - FILE* f = fopen(partition, "r+b"); - if (f == NULL) { + int fd = open(partition, O_RDWR); + if (fd < 0) { printf("failed to open %s: %s\n", partition, strerror(errno)); return -1; } int attempt; - for (attempt = 0; attempt < 3; ++attempt) { - printf("write %s attempt %d start at %d\n", partition, attempt+1, start); - fseek(f, start, SEEK_SET); + for (attempt = 0; attempt < 10; ++attempt) { + off_t next_sync = start + (1<<20); + printf("raw write %s attempt %d start at %d\n", partition, attempt+1, start); + lseek(fd, start, SEEK_SET); while (start < len) { size_t to_write = len - start; - if (to_write > (1<<20)) to_write = 1<<20; - - if (fwrite(data+start, 1, to_write, f) != to_write) { - printf("short write writing to %s (%s)\n", - partition, strerror(errno)); - return -1; + if (to_write > 4096) to_write = 4096; + + ssize_t written = write(fd, data+start, to_write); + if (written < 0) { + if (errno == EINTR) { + written = 0; + } else { + printf("failed write writing to %s (%s)\n", + partition, strerror(errno)); + return -1; + } } - start += to_write; - if (start < len) { - usleep(50000); // 50 ms + start += written; + if (start >= next_sync) { + fsync(fd); + next_sync = start + (1<<20); } } + fsync(fd); // drop caches so our subsequent verification read // won't just be reading the cache. sync(); - FILE* dc = fopen("/proc/sys/vm/drop_caches", "w"); - fwrite("3\n", 2, 1, dc); - fclose(dc); + int dc = open("/proc/sys/vm/drop_caches", O_WRONLY); + write(dc, "3\n", 2); + close(dc); sleep(1); printf(" caches dropped\n"); // verify - fseek(f, 0, SEEK_SET); + lseek(fd, 0, SEEK_SET); unsigned char buffer[4096]; start = len; size_t p; @@ -467,11 +475,23 @@ int WriteToPartition(unsigned char* data, size_t len, size_t to_read = len - p; if (to_read > sizeof(buffer)) to_read = sizeof(buffer); - if (fread(buffer, 1, to_read, f) != to_read) { - printf("short verify read %s at %d: %s\n", - partition, p, strerror(errno)); - start = p; - break; + size_t so_far = 0; + while (so_far < to_read) { + ssize_t read_count = read(fd, buffer+so_far, to_read-so_far); + if (read_count < 0) { + if (errno == EINTR) { + read_count = 0; + } else { + printf("verify read error %s at %d: %s\n", + partition, p, strerror(errno)); + return -1; + } + } + if (read_count < to_read) { + printf("short verify read %s at %d: %d %d %s\n", + partition, p, read_count, to_read, strerror(errno)); + } + so_far += read_count; } if (memcmp(buffer, data+p, to_read)) { @@ -486,6 +506,8 @@ int WriteToPartition(unsigned char* data, size_t len, success = true; break; } + + sleep(2); } if (!success) { @@ -493,7 +515,7 @@ int WriteToPartition(unsigned char* data, size_t len, return -1; } - if (fclose(f) != 0) { + if (close(fd) != 0) { printf("error closing %s (%s)\n", partition, strerror(errno)); return -1; } -- cgit v1.2.3 From 35c474e8c0c6dcbdb10e6065184ed4516228d9dd Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 8 Jul 2013 09:42:54 -0700 Subject: recovery: try to write EMMC partitions more reliably Nexus 4 has flash errors that manifest during large writes (eg, of the radio partition). Writes of some blocks seem to be dropped silently, without any errors being returned to the user level. Make two changes to the partition-writing code: - break it up into 1MB writes instead of writing partitions with a single fwrite() call. Pause for 50ms in between every chunk. - read the partition back after writing and verify that we read what we wrote. Drop caches before reading so we (hopefully) are reading off the actual flash and not some cache. Neither of these should be necessary. Bug: 9602014 Change-Id: Ice2e24dd4c11f1a57968277b5eb1468c772f6f63 --- applypatch/applypatch.c | 78 +++++++++++++++++++++++++++++++++++++++++++++---- applypatch/applypatch.h | 2 +- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 69f8633ab..2f134df05 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -421,18 +421,84 @@ int WriteToPartition(unsigned char* data, size_t len, break; case EMMC: - ; - FILE* f = fopen(partition, "wb"); - if (fwrite(data, 1, len, f) != len) { - printf("short write writing to %s (%s)\n", - partition, strerror(errno)); + { + size_t start = 0; + int success = 0; + FILE* f = fopen(partition, "r+b"); + if (f == NULL) { + printf("failed to open %s: %s\n", partition, strerror(errno)); return -1; } + int attempt; + + for (attempt = 0; attempt < 3; ++attempt) { + printf("write %s attempt %d start at %d\n", partition, attempt+1, start); + fseek(f, start, SEEK_SET); + while (start < len) { + size_t to_write = len - start; + if (to_write > (1<<20)) to_write = 1<<20; + + if (fwrite(data+start, 1, to_write, f) != to_write) { + printf("short write writing to %s (%s)\n", + partition, strerror(errno)); + return -1; + } + start += to_write; + if (start < len) { + usleep(50000); // 50 ms + } + } + + // drop caches so our subsequent verification read + // won't just be reading the cache. + sync(); + FILE* dc = fopen("/proc/sys/vm/drop_caches", "w"); + fwrite("3\n", 2, 1, dc); + fclose(dc); + sleep(1); + printf(" caches dropped\n"); + + // verify + fseek(f, 0, SEEK_SET); + unsigned char buffer[4096]; + start = len; + size_t p; + for (p = 0; p < len; p += sizeof(buffer)) { + size_t to_read = len - p; + if (to_read > sizeof(buffer)) to_read = sizeof(buffer); + + if (fread(buffer, 1, to_read, f) != to_read) { + printf("short verify read %s at %d: %s\n", + partition, p, strerror(errno)); + start = p; + break; + } + + if (memcmp(buffer, data+p, to_read)) { + printf("verification failed starting at %d\n", p); + start = p; + break; + } + } + + if (start == len) { + printf("verification read succeeded (attempt %d)\n", attempt+1); + success = true; + break; + } + } + + if (!success) { + printf("failed to verify after all attempts\n"); + return -1; + } + if (fclose(f) != 0) { printf("error closing %s (%s)\n", partition, strerror(errno)); return -1; } break; + } } free(copy); @@ -473,7 +539,7 @@ int ParseSha1(const char* str, uint8_t* digest) { // Search an array of sha1 strings for one matching the given sha1. // Return the index of the match on success, or -1 if no match is // found. -int FindMatchingPatch(uint8_t* sha1, const char** patch_sha1_str, +int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str, int num_patches) { int i; uint8_t patch_sha1[SHA_DIGEST_SIZE]; diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index d1a023293..f1f13a100 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -65,7 +65,7 @@ int LoadFileContents(const char* filename, FileContents* file, int retouch_flag); int SaveFileContents(const char* filename, const FileContents* file); void FreeFileContents(FileContents* file); -int FindMatchingPatch(uint8_t* sha1, const char** patch_sha1_str, +int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str, int num_patches); // bsdiff.c -- cgit v1.2.3 From c6ab95e9d17fd174df1dd07076fbf6251480ba09 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 9 Jul 2013 10:34:46 -0700 Subject: recovery: write partitions more conservatively Write and verify partitions using write(2) and read(2) rather than the stdio functions. Read and write in 4kb blocks. When writing, fsync() every 1MB. Bug: 9602014 Change-Id: Ie98ce38e857786fc0f4ebf36bb5ffc93b41bc96f --- applypatch/applypatch.c | 70 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 2f134df05..3f67c32df 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -424,42 +424,50 @@ int WriteToPartition(unsigned char* data, size_t len, { size_t start = 0; int success = 0; - FILE* f = fopen(partition, "r+b"); - if (f == NULL) { + int fd = open(partition, O_RDWR); + if (fd < 0) { printf("failed to open %s: %s\n", partition, strerror(errno)); return -1; } int attempt; - for (attempt = 0; attempt < 3; ++attempt) { - printf("write %s attempt %d start at %d\n", partition, attempt+1, start); - fseek(f, start, SEEK_SET); + for (attempt = 0; attempt < 10; ++attempt) { + off_t next_sync = start + (1<<20); + printf("raw write %s attempt %d start at %d\n", partition, attempt+1, start); + lseek(fd, start, SEEK_SET); while (start < len) { size_t to_write = len - start; - if (to_write > (1<<20)) to_write = 1<<20; - - if (fwrite(data+start, 1, to_write, f) != to_write) { - printf("short write writing to %s (%s)\n", - partition, strerror(errno)); - return -1; + if (to_write > 4096) to_write = 4096; + + ssize_t written = write(fd, data+start, to_write); + if (written < 0) { + if (errno == EINTR) { + written = 0; + } else { + printf("failed write writing to %s (%s)\n", + partition, strerror(errno)); + return -1; + } } - start += to_write; - if (start < len) { - usleep(50000); // 50 ms + start += written; + if (start >= next_sync) { + fsync(fd); + next_sync = start + (1<<20); } } + fsync(fd); // drop caches so our subsequent verification read // won't just be reading the cache. sync(); - FILE* dc = fopen("/proc/sys/vm/drop_caches", "w"); - fwrite("3\n", 2, 1, dc); - fclose(dc); + int dc = open("/proc/sys/vm/drop_caches", O_WRONLY); + write(dc, "3\n", 2); + close(dc); sleep(1); printf(" caches dropped\n"); // verify - fseek(f, 0, SEEK_SET); + lseek(fd, 0, SEEK_SET); unsigned char buffer[4096]; start = len; size_t p; @@ -467,11 +475,23 @@ int WriteToPartition(unsigned char* data, size_t len, size_t to_read = len - p; if (to_read > sizeof(buffer)) to_read = sizeof(buffer); - if (fread(buffer, 1, to_read, f) != to_read) { - printf("short verify read %s at %d: %s\n", - partition, p, strerror(errno)); - start = p; - break; + size_t so_far = 0; + while (so_far < to_read) { + ssize_t read_count = read(fd, buffer+so_far, to_read-so_far); + if (read_count < 0) { + if (errno == EINTR) { + read_count = 0; + } else { + printf("verify read error %s at %d: %s\n", + partition, p, strerror(errno)); + return -1; + } + } + if (read_count < to_read) { + printf("short verify read %s at %d: %d %d %s\n", + partition, p, read_count, to_read, strerror(errno)); + } + so_far += read_count; } if (memcmp(buffer, data+p, to_read)) { @@ -486,6 +506,8 @@ int WriteToPartition(unsigned char* data, size_t len, success = true; break; } + + sleep(2); } if (!success) { @@ -493,7 +515,7 @@ int WriteToPartition(unsigned char* data, size_t len, return -1; } - if (fclose(f) != 0) { + if (close(fd) != 0) { printf("error closing %s (%s)\n", partition, strerror(errno)); return -1; } -- cgit v1.2.3 From bf4a69ac41696fe78f6cc67b10cf1816186f1c5d Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 10 Jul 2013 13:39:50 -0700 Subject: recovery: sleep after writing partition and closing it Another speculative attempt to get everything we write actually stored to the device. Change-Id: Icf40b0741b4c535e55ea34848073a97d90dc0e70 --- applypatch/applypatch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 3f67c32df..2c62a0636 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -432,7 +432,7 @@ int WriteToPartition(unsigned char* data, size_t len, int attempt; for (attempt = 0; attempt < 10; ++attempt) { - off_t next_sync = start + (1<<20); + size_t next_sync = start + (1<<20); printf("raw write %s attempt %d start at %d\n", partition, attempt+1, start); lseek(fd, start, SEEK_SET); while (start < len) { @@ -487,7 +487,7 @@ int WriteToPartition(unsigned char* data, size_t len, return -1; } } - if (read_count < to_read) { + if ((size_t)read_count < to_read) { printf("short verify read %s at %d: %d %d %s\n", partition, p, read_count, to_read, strerror(errno)); } @@ -519,6 +519,11 @@ int WriteToPartition(unsigned char* data, size_t len, printf("error closing %s (%s)\n", partition, strerror(errno)); return -1; } + // hack: sync and sleep after closing in hopes of getting + // the data actually onto flash. + printf("sleeping after close\n"); + sync(); + sleep(5); break; } } -- cgit v1.2.3 From 166565f9fb3034f7e7f60f6614cff754d94a4078 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 10 Jul 2013 13:39:50 -0700 Subject: recovery: sleep after writing partition and closing it Another speculative attempt to get everything we write actually stored to the device. Change-Id: Icf40b0741b4c535e55ea34848073a97d90dc0e70 --- applypatch/applypatch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 3f67c32df..2c62a0636 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -432,7 +432,7 @@ int WriteToPartition(unsigned char* data, size_t len, int attempt; for (attempt = 0; attempt < 10; ++attempt) { - off_t next_sync = start + (1<<20); + size_t next_sync = start + (1<<20); printf("raw write %s attempt %d start at %d\n", partition, attempt+1, start); lseek(fd, start, SEEK_SET); while (start < len) { @@ -487,7 +487,7 @@ int WriteToPartition(unsigned char* data, size_t len, return -1; } } - if (read_count < to_read) { + if ((size_t)read_count < to_read) { printf("short verify read %s at %d: %d %d %s\n", partition, p, read_count, to_read, strerror(errno)); } @@ -519,6 +519,11 @@ int WriteToPartition(unsigned char* data, size_t len, printf("error closing %s (%s)\n", partition, strerror(errno)); return -1; } + // hack: sync and sleep after closing in hopes of getting + // the data actually onto flash. + printf("sleeping after close\n"); + sync(); + sleep(5); break; } } -- cgit v1.2.3 From e8d953aa7ed0c16beb1b03a05d16cb23dd85e198 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 11 Jul 2013 12:09:05 -0700 Subject: recovery: more cargo-cult programming Add O_DIRECT|O_SYNC when opening partitions for write. Change-Id: I9825ad8e60fba87e482f8abc5593d6f54a1e3a1c --- applypatch/applypatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 2c62a0636..60e26ede3 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -424,7 +424,7 @@ int WriteToPartition(unsigned char* data, size_t len, { size_t start = 0; int success = 0; - int fd = open(partition, O_RDWR); + int fd = open(partition, O_RDWR | O_DIRECT | O_SYNC); if (fd < 0) { printf("failed to open %s: %s\n", partition, strerror(errno)); return -1; @@ -433,7 +433,7 @@ int WriteToPartition(unsigned char* data, size_t len, for (attempt = 0; attempt < 10; ++attempt) { size_t next_sync = start + (1<<20); - printf("raw write %s attempt %d start at %d\n", partition, attempt+1, start); + printf("raw O_DIRECT write %s attempt %d start at %d\n", partition, attempt+1, start); lseek(fd, start, SEEK_SET); while (start < len) { size_t to_write = len - start; -- cgit v1.2.3 From 901b898d5e4d7cc555974b8132f83f948f8fbaee Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 11 Jul 2013 12:31:25 -0700 Subject: recovery: remove O_DIRECT, use O_SYNC only O_DIRECT writes fail with EINVAL due to alignment issues. Change-Id: If8cf38a636313e4f4b4e61e66287dc903c473e5b --- applypatch/applypatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 60e26ede3..0dcdce0b1 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -424,7 +424,7 @@ int WriteToPartition(unsigned char* data, size_t len, { size_t start = 0; int success = 0; - int fd = open(partition, O_RDWR | O_DIRECT | O_SYNC); + int fd = open(partition, O_RDWR | O_SYNC); if (fd < 0) { printf("failed to open %s: %s\n", partition, strerror(errno)); return -1; @@ -433,7 +433,7 @@ int WriteToPartition(unsigned char* data, size_t len, for (attempt = 0; attempt < 10; ++attempt) { size_t next_sync = start + (1<<20); - printf("raw O_DIRECT write %s attempt %d start at %d\n", partition, attempt+1, start); + printf("raw O_SYNC write %s attempt %d start at %d\n", partition, attempt+1, start); lseek(fd, start, SEEK_SET); while (start < len) { size_t to_write = len - start; -- cgit v1.2.3 From 94fd07ba6d911a446d1d419ad188cbeccc76129a Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 26 Aug 2013 16:45:33 -0700 Subject: Update libpng API usage Remove usage of deprecated methods Change-Id: I747568a2c8c0c65ecbc9a3da4bac7b9cac7708ab --- minui/resources.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/minui/resources.c b/minui/resources.c index 72f39fbaa..c0a9ccacb 100644 --- a/minui/resources.c +++ b/minui/resources.c @@ -93,9 +93,13 @@ int res_create_surface(const char* name, gr_surface* pSurface) { png_set_sig_bytes(png_ptr, sizeof(header)); png_read_info(png_ptr, info_ptr); - int color_type = info_ptr->color_type; - int bit_depth = info_ptr->bit_depth; - int channels = info_ptr->channels; + int color_type, bit_depth; + size_t width, height; + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, + &color_type, NULL, NULL, NULL); + + int channels = png_get_channels(png_ptr, info_ptr); + if (!(bit_depth == 8 && ((channels == 3 && color_type == PNG_COLOR_TYPE_RGB) || (channels == 4 && color_type == PNG_COLOR_TYPE_RGBA) || @@ -105,8 +109,6 @@ int res_create_surface(const char* name, gr_surface* pSurface) { goto exit; } - size_t width = info_ptr->width; - size_t height = info_ptr->height; size_t stride = (color_type == PNG_COLOR_TYPE_GRAY ? 1 : 4) * width; size_t pixelSize = stride * height; @@ -246,13 +248,11 @@ int res_create_localized_surface(const char* name, gr_surface* pSurface) { png_set_sig_bytes(png_ptr, sizeof(header)); png_read_info(png_ptr, info_ptr); - size_t width = info_ptr->width; - size_t height = info_ptr->height; - size_t stride = 4 * width; - - int color_type = info_ptr->color_type; - int bit_depth = info_ptr->bit_depth; - int channels = info_ptr->channels; + int color_type, bit_depth; + size_t width, height; + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, + &color_type, NULL, NULL, NULL); + int channels = png_get_channels(png_ptr, info_ptr); if (!(bit_depth == 8 && (channels == 1 && color_type == PNG_COLOR_TYPE_GRAY))) { -- cgit v1.2.3