这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/android-tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 24 additions & 24 deletions packages/android-tools/vendor_core_fastboot_fastboot.cpp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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() {
Expand All @@ -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);
Expand All @@ -40,15 +40,15 @@ index 0062e7e..9d2ee12 100644
}
}

+#ifdef ANDROID
+#ifdef __ANDROID__
+static void list_devices(libusb_context *context) {
+#else
static void list_devices() {
+#endif
// 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
+
Expand All @@ -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() {
Expand All @@ -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());
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -109,7 +109,7 @@ index 0062e7e..9d2ee12 100644
{
}

+#ifdef ANDROID
+#ifdef __ANDROID__
+void FlashAllTool::Flash(libusb_context *context) {
+#else
void FlashAllTool::Flash() {
Expand All @@ -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();
Expand All @@ -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() {
Expand All @@ -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();
Expand All @@ -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) {
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ index c23793a..b7c07f0 100644
* SUCH DAMAGE.
*/

+#ifdef ANDROID
+#ifdef __ANDROID__
+#include <libusb-1.0/libusb.h>
+#endif
+
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions packages/android-tools/vendor_core_fastboot_usb.h.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ index e5f56e2..eea0075 100644

#pragma once

+#ifdef ANDROID
+#ifdef __ANDROID__
+#include <libusb-1.0/libusb.h>
+#endif
+
Expand All @@ -18,7 +18,7 @@ index e5f56e2..eea0075 100644

char interface[256];
+
+#ifdef ANDROID
+#ifdef __ANDROID__
+ bool termux_usb;
+#endif
};
Expand All @@ -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);
Expand Down
Loading