diff options
| author | ZjemCiKolege <frager1911@gmail.com> | 2017-09-08 20:27:04 +0000 |
|---|---|---|
| committer | Dan Pasanen <dan.pasanen@gmail.com> | 2018-02-05 10:22:53 -0600 |
| commit | 42d703a63f9f3f987cf85694a488e5dbfc5bb801 (patch) | |
| tree | f2025787adc23a143c4dcddb5feca65d81501809 | |
| parent | 04aa84d534c96f92f984e0de0d2039c764e7f4c4 (diff) | |
recovery: update for O compatability
Change-Id: I9cb7762c2e124514cc0d6c9fb8ffcdfda914f086
| -rw-r--r-- | recovery/Android.mk | 5 | ||||
| -rw-r--r-- | recovery/recovery_updater.cpp | 42 |
2 files changed, 20 insertions, 27 deletions
diff --git a/recovery/Android.mk b/recovery/Android.mk index c4c5495..4ed459d 100644 --- a/recovery/Android.mk +++ b/recovery/Android.mk @@ -1,8 +1,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_C_INCLUDES := bootable/recovery +LOCAL_C_INCLUDES := $(call project-path-for,recovery) \ +$(call project-path-for,recovery)/updater/include LOCAL_SRC_FILES := recovery_updater.cpp LOCAL_MODULE := librecovery_updater_g3 LOCAL_MODULE_TAGS := eng -include $(BUILD_STATIC_LIBRARY) +include $(BUILD_STATIC_LIBRARY)
\ No newline at end of file diff --git a/recovery/recovery_updater.cpp b/recovery/recovery_updater.cpp index 84ffa32..0a0c064 100644 --- a/recovery/recovery_updater.cpp +++ b/recovery/recovery_updater.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2015, The CyanogenMod Project + * Copyright (C) 2017, The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +25,9 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> - +#include <string> +#include <vector> #include "edify/expr.h" -#include "updater/install.h" #define MAX(a, b) (((a) > (b)) ? (a) : (b)) @@ -151,37 +152,28 @@ err_ret: } /* verify_baseband("BASEBAND_VERSION", "BASEBAND_VERSION", ...) */ -Value * VerifyBasebandFn(const char *name, State *state, int argc, Expr *argv[]) { +Value * VerifyBasebandFn(const char *name, State *state, + const std::vector<std::unique_ptr<Expr>>& argv) { char current_baseband_version[BASEBAND_VER_BUF_LEN]; - char *baseband_string; - char *baseband_version; - char *baseband_short_version; - int i, ret; + int ret; ret = get_baseband_version(current_baseband_version, BASEBAND_VER_BUF_LEN); if (ret) { - return ErrorAbort(state, "%s() failed to read current BASEBAND version: %d", + return ErrorAbort(state, kFreadFailure, "%s() failed to read current baseband version: %d", name, ret); } - - for (i = 0; i < argc; i++) { - baseband_string = Evaluate(state, argv[i]); - if (baseband_string < 0) { - return ErrorAbort(state, "%s() error parsing arguments: %d", - name, baseband_string); - } - - baseband_short_version = strtok(baseband_string, ":"); - baseband_version = strtok(NULL, ":"); - - uiPrintf(state, "Checking for BASEBAND version %s", baseband_short_version); - if (strncmp(baseband_version, current_baseband_version, strlen(baseband_version)) == 0) { - return StringValue(strdup("1")); + std::vector<std::string> args; + if (!ReadArgs(state, argv, &args)) { + return ErrorAbort(state, kArgsParsingFailure, "%s() error parsing arguments", name); + } + ret = 0; + for (auto& baseband_version : args) { + if (strncmp(baseband_version.c_str(), current_baseband_version, strlen(baseband_version.c_str())) == 0) { + ret = 1; + break; } } - - uiPrintf(state, "ERROR: It appears you are running an unsupported baseband."); - return StringValue(strdup("0")); + return StringValue(strdup(ret ? "1" : "0")); } void Register_librecovery_updater_g3() { |
