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
This commit is contained in:
@@ -18,13 +18,13 @@
|
|||||||
#define RECOVERY_COMMON_H
|
#define RECOVERY_COMMON_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: restore ui_print for LOGE
|
#define LOGE(...) ui_print("E:" __VA_ARGS__)
|
||||||
#define LOGE(...) fprintf(stdout, "E:" __VA_ARGS__)
|
|
||||||
#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
|
#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
|
||||||
#define LOGI(...) fprintf(stdout, "I:" __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.
|
// fopen a file, mounting volumes and making parent dirs as necessary.
|
||||||
FILE* fopen_path(const char *path, const char *mode);
|
FILE* fopen_path(const char *path, const char *mode);
|
||||||
|
|
||||||
|
void ui_print(const char* format, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+33
-2
@@ -15,11 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -27,7 +29,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#include "bootloader.h"
|
#include "bootloader.h"
|
||||||
#include "common.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
|
int
|
||||||
main(int argc, char **argv) {
|
main(int argc, char **argv) {
|
||||||
time_t start = time(NULL);
|
time_t start = time(NULL);
|
||||||
@@ -856,6 +875,7 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
Device* device = make_device();
|
Device* device = make_device();
|
||||||
ui = device->GetUI();
|
ui = device->GetUI();
|
||||||
|
gCurrentUI = ui;
|
||||||
|
|
||||||
ui->Init();
|
ui->Init();
|
||||||
ui->SetLocale(locale);
|
ui->SetLocale(locale);
|
||||||
@@ -909,7 +929,18 @@ main(int argc, char **argv) {
|
|||||||
LOGE("Cache wipe (requested by package) failed.");
|
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) {
|
} else if (wipe_data) {
|
||||||
if (device->WipeData()) status = INSTALL_ERROR;
|
if (device->WipeData()) status = INSTALL_ERROR;
|
||||||
if (erase_volume("/data")) status = INSTALL_ERROR;
|
if (erase_volume("/data")) status = INSTALL_ERROR;
|
||||||
|
|||||||
+10
-4
@@ -18,6 +18,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "verifier.h"
|
#include "verifier.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
@@ -113,13 +114,10 @@ class FakeUI : public RecoveryUI {
|
|||||||
bool IsTextVisible() { return false; }
|
bool IsTextVisible() { return false; }
|
||||||
bool WasTextEverVisible() { return false; }
|
bool WasTextEverVisible() { return false; }
|
||||||
void Print(const char* fmt, ...) {
|
void Print(const char* fmt, ...) {
|
||||||
char buf[256];
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(buf, 256, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
fputs(buf, stderr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenu(const char* const * headers, const char* const * items,
|
void StartMenu(const char* const * headers, const char* const * items,
|
||||||
@@ -128,6 +126,14 @@ class FakeUI : public RecoveryUI {
|
|||||||
void EndMenu() { }
|
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) {
|
int main(int argc, char **argv) {
|
||||||
if (argc < 2 || argc > 4) {
|
if (argc < 2 || argc > 4) {
|
||||||
fprintf(stderr, "Usage: %s [-f4 | -file <keys>] <package>\n", argv[0]);
|
fprintf(stderr, "Usage: %s [-f4 | -file <keys>] <package>\n", argv[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user