From 0f3e75d8c63b6c3eedef9dd2f67a5810da3a35ca Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 7 Aug 2015 22:22:45 -0700 Subject: updater: Switch to C++ and fix the build. Change-Id: I632201f74b26685cb7a5b3e75ef50163e8973308 --- recovery/Android.mk | 2 +- recovery/lib/downloadFN.h | 8 +++++ recovery/recovery_updater.c | 68 ------------------------------------------- recovery/recovery_updater.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 69 deletions(-) mode change 100755 => 100644 recovery/lib/downloadFN.h delete mode 100644 recovery/recovery_updater.c create mode 100644 recovery/recovery_updater.cpp diff --git a/recovery/Android.mk b/recovery/Android.mk index 9475448..46fc7a3 100644 --- a/recovery/Android.mk +++ b/recovery/Android.mk @@ -21,7 +21,7 @@ LOCAL_MODULE_TAGS := eng LOCAL_C_INCLUDES += bootable/recovery \ device/asus/tilapia/recovery/lib -LOCAL_SRC_FILES := recovery_updater.c +LOCAL_SRC_FILES := recovery_updater.cpp LOCAL_STATIC_LIBRARIES := libIMCdownload libPrgHandler diff --git a/recovery/lib/downloadFN.h b/recovery/lib/downloadFN.h old mode 100755 new mode 100644 index b8cb0a7..a8a2f63 --- a/recovery/lib/downloadFN.h +++ b/recovery/lib/downloadFN.h @@ -1,6 +1,10 @@ #ifndef _DOWNLOADFN_H #define _DOWNLOADFN_H +#ifdef __cplusplus +extern "C" { +#endif + void SetBaudrate(int baudrate); void SetComPort(char *comport); void SetTraceFile(char *filepath); @@ -9,4 +13,8 @@ void SetHighPerformance(); void ResetModem(); int DownloadFiles(char* file); +#ifdef __cplusplus +} +#endif + #endif diff --git a/recovery/recovery_updater.c b/recovery/recovery_updater.c deleted file mode 100644 index d75ac0b..0000000 --- a/recovery/recovery_updater.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cutils/misc.h" -#include "cutils/properties.h" -#include "edify/expr.h" -#include "mincrypt/sha.h" -#include "minzip/DirUtil.h" -#include "mtdutils/mounts.h" -#include "mtdutils/mtdutils.h" -#include "downloadFN.h" - -Value* DownloadModemFn(const char* name, State* state, int argc, Expr* argv[]) { - - char* modemImg; - int result = -1; - - if (argc != 1) - return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); - - if (ReadArgs(state, argv, 1, &modemImg) != 0) { - return NULL; - } - - printf("DownloadModemFn: %s\n", modemImg); - - result = DownloadFiles(modemImg); - - if (result < 0) { - printf("Download failed!\n"); - } else { - printf("Download success!\n"); - ResetModem(); - sleep(6); - } - return StringValue(strdup(result >= 0 ? "t" : "")); -} - -void Register_librecovery_updater_tilapia() { - printf("Register_librecovery_updater_tilapia is called\n"); - RegisterFunction("bach.update_modem", DownloadModemFn); -} diff --git a/recovery/recovery_updater.cpp b/recovery/recovery_updater.cpp new file mode 100644 index 0000000..d75ac0b --- /dev/null +++ b/recovery/recovery_updater.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cutils/misc.h" +#include "cutils/properties.h" +#include "edify/expr.h" +#include "mincrypt/sha.h" +#include "minzip/DirUtil.h" +#include "mtdutils/mounts.h" +#include "mtdutils/mtdutils.h" +#include "downloadFN.h" + +Value* DownloadModemFn(const char* name, State* state, int argc, Expr* argv[]) { + + char* modemImg; + int result = -1; + + if (argc != 1) + return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); + + if (ReadArgs(state, argv, 1, &modemImg) != 0) { + return NULL; + } + + printf("DownloadModemFn: %s\n", modemImg); + + result = DownloadFiles(modemImg); + + if (result < 0) { + printf("Download failed!\n"); + } else { + printf("Download success!\n"); + ResetModem(); + sleep(6); + } + return StringValue(strdup(result >= 0 ? "t" : "")); +} + +void Register_librecovery_updater_tilapia() { + printf("Register_librecovery_updater_tilapia is called\n"); + RegisterFunction("bach.update_modem", DownloadModemFn); +} -- cgit v1.2.3