diff options
3 files changed, 236 insertions, 0 deletions
diff --git a/dynamic-layers/selinux/android-tools/android-tools/adbd.mk b/dynamic-layers/selinux/android-tools/android-tools/adbd.mk new file mode 100644 index 0000000..cb82683 --- /dev/null +++ b/dynamic-layers/selinux/android-tools/android-tools/adbd.mk | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | include ../../rules_yocto.mk | ||
| 2 | NAME = adbd | ||
| 3 | |||
| 4 | SOURCES = \ | ||
| 5 | adb/daemon/main.cpp \ | ||
| 6 | adb/daemon/auth.cpp \ | ||
| 7 | adb/daemon/jdwp_service.cpp \ | ||
| 8 | adb/daemon/file_sync_service.cpp \ | ||
| 9 | adb/daemon/services.cpp \ | ||
| 10 | adb/daemon/shell_service.cpp \ | ||
| 11 | adb/daemon/remount_service.cpp \ | ||
| 12 | adb/daemon/restart_service.cpp \ | ||
| 13 | adb/daemon/reboot_service.cpp \ | ||
| 14 | adb/daemon/framebuffer_service.cpp \ | ||
| 15 | adb/daemon/set_verity_enable_state_service.cpp \ | ||
| 16 | adb/shell_service_protocol.cpp \ | ||
| 17 | adb/adb.cpp \ | ||
| 18 | adb/adb_io.cpp \ | ||
| 19 | adb/adb_listeners.cpp \ | ||
| 20 | adb/adb_trace.cpp \ | ||
| 21 | adb/adb_unique_fd.cpp \ | ||
| 22 | adb/adb_utils.cpp \ | ||
| 23 | adb/fdevent.cpp \ | ||
| 24 | adb/services.cpp \ | ||
| 25 | adb/sockets.cpp \ | ||
| 26 | adb/socket_spec.cpp \ | ||
| 27 | adb/sysdeps/errno.cpp \ | ||
| 28 | adb/transport.cpp \ | ||
| 29 | adb/transport_fd.cpp \ | ||
| 30 | adb/transport_local.cpp \ | ||
| 31 | adb/transport_usb.cpp \ | ||
| 32 | adb/sysdeps_unix.cpp \ | ||
| 33 | adb/sysdeps/posix/network.cpp \ | ||
| 34 | adb/daemon/usb_legacy.cpp \ | ||
| 35 | adb/daemon/usb_ffs.cpp \ | ||
| 36 | adb/daemon/usb.cpp \ | ||
| 37 | diagnose_usb/diagnose_usb.cpp \ | ||
| 38 | libasyncio/AsyncIO.cpp \ | ||
| 39 | |||
| 40 | CXXFLAGS += -std=gnu++20 | ||
| 41 | CPPFLAGS += -Iinclude -Iadb -Ibase/include -I$(OUT_DIR)/usr/include/ -Imkbootimg/include/bootimg -Ifs_mgr/include \ | ||
| 42 | -Ifs_mgr/include_fstab \ | ||
| 43 | -DADB_VERSION='"$(DEB_VERSION)"' -D_GNU_SOURCE | ||
| 44 | LDFLAGS += -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android -Wl,-rpath-link=$(OUT_DIR)/usr/lib/$(DEB_HOST_MULTIARCH)/android/ \ | ||
| 45 | -lpthread -L$(OUT_DIR)/usr/lib/$(DEB_HOST_MULTIARCH)/android/ -lbase -lcrypto_utils -lcrypto -lcutils -llog -lresolv | ||
| 46 | |||
| 47 | PAGE_SIZE ?= 4096 | ||
| 48 | |||
| 49 | CXXFLAGS += -UADB_HOST | ||
| 50 | CXXFLAGS += -DADB_HOST=0 | ||
| 51 | CXXFLAGS += -DALLOW_ADBD_DISABLE_VERITY | ||
| 52 | CXXFLAGS += -DALLOW_ADBD_NO_AUTH | ||
| 53 | CXXFLAGS += -DPLATFORM_TOOLS_VERSION='"28.0.2"' | ||
| 54 | CXXFLAGS += -Idiagnose_usb/include | ||
| 55 | CXXFLAGS += -Iadb/daemon/include | ||
| 56 | CXXFLAGS += -Ilibasyncio/include | ||
| 57 | CXXFLAGS += -Wno-c++11-narrowing | ||
| 58 | CXXFLAGS += -DPAGE_SIZE=$(PAGE_SIZE) | ||
| 59 | |||
| 60 | |||
| 61 | # -latomic should be the last library specified | ||
| 62 | # https://github.com/android/ndk/issues/589 | ||
| 63 | ifneq ($(filter armel mipsel,$(DEB_HOST_ARCH)),) | ||
| 64 | LDFLAGS += -latomic | ||
| 65 | endif | ||
| 66 | |||
| 67 | build: $(SOURCES) | ||
| 68 | mkdir --parents ../../../android-tools/adbd | ||
| 69 | $(CXX) $^ -o ../../../android-tools/adbd/adbd $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) | ||
| 70 | |||
| 71 | clean: | ||
| 72 | $(RM) $(OUT_DIR)/usr/bin/$(NAME) | ||
diff --git a/dynamic-layers/selinux/android-tools/android-tools/core/0016-Adapt-adbd-to-work-with-yocto.patch b/dynamic-layers/selinux/android-tools/android-tools/core/0016-Adapt-adbd-to-work-with-yocto.patch new file mode 100644 index 0000000..8819431 --- /dev/null +++ b/dynamic-layers/selinux/android-tools/android-tools/core/0016-Adapt-adbd-to-work-with-yocto.patch | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | From 1c836e4402ae170b3e0bf31da9012b7a3b1c40a1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 3 | Date: Wed, 8 Mar 2023 15:21:49 +0100 | ||
| 4 | Subject: [PATCH] Adapt adbd to work with yocto | ||
| 5 | |||
| 6 | Co-authored-by: JJ Robertson <jrobertson@snap.com> | ||
| 7 | Co-authored-by: Wejdene Smida <wsmida@snap.com> | ||
| 8 | Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 9 | --- | ||
| 10 | adb/daemon/file_sync_service.cpp | 4 ++-- | ||
| 11 | adb/daemon/main.cpp | 4 ++-- | ||
| 12 | adb/daemon/reboot_service.cpp | 5 ++++- | ||
| 13 | adb/daemon/set_verity_enable_state_service.cpp | 6 +++++- | ||
| 14 | adb/daemon/shell_service.cpp | 4 ++++ | ||
| 15 | adb/types.h | 1 + | ||
| 16 | 6 files changed, 18 insertions(+), 6 deletions(-) | ||
| 17 | |||
| 18 | diff --git a/adb/daemon/file_sync_service.cpp b/adb/daemon/file_sync_service.cpp | ||
| 19 | index e82a51f2..ba112cbe 100644 | ||
| 20 | --- a/adb/daemon/file_sync_service.cpp | ||
| 21 | +++ b/adb/daemon/file_sync_service.cpp | ||
| 22 | @@ -111,7 +111,7 @@ static bool secure_mkdirs(const std::string& path) { | ||
| 23 | partial_path += path_component; | ||
| 24 | |||
| 25 | if (should_use_fs_config(partial_path)) { | ||
| 26 | - fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); | ||
| 27 | + // fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); | ||
| 28 | } | ||
| 29 | if (adb_mkdir(partial_path.c_str(), mode) == -1) { | ||
| 30 | if (errno != EEXIST) { | ||
| 31 | @@ -434,7 +434,7 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) { | ||
| 32 | uint64_t capabilities = 0; | ||
| 33 | if (should_use_fs_config(path)) { | ||
| 34 | unsigned int broken_api_hack = mode; | ||
| 35 | - fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); | ||
| 36 | + // fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); | ||
| 37 | mode = broken_api_hack; | ||
| 38 | } | ||
| 39 | |||
| 40 | diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp | ||
| 41 | index e5a49171..c75263c4 100644 | ||
| 42 | --- a/adb/daemon/main.cpp | ||
| 43 | +++ b/adb/daemon/main.cpp | ||
| 44 | @@ -191,6 +191,8 @@ int adbd_main(int server_port) { | ||
| 45 | umask(0); | ||
| 46 | |||
| 47 | signal(SIGPIPE, SIG_IGN); | ||
| 48 | + signal(SIGINT, SIG_DFL); | ||
| 49 | + signal(SIGQUIT, SIG_DFL); | ||
| 50 | |||
| 51 | #if defined(__BIONIC__) | ||
| 52 | auto fdsan_level = android_fdsan_get_error_level(); | ||
| 53 | @@ -232,13 +234,11 @@ int adbd_main(int server_port) { | ||
| 54 | |||
| 55 | bool is_usb = false; | ||
| 56 | |||
| 57 | -#if defined(__ANDROID__) | ||
| 58 | if (access(USB_FFS_ADB_EP0, F_OK) == 0) { | ||
| 59 | // Listen on USB. | ||
| 60 | usb_init(); | ||
| 61 | is_usb = true; | ||
| 62 | } | ||
| 63 | -#endif | ||
| 64 | |||
| 65 | // If one of these properties is set, also listen on that port. | ||
| 66 | // If one of the properties isn't set and we couldn't listen on usb, listen | ||
| 67 | diff --git a/adb/daemon/reboot_service.cpp b/adb/daemon/reboot_service.cpp | ||
| 68 | index a5a11b86..6bd069d4 100644 | ||
| 69 | --- a/adb/daemon/reboot_service.cpp | ||
| 70 | +++ b/adb/daemon/reboot_service.cpp | ||
| 71 | @@ -28,7 +28,9 @@ | ||
| 72 | #include <android-base/logging.h> | ||
| 73 | #include <android-base/properties.h> | ||
| 74 | #include <android-base/stringprintf.h> | ||
| 75 | -#include <bootloader_message/bootloader_message.h> | ||
| 76 | +// #include <bootloader_message/bootloader_message.h> | ||
| 77 | +#include <linux/reboot.h> | ||
| 78 | +#include <sys/signal.h> | ||
| 79 | #include <cutils/android_reboot.h> | ||
| 80 | |||
| 81 | #include "adb_io.h" | ||
| 82 | @@ -76,6 +78,7 @@ void reboot_service(unique_fd fd, const std::string& arg) { | ||
| 83 | return; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | + syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, reboot_arg.c_str()); | ||
| 87 | // Don't return early. Give the reboot command time to take effect | ||
| 88 | // to avoid messing up scripts which do "adb reboot && adb wait-for-device" | ||
| 89 | while (true) { | ||
| 90 | diff --git a/adb/daemon/set_verity_enable_state_service.cpp b/adb/daemon/set_verity_enable_state_service.cpp | ||
| 91 | index 889229fe..51e9be93 100644 | ||
| 92 | --- a/adb/daemon/set_verity_enable_state_service.cpp | ||
| 93 | +++ b/adb/daemon/set_verity_enable_state_service.cpp | ||
| 94 | @@ -22,7 +22,7 @@ | ||
| 95 | #include <errno.h> | ||
| 96 | #include <fcntl.h> | ||
| 97 | #include <inttypes.h> | ||
| 98 | -#include <libavb_user/libavb_user.h> | ||
| 99 | +// #include <libavb_user/libavb_user.h> | ||
| 100 | #include <stdarg.h> | ||
| 101 | #include <stdio.h> | ||
| 102 | #include <sys/mount.h> | ||
| 103 | @@ -65,6 +65,7 @@ static bool make_block_device_writable(const std::string& dev) { | ||
| 104 | /* Turn verity on/off */ | ||
| 105 | static bool set_verity_enabled_state(int fd, const char* block_device, const char* mount_point, | ||
| 106 | bool enable) { | ||
| 107 | +#if defined(__ANDROID__) | ||
| 108 | if (!make_block_device_writable(block_device)) { | ||
| 109 | WriteFdFmt(fd, "Could not make block device %s writable (%s).\n", | ||
| 110 | block_device, strerror(errno)); | ||
| 111 | @@ -115,6 +116,7 @@ static bool set_verity_enabled_state(int fd, const char* block_device, const cha | ||
| 112 | mount_point, strerror(errno)); | ||
| 113 | } | ||
| 114 | WriteFdFmt(fd, "Verity %s on %s\n", enable ? "enabled" : "disabled", mount_point); | ||
| 115 | +#endif | ||
| 116 | return true; | ||
| 117 | } | ||
| 118 | |||
| 119 | @@ -126,6 +128,7 @@ static std::string get_ab_suffix() { | ||
| 120 | return android::base::GetProperty("ro.boot.slot_suffix", ""); | ||
| 121 | } | ||
| 122 | |||
| 123 | +#if defined(__ANDROID__) | ||
| 124 | static bool is_avb_device_locked() { | ||
| 125 | return android::base::GetProperty("ro.boot.vbmeta.device_state", "") == "locked"; | ||
| 126 | } | ||
| 127 | @@ -245,3 +248,4 @@ void set_verity_enabled_state_service(unique_fd fd, bool enable) { | ||
| 128 | WriteFdExactly(fd.get(), "Now reboot your device for settings to take effect\n"); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | +#endif | ||
| 132 | diff --git a/adb/daemon/shell_service.cpp b/adb/daemon/shell_service.cpp | ||
| 133 | index 3c8f3939..84f4f54d 100644 | ||
| 134 | --- a/adb/daemon/shell_service.cpp | ||
| 135 | +++ b/adb/daemon/shell_service.cpp | ||
| 136 | @@ -264,6 +264,10 @@ bool Subprocess::ForkAndExec(std::string* error) { | ||
| 137 | env["TMPDIR"] = "/data/local/tmp"; | ||
| 138 | env["USER"] = pw->pw_name; | ||
| 139 | } | ||
| 140 | + if (env.find("PS1") == env.end()) { | ||
| 141 | + env["PS1"] = "\\h:\\w\\$ "; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | |||
| 145 | if (!terminal_type_.empty()) { | ||
| 146 | env["TERM"] = terminal_type_; | ||
| 147 | diff --git a/adb/types.h b/adb/types.h | ||
| 148 | index 6af4a150..9efe223b 100644 | ||
| 149 | --- a/adb/types.h | ||
| 150 | +++ b/adb/types.h | ||
| 151 | @@ -20,6 +20,7 @@ | ||
| 152 | #include <cstring> | ||
| 153 | #include <deque> | ||
| 154 | #include <memory> | ||
| 155 | +#include <string> | ||
| 156 | #include <type_traits> | ||
| 157 | #include <utility> | ||
| 158 | #include <vector> | ||
| 159 | -- | ||
| 160 | 2.36.1.vfs.0.0 | ||
| 161 | |||
diff --git a/dynamic-layers/selinux/android-tools/android-tools_10.0.0.r36.bb b/dynamic-layers/selinux/android-tools/android-tools_10.0.0.r36.bb index ca3c9be..f342655 100644 --- a/dynamic-layers/selinux/android-tools/android-tools_10.0.0.r36.bb +++ b/dynamic-layers/selinux/android-tools/android-tools_10.0.0.r36.bb | |||
| @@ -75,12 +75,14 @@ SRC_URI += " \ | |||
| 75 | file://core/0013-patching-libziparchive.mk-to-build-in-yocto-environm.patch;patchdir=system/core \ | 75 | file://core/0013-patching-libziparchive.mk-to-build-in-yocto-environm.patch;patchdir=system/core \ |
| 76 | file://core/0014-patching-libbacktrace.mk-to-build-in-yocto-environme.patch;patchdir=system/core \ | 76 | file://core/0014-patching-libbacktrace.mk-to-build-in-yocto-environme.patch;patchdir=system/core \ |
| 77 | file://core/0015-Use-namespace-std-to-compile-libbacktrace.patch;patchdir=system/core \ | 77 | file://core/0015-Use-namespace-std-to-compile-libbacktrace.patch;patchdir=system/core \ |
| 78 | file://core/0016-Adapt-adbd-to-work-with-yocto.patch;patchdir=system/core \ | ||
| 78 | file://0001-libcrypto.mk-modifications-to-make-it-build-in-yocto.patch;patchdir=external/boringssl \ | 79 | file://0001-libcrypto.mk-modifications-to-make-it-build-in-yocto.patch;patchdir=external/boringssl \ |
| 79 | file://0001-patching-libundwind-to-build-in-yocto-environment.patch;patchdir=external/libunwind \ | 80 | file://0001-patching-libundwind-to-build-in-yocto-environment.patch;patchdir=external/libunwind \ |
| 80 | file://0001-libext4_utils.mk-modifications-to-make-it-build-in-y.patch;patchdir=system/extras \ | 81 | file://0001-libext4_utils.mk-modifications-to-make-it-build-in-y.patch;patchdir=system/extras \ |
| 81 | file://0002-libfec-change-out_dir-in-makefile.patch;patchdir=system/extras \ | 82 | file://0002-libfec-change-out_dir-in-makefile.patch;patchdir=system/extras \ |
| 82 | file://rules_yocto.mk;subdir=git \ | 83 | file://rules_yocto.mk;subdir=git \ |
| 83 | file://android-tools-adbd.service \ | 84 | file://android-tools-adbd.service \ |
| 85 | file://adbd.mk;subdir=git/system/core/debian \ | ||
| 84 | " | 86 | " |
| 85 | 87 | ||
| 86 | S = "${WORKDIR}/git" | 88 | S = "${WORKDIR}/git" |
| @@ -111,6 +113,7 @@ CC:append:class-nativesdk = " -I${STAGING_INCDIR}" | |||
| 111 | 113 | ||
| 112 | PREREQUISITE_core = "libbase libsparse liblog libcutils" | 114 | PREREQUISITE_core = "libbase libsparse liblog libcutils" |
| 113 | TOOLS_TO_BUILD = "libcrypto_utils libadb libziparchive fastboot adb img2simg simg2img libbacktrace" | 115 | TOOLS_TO_BUILD = "libcrypto_utils libadb libziparchive fastboot adb img2simg simg2img libbacktrace" |
| 116 | TOOLS_TO_BUILD:append:class-target = " adbd" | ||
| 114 | 117 | ||
| 115 | # Adb needs sys/capability.h, which is not available for native* | 118 | # Adb needs sys/capability.h, which is not available for native* |
| 116 | TOOLS:class-native = "boringssl fastboot ext4_utils mkbootimg" | 119 | TOOLS:class-native = "boringssl fastboot ext4_utils mkbootimg" |
