From 3305d48b0be5c6d1578e04e9835c236335a40a9f Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 26 Sep 2019 00:02:29 -0700 Subject: minadbd: Export minadbd/types.h to libinstall. Test: mmma bootable/recovery Change-Id: I503e942b23cc51024aa752c1eb3db5455a44a9d1 --- install/Android.bp | 8 ++--- install/adb_install.cpp | 2 +- minadbd/Android.bp | 11 +++++-- minadbd/include/minadbd/types.h | 64 +++++++++++++++++++++++++++++++++++++++ minadbd/minadbd.cpp | 2 +- minadbd/minadbd_services.cpp | 2 +- minadbd/minadbd_services_test.cpp | 2 +- minadbd/minadbd_types.h | 64 --------------------------------------- 8 files changed, 81 insertions(+), 74 deletions(-) create mode 100644 minadbd/include/minadbd/types.h delete mode 100644 minadbd/minadbd_types.h diff --git a/install/Android.bp b/install/Android.bp index 89cc3f23e..78c3a5784 100644 --- a/install/Android.bp +++ b/install/Android.bp @@ -19,10 +19,6 @@ cc_defaults { "recovery_defaults", ], - header_libs: [ - "libminadbd_headers", - ], - shared_libs: [ "libbase", "libbootloader_message", @@ -69,6 +65,10 @@ cc_library_static { "wipe_device.cpp", ], + header_libs: [ + "libminadbd_headers", + ], + shared_libs: [ "librecovery_ui", ], diff --git a/install/adb_install.cpp b/install/adb_install.cpp index ed664429a..ee79a32c0 100644 --- a/install/adb_install.cpp +++ b/install/adb_install.cpp @@ -44,7 +44,7 @@ #include "fuse_sideload.h" #include "install/install.h" #include "install/wipe_data.h" -#include "minadbd_types.h" +#include "minadbd/types.h" #include "otautil/sysutil.h" #include "recovery_ui/device.h" #include "recovery_ui/ui.h" diff --git a/minadbd/Android.bp b/minadbd/Android.bp index 805d12af3..071712599 100644 --- a/minadbd/Android.bp +++ b/minadbd/Android.bp @@ -26,6 +26,10 @@ cc_defaults { include_dirs: [ "system/core/adb", ], + + header_libs: [ + "libminadbd_headers", + ], } // `libminadbd_services` is analogous to the `libadbd_services` for regular `adbd`, but providing @@ -58,9 +62,12 @@ cc_library { cc_library_headers { name: "libminadbd_headers", recovery_available: true, - // TODO create a include dir export_include_dirs: [ - ".", + "include", + ], + // adb_install.cpp + visibility: [ + "//bootable/recovery/install", ], } diff --git a/minadbd/include/minadbd/types.h b/minadbd/include/minadbd/types.h new file mode 100644 index 000000000..002523f1f --- /dev/null +++ b/minadbd/include/minadbd/types.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2019 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. + */ + +#pragma once + +#include + +// The message between recovery and minadbd is 8 bytes in size unless the length is explicitly +// specified. Both the command and status has the format |prefix(4 bytes) + encoded enum(4 bytes)|. +constexpr size_t kMinadbdMessageSize = 8; +constexpr char const kMinadbdCommandPrefix[] = "COMD"; +constexpr char const kMinadbdStatusPrefix[] = "STAT"; + +enum MinadbdErrorCode : int { + kMinadbdSuccess = 0, + kMinadbdArgumentsParsingError = 1, + kMinadbdSocketIOError = 2, + kMinadbdMessageFormatError = 3, + kMinadbdAdbVersionError = 4, + kMinadbdHostCommandArgumentError = 5, + kMinadbdFuseStartError = 6, + kMinadbdUnsupportedCommandError = 7, + kMinadbdCommandExecutionError = 8, + kMinadbdErrorUnknown = 9, + kMinadbdHostSocketIOError = 10, +}; + +enum class MinadbdCommandStatus : uint32_t { + kSuccess = 0, + kFailure = 1, +}; + +enum class MinadbdCommand : uint32_t { + kInstall = 0, + kUiPrint = 1, + kRebootAndroid = 2, + kRebootBootloader = 3, + kRebootFastboot = 4, + kRebootRecovery = 5, + kRebootRescue = 6, + kWipeCache = 7, + kWipeData = 8, + kNoOp = 9, + + // Last but invalid command. + kError, +}; + +static_assert(kMinadbdMessageSize == sizeof(kMinadbdCommandPrefix) - 1 + sizeof(MinadbdCommand)); +static_assert(kMinadbdMessageSize == + sizeof(kMinadbdStatusPrefix) - 1 + sizeof(MinadbdCommandStatus)); diff --git a/minadbd/minadbd.cpp b/minadbd/minadbd.cpp index c80d5490a..7b82faa05 100644 --- a/minadbd/minadbd.cpp +++ b/minadbd/minadbd.cpp @@ -28,8 +28,8 @@ #include "adb_auth.h" #include "transport.h" +#include "minadbd/types.h" #include "minadbd_services.h" -#include "minadbd_types.h" using namespace std::string_literals; diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index c31afbe06..cabcdaa09 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -43,7 +43,7 @@ #include "adb_utils.h" #include "fuse_adb_provider.h" #include "fuse_sideload.h" -#include "minadbd_types.h" +#include "minadbd/types.h" #include "services.h" #include "sysdeps.h" diff --git a/minadbd/minadbd_services_test.cpp b/minadbd/minadbd_services_test.cpp index f87873792..b694a57d1 100644 --- a/minadbd/minadbd_services_test.cpp +++ b/minadbd/minadbd_services_test.cpp @@ -35,8 +35,8 @@ #include "adb_io.h" #include "fuse_adb_provider.h" #include "fuse_sideload.h" +#include "minadbd/types.h" #include "minadbd_services.h" -#include "minadbd_types.h" #include "socket.h" class MinadbdServicesTest : public ::testing::Test { diff --git a/minadbd/minadbd_types.h b/minadbd/minadbd_types.h deleted file mode 100644 index 002523f1f..000000000 --- a/minadbd/minadbd_types.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#pragma once - -#include - -// The message between recovery and minadbd is 8 bytes in size unless the length is explicitly -// specified. Both the command and status has the format |prefix(4 bytes) + encoded enum(4 bytes)|. -constexpr size_t kMinadbdMessageSize = 8; -constexpr char const kMinadbdCommandPrefix[] = "COMD"; -constexpr char const kMinadbdStatusPrefix[] = "STAT"; - -enum MinadbdErrorCode : int { - kMinadbdSuccess = 0, - kMinadbdArgumentsParsingError = 1, - kMinadbdSocketIOError = 2, - kMinadbdMessageFormatError = 3, - kMinadbdAdbVersionError = 4, - kMinadbdHostCommandArgumentError = 5, - kMinadbdFuseStartError = 6, - kMinadbdUnsupportedCommandError = 7, - kMinadbdCommandExecutionError = 8, - kMinadbdErrorUnknown = 9, - kMinadbdHostSocketIOError = 10, -}; - -enum class MinadbdCommandStatus : uint32_t { - kSuccess = 0, - kFailure = 1, -}; - -enum class MinadbdCommand : uint32_t { - kInstall = 0, - kUiPrint = 1, - kRebootAndroid = 2, - kRebootBootloader = 3, - kRebootFastboot = 4, - kRebootRecovery = 5, - kRebootRescue = 6, - kWipeCache = 7, - kWipeData = 8, - kNoOp = 9, - - // Last but invalid command. - kError, -}; - -static_assert(kMinadbdMessageSize == sizeof(kMinadbdCommandPrefix) - 1 + sizeof(MinadbdCommand)); -static_assert(kMinadbdMessageSize == - sizeof(kMinadbdStatusPrefix) - 1 + sizeof(MinadbdCommandStatus)); -- cgit v1.2.3