From 5e5e334b3beacd56004310514bd565cd0a40d92a Mon Sep 17 00:00:00 2001 From: Lennart Wieboldt Date: Tue, 25 Jul 2017 21:48:39 +0200 Subject: Remove LOCAL_CLANG clang is the default compiler since Android nougat Change-Id: I930bba431dc49970cb4491ed5fcf44b5e00e97df Signed-off-by: Lennart Wieboldt --- minadbd/Android.mk | 2 -- 1 file changed, 2 deletions(-) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index de0b0c890..8d86fd653 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -15,7 +15,6 @@ LOCAL_SRC_FILES := \ minadbd.cpp \ minadbd_services.cpp \ -LOCAL_CLANG := true LOCAL_MODULE := libminadbd LOCAL_CFLAGS := $(minadbd_cflags) LOCAL_CONLY_FLAGS := -Wimplicit-function-declaration @@ -27,7 +26,6 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_CLANG := true LOCAL_MODULE := minadbd_test LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_SRC_FILES := fuse_adb_provider_test.cpp -- cgit v1.2.3 From 99f0d9e52bdbe314d77300f883d66e4470d4a5ee Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 13 Oct 2016 12:46:38 -0700 Subject: Drop -Wno-unused-parameter. The only one left is libedify. Will handle that in a separate CL. Test: mmma bootable/recovery Change-Id: I732a5f85229da90fd767bee2e46c5c95f529c396 --- minadbd/Android.mk | 17 ++++++++++++++++- minadbd/minadbd_services.cpp | 30 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 16 deletions(-) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index 8d86fd653..803171d99 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -1,13 +1,26 @@ # Copyright 2005 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) minadbd_cflags := \ -Wall -Werror \ - -Wno-unused-parameter \ -Wno-missing-field-initializers \ -DADB_HOST=0 \ +# libadbd (static library) +# =============================== include $(CLEAR_VARS) LOCAL_SRC_FILES := \ @@ -24,6 +37,8 @@ LOCAL_STATIC_LIBRARIES := libcrypto libbase include $(BUILD_STATIC_LIBRARY) +# minadbd_test (native test) +# =============================== include $(CLEAR_VARS) LOCAL_MODULE := minadbd_test diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 61c06cc0a..9f0f1f87d 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -58,20 +58,20 @@ static int create_service_thread(void (*func)(int, const std::string&), const st return s[0]; } -int service_to_fd(const char* name, const atransport* transport) { - int ret = -1; +int service_to_fd(const char* name, const atransport* /* transport */) { + int ret = -1; - if (!strncmp(name, "sideload:", 9)) { - // this exit status causes recovery to print a special error - // message saying to use a newer adb (that supports - // sideload-host). - exit(3); - } else if (!strncmp(name, "sideload-host:", 14)) { - std::string arg(name + 14); - ret = create_service_thread(sideload_host_service, arg); - } - if (ret >= 0) { - close_on_exec(ret); - } - return ret; + if (!strncmp(name, "sideload:", 9)) { + // this exit status causes recovery to print a special error + // message saying to use a newer adb (that supports + // sideload-host). + exit(3); + } else if (!strncmp(name, "sideload-host:", 14)) { + std::string arg(name + 14); + ret = create_service_thread(sideload_host_service, arg); + } + if (ret >= 0) { + close_on_exec(ret); + } + return ret; } -- cgit v1.2.3 From a88cc5440ed79a0927f57bbd03377ff3ce04a760 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 25 Oct 2017 13:16:54 -0700 Subject: Switch to bionic gtest in bootable/recovery We encountered segfaults in Imgdiff host tests due to the failure to reset states of getopt. The problem can be solved by switching to use bionic's gtest where a new process is forked for each test. Also modify the recovery_component_test to make sure it runs in parallel. Changes include: 1. Merge the writes to misc partition into one single test. 2. Change the hard coded location "/cache/saved.file" into a configurable variable. Bug: 67849209 Test: recovery tests pass Change-Id: I165d313f32b83393fb7922c5078636ac40b50bc2 --- minadbd/Android.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index 803171d99..3c9ab3a7f 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -46,7 +46,12 @@ LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_SRC_FILES := fuse_adb_provider_test.cpp LOCAL_CFLAGS := $(minadbd_cflags) LOCAL_C_INCLUDES := $(LOCAL_PATH) system/core/adb -LOCAL_STATIC_LIBRARIES := libminadbd -LOCAL_SHARED_LIBRARIES := liblog libbase libcutils +LOCAL_STATIC_LIBRARIES := \ + libBionicGtestMain \ + libminadbd +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libbase \ + libcutils include $(BUILD_NATIVE_TEST) -- cgit v1.2.3 From 91a7aa4577feb5f80038a30d15765e8b79845cf1 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 1 May 2017 15:57:38 -0700 Subject: Clean up fuse_sideload and add a testcase. This CL mainly changes: a) moving the interface in struct provider_vtab to std::function; b) code cleanup, such as moving the declaration closer to the uses, using explicit type conversion. Test: recovery_component_test Test: minadbd_test Test: Sideload a package on marlin. Change-Id: Id0e3c70f1ada54a4cd985b54c84438c23ed4687e --- minadbd/fuse_adb_provider.cpp | 53 ++++++++++++++++++-------------------- minadbd/fuse_adb_provider.h | 8 +++--- minadbd/fuse_adb_provider_test.cpp | 6 ++--- 3 files changed, 32 insertions(+), 35 deletions(-) (limited to 'minadbd') diff --git a/minadbd/fuse_adb_provider.cpp b/minadbd/fuse_adb_provider.cpp index 0f4c2563d..9bd3f2392 100644 --- a/minadbd/fuse_adb_provider.cpp +++ b/minadbd/fuse_adb_provider.cpp @@ -14,46 +14,43 @@ * limitations under the License. */ -#include +#include "fuse_adb_provider.h" + +#include #include +#include #include -#include + +#include #include "adb.h" #include "adb_io.h" -#include "fuse_adb_provider.h" #include "fuse_sideload.h" -int read_block_adb(void* data, uint32_t block, uint8_t* buffer, uint32_t fetch_size) { - adb_data* ad = reinterpret_cast(data); - - if (!WriteFdFmt(ad->sfd, "%08u", block)) { - fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno)); - return -EIO; - } +int read_block_adb(const adb_data& ad, uint32_t block, uint8_t* buffer, uint32_t fetch_size) { + if (!WriteFdFmt(ad.sfd, "%08u", block)) { + fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno)); + return -EIO; + } - if (!ReadFdExactly(ad->sfd, buffer, fetch_size)) { - fprintf(stderr, "failed to read from adb host: %s\n", strerror(errno)); - return -EIO; - } - - return 0; -} + if (!ReadFdExactly(ad.sfd, buffer, fetch_size)) { + fprintf(stderr, "failed to read from adb host: %s\n", strerror(errno)); + return -EIO; + } -static void close_adb(void* data) { - adb_data* ad = reinterpret_cast(data); - WriteFdExactly(ad->sfd, "DONEDONE"); + return 0; } int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size) { - adb_data ad; - ad.sfd = sfd; - ad.file_size = file_size; - ad.block_size = block_size; + adb_data ad; + ad.sfd = sfd; + ad.file_size = file_size; + ad.block_size = block_size; - provider_vtab vtab; - vtab.read_block = read_block_adb; - vtab.close = close_adb; + provider_vtab vtab; + vtab.read_block = std::bind(read_block_adb, ad, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3); + vtab.close = [&ad]() { WriteFdExactly(ad.sfd, "DONEDONE"); }; - return run_fuse_sideload(&vtab, &ad, file_size, block_size); + return run_fuse_sideload(vtab, file_size, block_size); } diff --git a/minadbd/fuse_adb_provider.h b/minadbd/fuse_adb_provider.h index 9941709b9..36d86d539 100644 --- a/minadbd/fuse_adb_provider.h +++ b/minadbd/fuse_adb_provider.h @@ -20,13 +20,13 @@ #include struct adb_data { - int sfd; // file descriptor for the adb channel + int sfd; // file descriptor for the adb channel - uint64_t file_size; - uint32_t block_size; + uint64_t file_size; + uint32_t block_size; }; -int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer, uint32_t fetch_size); +int read_block_adb(const adb_data& ad, uint32_t block, uint8_t* buffer, uint32_t fetch_size); int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size); #endif diff --git a/minadbd/fuse_adb_provider_test.cpp b/minadbd/fuse_adb_provider_test.cpp index 31be2a64e..00250e505 100644 --- a/minadbd/fuse_adb_provider_test.cpp +++ b/minadbd/fuse_adb_provider_test.cpp @@ -46,8 +46,8 @@ TEST(fuse_adb_provider, read_block_adb) { uint32_t block = 1234U; const char expected_block[] = "00001234"; - ASSERT_EQ(0, read_block_adb(static_cast(&data), block, - reinterpret_cast(block_data), sizeof(expected_data) - 1)); + ASSERT_EQ(0, read_block_adb(data, block, reinterpret_cast(block_data), + sizeof(expected_data) - 1)); // Check that read_block_adb requested the right block. char block_req[sizeof(expected_block)] = {}; @@ -84,7 +84,7 @@ TEST(fuse_adb_provider, read_block_adb_fail_write) { signal(SIGPIPE, SIG_IGN); char buf[1]; - ASSERT_EQ(-EIO, read_block_adb(static_cast(&data), 0, reinterpret_cast(buf), 1)); + ASSERT_EQ(-EIO, read_block_adb(data, 0, reinterpret_cast(buf), 1)); close(sockets[0]); } -- cgit v1.2.3 From f87d20404d624418d7b259f45b32831e54d31ba4 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 15 Nov 2017 11:26:06 -0800 Subject: minadbd: Remove two warning options. '-Wimplicit-function-declaration' is not needed (it's for C89) and already enabled by -Wall. For '-Wno-missing-field-initializers', don't see any existing case that requires the flag. Test: `mmma -j bootable/recovery` on aosp_{bullhead,marlin}-userdebug. Change-Id: I46604723087ed9a7747f6cae31a95fc0074c6758 --- minadbd/Android.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index 3c9ab3a7f..50e3b34ef 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -16,10 +16,9 @@ LOCAL_PATH:= $(call my-dir) minadbd_cflags := \ -Wall -Werror \ - -Wno-missing-field-initializers \ -DADB_HOST=0 \ -# libadbd (static library) +# libminadbd (static library) # =============================== include $(CLEAR_VARS) @@ -30,7 +29,6 @@ LOCAL_SRC_FILES := \ LOCAL_MODULE := libminadbd LOCAL_CFLAGS := $(minadbd_cflags) -LOCAL_CONLY_FLAGS := -Wimplicit-function-declaration LOCAL_C_INCLUDES := bootable/recovery system/core/adb LOCAL_WHOLE_STATIC_LIBRARIES := libadbd LOCAL_STATIC_LIBRARIES := libcrypto libbase -- cgit v1.2.3 From 84c82a8142517f30040bf16bed045eb3b309e967 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Fri, 13 Apr 2018 16:08:01 -0700 Subject: minadbd: track signature change of service_to_fd. Bug: http://b/37066218 Bug: http://b/71898863 Test: treehugger Change-Id: I5f2b14c65cff8d41dd3230d78b87e3e27e489bf6 (cherry picked from commit 570b08b7904901162ae2d4c847b19c1aa9738aaf) --- minadbd/minadbd_services.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minadbd') diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 9f0f1f87d..043c51a6a 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -58,7 +58,7 @@ static int create_service_thread(void (*func)(int, const std::string&), const st return s[0]; } -int service_to_fd(const char* name, const atransport* /* transport */) { +int service_to_fd(const char* name, atransport* /* transport */) { int ret = -1; if (!strncmp(name, "sideload:", 9)) { -- cgit v1.2.3