android-tools: fix typos in fastboot patch

Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
This commit is contained in:
Ookiineko 2022-04-27 17:48:32 +08:00 committed by Henrik Grimler
parent 5e8c078e3d
commit 67ceadbb4e
No known key found for this signature in database
GPG Key ID: B0076E490B71616B
5 changed files with 48 additions and 48 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Android platform tools"
TERMUX_PKG_LICENSE="Apache-2.0, MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=31.0.3p1
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://github.com/nmeum/android-tools/releases/download/$TERMUX_PKG_VERSION/android-tools-$TERMUX_PKG_VERSION.tar.xz
TERMUX_PKG_SHA256=0ef69f919d58a2bdff2083d2e83a9ef38df079ec82651b2544e9e48086df5ab8
TERMUX_PKG_AUTO_UPDATE=true

View File

@ -6,7 +6,7 @@ index 0062e7e..9d2ee12 100644
#include <liblp/liblp.h>
#include <sparse/sparse.h>
#include <ziparchive/zip_archive.h>
+#ifdef ANDROID
+#ifdef __ANDROID__
+#include <libusb-1.0/libusb.h>
+#endif
@ -16,7 +16,7 @@ index 0062e7e..9d2ee12 100644
//
// The returned Transport is a singleton, so multiple calls to this function will return the same
// object, and the caller should not attempt to delete the returned Transport.
+#ifdef ANDROID
+#ifdef __ANDROID__
+static Transport* open_device(libusb_context *context) {
+#else
static Transport* open_device() {
@ -28,7 +28,7 @@ index 0062e7e..9d2ee12 100644
fprintf(stderr, "error: %s\n", error.c_str());
}
} else {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ transport = usb_open(match_fastboot, context);
+#else
transport = usb_open(match_fastboot);
@ -40,7 +40,7 @@ index 0062e7e..9d2ee12 100644
}
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+static void list_devices(libusb_context *context) {
+#else
static void list_devices() {
@ -48,7 +48,7 @@ index 0062e7e..9d2ee12 100644
// We don't actually open a USB device here,
// just getting our callback called so we can
// list all the connected devices.
+#ifdef ANDROID
+#ifdef __ANDROID__
+ usb_open(list_devices_callback, context);
+#else
+
@ -61,7 +61,7 @@ index 0062e7e..9d2ee12 100644
return fb->GetVar("is-userspace", &value) == fastboot::SUCCESS && value == "yes";
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+static void reboot_to_userspace_fastboot(libusb_context *context) {
+#else
static void reboot_to_userspace_fastboot() {
@ -73,7 +73,7 @@ index 0062e7e..9d2ee12 100644
// Give the current connection time to close.
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+#ifdef ANDROID
+#ifdef __ANDROID__
+ fb->set_transport(open_device(context));
+#else
fb->set_transport(open_device());
@ -85,7 +85,7 @@ index 0062e7e..9d2ee12 100644
FlashAllTool(const ImageSource& source, const std::string& slot_override, bool skip_secondary,
bool wipe, bool force_flash);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ void Flash(libusb_context *context);
+#else
void Flash();
@ -97,7 +97,7 @@ index 0062e7e..9d2ee12 100644
void CollectImages();
void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images);
void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ void UpdateSuperPartition(libusb_context *context);
+#else
void UpdateSuperPartition();
@ -109,7 +109,7 @@ index 0062e7e..9d2ee12 100644
{
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+void FlashAllTool::Flash(libusb_context *context) {
+#else
void FlashAllTool::Flash() {
@ -121,7 +121,7 @@ index 0062e7e..9d2ee12 100644
FlashImages(boot_images_);
// Sync the super partition. This will reboot to userspace fastboot if needed.
+#ifdef ANDROID
+#ifdef __ANDROID__
+ UpdateSuperPartition(context);
+#else
UpdateSuperPartition();
@ -133,7 +133,7 @@ index 0062e7e..9d2ee12 100644
do_for_partitions(image.part_name, slot, flash, false);
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+void FlashAllTool::UpdateSuperPartition(libusb_context *context) {
+#else
void FlashAllTool::UpdateSuperPartition() {
@ -143,7 +143,7 @@ index 0062e7e..9d2ee12 100644
return;
}
if (!is_userspace_fastboot()) {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ reboot_to_userspace_fastboot(context);
+#else
reboot_to_userspace_fastboot();
@ -155,7 +155,7 @@ index 0062e7e..9d2ee12 100644
}
static void do_update(const char* filename, const std::string& slot_override, bool skip_secondary,
+#ifdef ANDROID
+#ifdef __ANDROID__
+ bool force_flash, libusb_context *context) {
+#else
bool force_flash) {
@ -167,7 +167,7 @@ index 0062e7e..9d2ee12 100644
}
FlashAllTool tool(ZipImageSource(zip), slot_override, skip_secondary, false, force_flash);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ tool.Flash(context);
+#else
tool.Flash();
@ -179,13 +179,13 @@ index 0062e7e..9d2ee12 100644
}
static void do_flashall(const std::string& slot_override, bool skip_secondary, bool wipe,
+#ifdef ANDROID
+#ifdef __ANDROID__
+ bool force_flash, libusb_context *context) {
+#else
bool force_flash) {
+#endif
FlashAllTool tool(LocalImageSource(), slot_override, skip_secondary, wipe, force_flash);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ tool.Flash(context);
+#else
tool.Flash();
@ -197,7 +197,7 @@ index 0062e7e..9d2ee12 100644
}
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+int FastBootTool::Main(int argc, char* argv[]) {
+ libusb_context *context;
+ libusb_set_option(NULL, LIBUSB_OPTION_WEAK_AUTHORITY);
@ -218,7 +218,7 @@ index 0062e7e..9d2ee12 100644
if (argc == 0 && !wants_wipe && !wants_set_active) syntax_error("no command");
if (argc > 0 && !strcmp(*argv, "devices")) {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ list_devices(context);
+#else
list_devices();
@ -230,7 +230,7 @@ index 0062e7e..9d2ee12 100644
return show_help();
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+ Transport* transport = open_device(context);
+#else
Transport* transport = open_device();
@ -242,13 +242,13 @@ index 0062e7e..9d2ee12 100644
} else if (command == "flashall") {
if (slot_override == "all") {
fprintf(stderr, "Warning: slot set to 'all'. Secondary slots will not be flashed.\n");
+#ifdef ANDROID
+#ifdef __ANDROID__
+ do_flashall(slot_override, true, wants_wipe, force_flash, context);
+#else
do_flashall(slot_override, true, wants_wipe, force_flash);
+#endif
} else {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ do_flashall(slot_override, skip_secondary, wants_wipe, force_flash, context);
+#else
do_flashall(slot_override, skip_secondary, wants_wipe, force_flash);
@ -260,7 +260,7 @@ index 0062e7e..9d2ee12 100644
if (!args.empty()) {
filename = next_arg(&args);
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+ do_update(filename.c_str(), slot_override, skip_secondary || slot_all, force_flash, context);
+#else
do_update(filename.c_str(), slot_override, skip_secondary || slot_all, force_flash);
@ -272,7 +272,7 @@ index 0062e7e..9d2ee12 100644
fb->RebootTo("recovery");
fb->WaitForDisconnect();
} else if (wants_reboot_fastboot) {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ reboot_to_userspace_fastboot(context);
+#else
reboot_to_userspace_fastboot();

View File

@ -6,7 +6,7 @@ index c23793a..b7c07f0 100644
* SUCH DAMAGE.
*/
+#ifdef ANDROID
+#ifdef __ANDROID__
+#include <libusb-1.0/libusb.h>
+#endif
+
@ -15,7 +15,7 @@ index c23793a..b7c07f0 100644
class FastBootTool {
public:
int Main(int argc, char* argv[]);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ int RealMain(int argc, char* argv[], libusb_context *context);
+#endif

View File

@ -6,7 +6,7 @@ index e5f56e2..eea0075 100644
#pragma once
+#ifdef ANDROID
+#ifdef __ANDROID__
+#include <libusb-1.0/libusb.h>
+#endif
+
@ -18,7 +18,7 @@ index e5f56e2..eea0075 100644
char interface[256];
+
+#ifdef ANDROID
+#ifdef __ANDROID__
+ bool termux_usb;
+#endif
};
@ -28,7 +28,7 @@ index e5f56e2..eea0075 100644
typedef int (*ifc_match_func)(usb_ifc_info *ifc);
// 0 is non blocking
+#ifdef ANDROID
+#ifdef __ANDROID__
+UsbTransport* usb_open(ifc_match_func callback, libusb_context *context, uint32_t timeout_ms = 0);
+#else
UsbTransport* usb_open(ifc_match_func callback, uint32_t timeout_ms = 0);

View File

@ -6,7 +6,7 @@ index 964488c..d03f3a2 100644
#include <linux/usbdevice_fs.h>
#include <linux/version.h>
#include <linux/usb/ch9.h>
+#ifdef ANDROID
+#ifdef __ANDROID__
+#include <libusb-1.0/libusb.h>
+#endif
@ -16,7 +16,7 @@ index 964488c..d03f3a2 100644
struct usb_handle
{
char fname[64];
+#ifdef ANDROID
+#ifdef __ANDROID__
+ int fd;
+ bool termux_usb;
+#endif
@ -27,7 +27,7 @@ index 964488c..d03f3a2 100644
}
static int filter_usb_device(char* sysfs_name,
+#ifdef ANDROID
+#ifdef __ANDROID__
+ libusb_context *context, int fd, bool termux_usb,
+#endif
char *ptr, int len, int writable,
@ -37,7 +37,7 @@ index 964488c..d03f3a2 100644
info.dev_subclass = dev->bDeviceSubClass;
info.dev_protocol = dev->bDeviceProtocol;
info.writable = writable;
+#ifdef ANDROID
+#ifdef __ANDROID__
+ info.termux_usb = termux_usb;
+ if (termux_usb)
@ -51,7 +51,7 @@ index 964488c..d03f3a2 100644
*/
info.serial_number[0] = '\0';
if (dev->iSerialNumber) {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ if (termux_usb) {
+ libusb_device_handle *handle;
+ unsigned char serial_num[256];
@ -67,7 +67,7 @@ index 964488c..d03f3a2 100644
info.serial_number[chars_read - 1] = '\0';
}
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+ }
+#endif
}
@ -77,7 +77,7 @@ index 964488c..d03f3a2 100644
info.has_bulk_in = (in != -1);
info.has_bulk_out = (out != -1);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ if (termux_usb)
+ snprintf(info.interface, sizeof(info.interface), "fastboot\n");
+ else {
@ -88,7 +88,7 @@ index 964488c..d03f3a2 100644
if (android::base::ReadFileToString(path, &interface)) {
snprintf(info.interface, sizeof(info.interface), "%s", interface.c_str());
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+ }
+#endif
@ -98,7 +98,7 @@ index 964488c..d03f3a2 100644
return 0;
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+static std::unique_ptr<usb_handle> find_usb_device(const char* base, libusb_context *context, ifc_match_func callback)
+#else
static std::unique_ptr<usb_handle> find_usb_device(const char* base, ifc_match_func callback)
@ -110,7 +110,7 @@ index 964488c..d03f3a2 100644
int fd;
int writable;
+#ifdef ANDROID
+#ifdef __ANDROID__
+ bool linux_usb, termux_usb;
+ linux_usb = termux_usb = true;
+ writable = 1;
@ -123,7 +123,7 @@ index 964488c..d03f3a2 100644
+#endif
+
std::unique_ptr<DIR, decltype(&closedir)> busdir(opendir(base), closedir);
+#ifdef ANDROID
+#ifdef __ANDROID__
+ if (busdir == 0) linux_usb = false;
+
+ bool is_linux_usb, is_termux_usb;
@ -147,7 +147,7 @@ index 964488c..d03f3a2 100644
// DBG("[ scanning %s ]\n", devname);
writable = 1;
+#ifdef ANDROID
+#ifdef __ANDROID__
+ if (is_termux_usb) lseek(fd, 0, SEEK_SET);
+ else {
+#endif
@ -158,19 +158,19 @@ index 964488c..d03f3a2 100644
continue;
}
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+ }
+#endif
n = read(fd, desc, sizeof(desc));
+#ifdef ANDROID
+#ifdef __ANDROID__
+ if (filter_usb_device(de->d_name, context, fd, is_termux_usb, desc, n, writable, callback, &in, &out, &ifc) == 0) {
+#else
if (filter_usb_device(de->d_name, desc, n, writable, callback, &in, &out, &ifc) == 0) {
+#endif
usb.reset(new usb_handle());
+#ifdef ANDROID
+#ifdef __ANDROID__
+ usb->fd = fd;
+ usb->termux_usb = is_termux_usb;
+#else
@ -183,7 +183,7 @@ index 964488c..d03f3a2 100644
return 0;
}
+#ifdef ANDROID
+#ifdef __ANDROID__
+UsbTransport* usb_open(ifc_match_func callback, libusb_context *context, uint32_t timeout_ms) {
+ std::unique_ptr<usb_handle> handle = find_usb_device("/sys/bus/usb/devices", context, callback);
+#else
@ -197,13 +197,13 @@ index 964488c..d03f3a2 100644
{
double deadline = now() + WAIT_FOR_DISCONNECT_TIMEOUT;
while (now() < deadline) {
+#ifdef ANDROID
+#ifdef __ANDROID__
+ if(handle_->termux_usb) {
+ if (fcntl(handle_->fd, F_GETFD) == -1) return 0;
+ } else {
+#endif
if (access(handle_->fname, F_OK)) return 0;
+#ifdef ANDROID
+#ifdef __ANDROID__
+ }
+#endif
std::this_thread::sleep_for(50ms);