From 7cdb29d2e265e0ce1e1308782e7d4378878e02ae Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Wed, 16 Dec 2015 01:55:44 +0000 Subject: [PATCH] devel/android-tools-{adb,fastboot}-devel: update to m.p.5956 Changes: https://android.googlesource.com/platform/system/core/+log/0bb1ce06ea46..461a29540c01/adb Changes: https://android.googlesource.com/platform/system/core/+log/0bb1ce06ea46..461a29540c01/fastboot --- devel/android-tools-adb-devel/Makefile | 12 +- devel/android-tools-adb-devel/distinfo | 8 +- devel/android-tools-adb-devel/files/Makefile | 1 + .../patch-base_include_android-base_logging.h | 11 + .../files/patch-base_logging.cpp | 40 ++++ devel/android-tools-adb/Makefile | 1 + ...> extra-patch-base_include_base_logging.h} | 0 devel/android-tools-fastboot-devel/Makefile | 9 +- devel/android-tools-fastboot-devel/distinfo | 12 +- .../files/Makefile | 8 +- .../files/pkg-message.in | 7 + .../files/usb_freebsd.cpp | 208 ++++++++++++++++++ .../files/util_freebsd.cpp | 37 ++++ 13 files changed, 331 insertions(+), 23 deletions(-) create mode 100644 devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h create mode 100644 devel/android-tools-adb-devel/files/patch-base_logging.cpp rename devel/android-tools-adb/files/{patch-base_include_base_logging.h => extra-patch-base_include_base_logging.h} (100%) create mode 100644 devel/android-tools-fastboot-devel/files/pkg-message.in create mode 100644 devel/android-tools-fastboot-devel/files/usb_freebsd.cpp create mode 100644 devel/android-tools-fastboot-devel/files/util_freebsd.cpp diff --git a/devel/android-tools-adb-devel/Makefile b/devel/android-tools-adb-devel/Makefile index d831f2abf46b..3d2bd850202f 100644 --- a/devel/android-tools-adb-devel/Makefile +++ b/devel/android-tools-adb-devel/Makefile @@ -1,8 +1,8 @@ # $FreeBSD$ # Hint: git describe --abbrev=12 --match android-m-preview -DISTVERSION= m-preview-5498 -DISTVERSIONSUFFIX= -g0bb1ce06ea46 +DISTVERSION= m-preview-5956 +DISTVERSIONSUFFIX= -g461a29540c01 PORTREVISION= 0 PKGNAMESUFFIX= -devel @@ -17,18 +17,14 @@ OPTIONS_DEFINE= TEST_PYTHON TEST_PYTHON_DESC= ${TEST_DESC:S/tests/python &/} TEST_PYTHON_GH_PROJECT= platform_development:development -TEST_PYTHON_GH_TAGNAME= ${DISTVERSIONFULL:C/-[0-9].*//}-2403-g084d084:development +TEST_PYTHON_GH_TAGNAME= ${DISTVERSIONFULL:C/-[0-9].*//}-2510-g72f24a0:development TEST_PYTHON_BUILD_DEPENDS=${PYTHON_PKGNAMEPREFIX}mock>0:${PORTSDIR}/devel/py-mock TEST_PYTHON_USES= python:2.7,build pre-install-TEST_PYTHON-on: # XXX python tests may leave behind running adb server -# test_adb.py remains in core repository for some reason ${SETENV} PATH=${BUILD_WRKSRC}:${PATH} \ PYTHONPATH=${WRKSRC_development}/python-packages \ - ${PYTHON_CMD} ${BUILD_WRKSRC}/test_adb.py - ${SETENV} PATH=${BUILD_WRKSRC}:${PATH} \ - PYTHONPATH=${WRKSRC_development}/python-packages \ - ${PYTHON_CMD} ${WRKSRC_development}/python-packages/adb/test_device.py + ${PYTHON_CMD} -m unittest discover -vs ${BUILD_WRKSRC} .include "${MASTERDIR}/Makefile" diff --git a/devel/android-tools-adb-devel/distinfo b/devel/android-tools-adb-devel/distinfo index 322c8175d3c1..146ac565260d 100644 --- a/devel/android-tools-adb-devel/distinfo +++ b/devel/android-tools-adb-devel/distinfo @@ -1,6 +1,6 @@ -SHA256 (android-platform_system_core-android-m-preview-5498-g0bb1ce06ea46_GH0.tar.gz) = 6495262da5f639cb76625437c82475c6220cab208666cf739508871ce36e79da -SIZE (android-platform_system_core-android-m-preview-5498-g0bb1ce06ea46_GH0.tar.gz) = 1407054 +SHA256 (android-platform_system_core-android-m-preview-5956-g461a29540c01_GH0.tar.gz) = 369b2d67c7887124d4d31e1d51934517d243a4c39f266f3685e709f8592b7d14 +SIZE (android-platform_system_core-android-m-preview-5956-g461a29540c01_GH0.tar.gz) = 1428466 SHA256 (mbrubeck-android-completion-3b0fabe_GH0.tar.gz) = dc774f101acd9514baf3e7a0ac610068116f2c093b94987ba59203a39a6439dc SIZE (mbrubeck-android-completion-3b0fabe_GH0.tar.gz) = 5948 -SHA256 (android-platform_development-android-m-preview-2403-g084d084_GH0.tar.gz) = a7c33bf2708d61ae2e44ff149fac2460f80746e7da936f08b373841be5750102 -SIZE (android-platform_development-android-m-preview-2403-g084d084_GH0.tar.gz) = 183883403 +SHA256 (android-platform_development-android-m-preview-2510-g72f24a0_GH0.tar.gz) = a7e3172a61be2b7545fb4c10d5516cceb68b574cf7c83b7fc00c5cac0527b182 +SIZE (android-platform_development-android-m-preview-2510-g72f24a0_GH0.tar.gz) = 183871106 diff --git a/devel/android-tools-adb-devel/files/Makefile b/devel/android-tools-adb-devel/files/Makefile index 31a19002c9a1..905516363c7c 100644 --- a/devel/android-tools-adb-devel/files/Makefile +++ b/devel/android-tools-adb-devel/files/Makefile @@ -17,6 +17,7 @@ SRCS+= adb_trace.cpp SRCS+= adb_utils.cpp SRCS+= commandline.cpp SRCS+= console.cpp +SRCS+= diagnose_usb.cpp SRCS+= fdevent.cpp SRCS+= file_sync_client.cpp SRCS+= line_printer.cpp diff --git a/devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h b/devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h new file mode 100644 index 000000000000..7f170c3f521b --- /dev/null +++ b/devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h @@ -0,0 +1,11 @@ +--- base/include/android-base/logging.h.orig 2015-09-29 18:07:07 UTC ++++ base/include/android-base/logging.h +@@ -25,6 +25,8 @@ + #endif + #endif + ++#include ++ + #include + #include + #include diff --git a/devel/android-tools-adb-devel/files/patch-base_logging.cpp b/devel/android-tools-adb-devel/files/patch-base_logging.cpp new file mode 100644 index 000000000000..7ace8ede711e --- /dev/null +++ b/devel/android-tools-adb-devel/files/patch-base_logging.cpp @@ -0,0 +1,40 @@ +--- base/logging.cpp.orig 2015-12-14 21:12:52 UTC ++++ base/logging.cpp +@@ -66,6 +68,16 @@ + #include + #elif defined(_WIN32) + #include ++#elif defined(__DragonFly__) ++#include ++#elif defined(__FreeBSD__) ++#include ++#include ++#include ++#elif defined(__NetBSD__) ++#include ++#else ++#include + #endif + + static pid_t GetThreadId() { +@@ -77,6 +89,20 @@ static pid_t GetThreadId() { + return syscall(__NR_gettid); + #elif defined(_WIN32) + return GetCurrentThreadId(); ++#elif defined(__DragonFly__) ++ return lwp_gettid(); ++#elif defined(__NetBSD__) ++ return _lwp_self(); ++#elif defined(__FreeBSD__) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#else ++ return (intptr_t) pthread_self(); + #endif + } + diff --git a/devel/android-tools-adb/Makefile b/devel/android-tools-adb/Makefile index d5ea416d41d9..bf612084a1a6 100644 --- a/devel/android-tools-adb/Makefile +++ b/devel/android-tools-adb/Makefile @@ -25,6 +25,7 @@ GH_REVISION= f7f765fd62bf # generated by: make update-revision CONFLICTS_INSTALL?= ${PORTNAME}-devel-* .ifndef EXTRA_PATCHES +EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_include_base_logging.h EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_file__test.cpp .endif diff --git a/devel/android-tools-adb/files/patch-base_include_base_logging.h b/devel/android-tools-adb/files/extra-patch-base_include_base_logging.h similarity index 100% rename from devel/android-tools-adb/files/patch-base_include_base_logging.h rename to devel/android-tools-adb/files/extra-patch-base_include_base_logging.h diff --git a/devel/android-tools-fastboot-devel/Makefile b/devel/android-tools-fastboot-devel/Makefile index 5af4e6f9d757..79d6b5bb3224 100644 --- a/devel/android-tools-fastboot-devel/Makefile +++ b/devel/android-tools-fastboot-devel/Makefile @@ -1,17 +1,18 @@ # $FreeBSD$ # Hint: git describe --abbrev=12 --match android-m-preview -DISTVERSION= m-preview-5498 -DISTVERSIONSUFFIX= -g0bb1ce06ea46 +DISTVERSION= m-preview-5956 +DISTVERSIONSUFFIX= -g461a29540c01 PORTREVISION= 0 PKGNAMESUFFIX= -devel -GH_TAGNAME= ${DISTVERSIONFULL:C/-[0-9].*//}-972-g442e952:extras \ - ${DISTVERSIONFULL:C/-[0-9].*//}-90-ga83098b:libselinux +GH_TAGNAME= ${DISTVERSIONFULL:C/-[0-9].*//}-1071-g4f5860d:extras \ + ${DISTVERSIONFULL:C/-[0-9].*//}-94-gbe5f860:libselinux CONFLICTS_INSTALL= ${PORTNAME}-[0-9]* MASTERDIR= ${.CURDIR}/../android-tools-fastboot +FILESDIR= ${.CURDIR}/files DISTINFO_FILE= ${.CURDIR}/distinfo .include "${MASTERDIR}/Makefile" diff --git a/devel/android-tools-fastboot-devel/distinfo b/devel/android-tools-fastboot-devel/distinfo index 20cf4cc63b31..2061619f0d14 100644 --- a/devel/android-tools-fastboot-devel/distinfo +++ b/devel/android-tools-fastboot-devel/distinfo @@ -1,10 +1,10 @@ SHA256 (fastboot.1?id=706e754) = 2af01b064440952a82f1602691a0fecc030302722a71444946fb70d9c423d283 SIZE (fastboot.1?id=706e754) = 5906 -SHA256 (android-platform_system_core-android-m-preview-5498-g0bb1ce06ea46_GH0.tar.gz) = 6495262da5f639cb76625437c82475c6220cab208666cf739508871ce36e79da -SIZE (android-platform_system_core-android-m-preview-5498-g0bb1ce06ea46_GH0.tar.gz) = 1407054 -SHA256 (jbeich-platform_system_extras-android-m-preview-972-g442e952_GH0.tar.gz) = 77082c3fae368dda9fe0a7edb2b54cfb3c47a849f5fe3ab160225304e3598e1e -SIZE (jbeich-platform_system_extras-android-m-preview-972-g442e952_GH0.tar.gz) = 76529760 -SHA256 (jbeich-platform_external_libselinux-android-m-preview-90-ga83098b_GH0.tar.gz) = 05afbdfad4028c4cdc62d1fa831760cded52883749e686a5c0cea5901d5aa33c -SIZE (jbeich-platform_external_libselinux-android-m-preview-90-ga83098b_GH0.tar.gz) = 58818 +SHA256 (android-platform_system_core-android-m-preview-5956-g461a29540c01_GH0.tar.gz) = 369b2d67c7887124d4d31e1d51934517d243a4c39f266f3685e709f8592b7d14 +SIZE (android-platform_system_core-android-m-preview-5956-g461a29540c01_GH0.tar.gz) = 1428466 +SHA256 (jbeich-platform_system_extras-android-m-preview-1071-g4f5860d_GH0.tar.gz) = 31376565de222f87cbcea4786346a198432c6aae257a857d7afa4ec1e3b5997d +SIZE (jbeich-platform_system_extras-android-m-preview-1071-g4f5860d_GH0.tar.gz) = 76521949 +SHA256 (jbeich-platform_external_libselinux-android-m-preview-94-gbe5f860_GH0.tar.gz) = 596a151d25a0cf1e39abc3157ea91f1c69471a9bb41859e915f6c4ac5efaf2c0 +SIZE (jbeich-platform_external_libselinux-android-m-preview-94-gbe5f860_GH0.tar.gz) = 58977 SHA256 (mbrubeck-android-completion-3b0fabe_GH0.tar.gz) = dc774f101acd9514baf3e7a0ac610068116f2c093b94987ba59203a39a6439dc SIZE (mbrubeck-android-completion-3b0fabe_GH0.tar.gz) = 5948 diff --git a/devel/android-tools-fastboot-devel/files/Makefile b/devel/android-tools-fastboot-devel/files/Makefile index c90b8ac76fdf..c1c277bd2351 100644 --- a/devel/android-tools-fastboot-devel/files/Makefile +++ b/devel/android-tools-fastboot-devel/files/Makefile @@ -17,10 +17,15 @@ SRCS+= util.cpp SRCS+= usb_freebsd.cpp SRCS+= util_freebsd.cpp -# required by fastboot and libziparchive +# required by fastboot +.PATH: ${.CURDIR}/../adb +SRCS+= diagnose_usb.cpp + +# required by fastboot, diagnose_usb and libziparchive .PATH: ${.CURDIR}/../base SRCS+= file.cpp SRCS+= strings.cpp +SRCS+= stringprintf.cpp # required by fastboot .PATH: ${.CURDIR}/../ext4_utils @@ -81,6 +86,7 @@ CPPFLAGS+= -Dmmap64=mmap CPPFLAGS+= -Dpread64=pread CPPFLAGS+= -I${.CURDIR} CPPFLAGS+= -I${.CURDIR}/../include +CPPFLAGS+= -I${.CURDIR}/../adb CPPFLAGS+= -I${.CURDIR}/../mkbootimg CPPFLAGS+= -I${.CURDIR}/../base/include CPPFLAGS+= -I${.CURDIR}/../ext4_utils diff --git a/devel/android-tools-fastboot-devel/files/pkg-message.in b/devel/android-tools-fastboot-devel/files/pkg-message.in new file mode 100644 index 000000000000..32713248181a --- /dev/null +++ b/devel/android-tools-fastboot-devel/files/pkg-message.in @@ -0,0 +1,7 @@ +The port installed fastboot(1) under %%PREFIX%%/bin. However, there's +a different fastboot(8) under /sbin. To avoid accidentally invoking +the wrong command make sure either to + +- adjust PATH environment variable to have fastboot(1) found first +- create a shell alias with absolute path to fastboot(1) +- create a symlink with different name in PATH e.g., under ~/bin diff --git a/devel/android-tools-fastboot-devel/files/usb_freebsd.cpp b/devel/android-tools-fastboot-devel/files/usb_freebsd.cpp new file mode 100644 index 000000000000..3780489b4fea --- /dev/null +++ b/devel/android-tools-fastboot-devel/files/usb_freebsd.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2011 Hans Petter Selasky. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include + +#include "usb.h" + +struct usb_handle { + libusb_device_handle *handle; + libusb_device *dev; + unsigned char ep_in; + unsigned char ep_out; + unsigned char iface; +}; + +class LibusbUsbTransport : public Transport { +public: + LibusbUsbTransport(std::unique_ptr handle): + h(std::move(handle)) {} + ~LibusbUsbTransport() override = default; + + ssize_t Read(void *_data, size_t len) override; + ssize_t Write(const void *_data, size_t len) override; + int Close() override; + +private: + std::unique_ptr h; + + DISALLOW_COPY_AND_ASSIGN(LibusbUsbTransport); +}; + +static int +probe(std::unique_ptr &h, ifc_match_func callback) +{ + usb_ifc_info info; + libusb_device_descriptor ddesc; + libusb_config_descriptor *pcfg; + int i, j; + + if (libusb_open(h->dev, &h->handle) < 0) + return (-1); + + if (libusb_get_device_descriptor(h->dev, &ddesc) < 0) { + libusb_close(h->handle); + return (-1); + } + memset(&info, 0, sizeof(info)); + + info.dev_vendor = ddesc.idVendor; + info.dev_product = ddesc.idProduct; + info.dev_class = ddesc.bDeviceClass; + info.dev_subclass = ddesc.bDeviceSubClass; + info.dev_protocol = ddesc.bDeviceProtocol; + info.writable = 1; + + snprintf(info.device_path, sizeof(info.device_path), "ugen%d.%d", + libusb_get_bus_number(h->dev), libusb_get_device_address(h->dev)); + + if (ddesc.iSerialNumber != 0) { + libusb_get_string_descriptor_ascii(h->handle, ddesc.iSerialNumber, + (unsigned char *)info.serial_number, sizeof(info.serial_number)); + } + if (libusb_get_active_config_descriptor(h->dev, &pcfg)) { + libusb_close(h->handle); + return (-1); + } + + for (i = 0; i < pcfg->bNumInterfaces; i++) { + + h->ep_in = 0; + h->ep_out = 0; + h->iface = i; + + for (j = 0; j < pcfg->interface[i].altsetting[0].bNumEndpoints; j++) { + + unsigned char temp = pcfg->interface[i].altsetting[0]. + endpoint[j].bEndpointAddress; + unsigned char type = pcfg->interface[i].altsetting[0]. + endpoint[j].bmAttributes & 0x03; + + /* check for BULK endpoint */ + if ((type & 0x03) == 0x02) { + /* check for IN endpoint */ + if (temp & 0x80) + h->ep_in = temp; + else + h->ep_out = temp; + } + } + + info.ifc_class = pcfg->interface[i].altsetting[0].bInterfaceClass; + info.ifc_subclass = pcfg->interface[i].altsetting[0].bInterfaceSubClass; + info.ifc_protocol = pcfg->interface[i].altsetting[0].bInterfaceProtocol; + info.has_bulk_in = (h->ep_in != 0); + info.has_bulk_out = (h->ep_out != 0); + + if (libusb_claim_interface(h->handle, h->iface) < 0) + continue; + + if (callback(&info) == 0) { + libusb_free_config_descriptor(pcfg); + return (0); + } + libusb_release_interface(h->handle, h->iface); + } + + libusb_free_config_descriptor(pcfg); + libusb_close(h->handle); + return (-1); +} + +static std::unique_ptr +enumerate(ifc_match_func callback) +{ + static libusb_context *ctx = NULL; + std::unique_ptr h; + libusb_device **ppdev; + ssize_t ndev; + ssize_t x; + + if (ctx == NULL) + libusb_init(&ctx); + + ndev = libusb_get_device_list(ctx, &ppdev); + for (x = 0; x < ndev; x++) { + + h.reset(new usb_handle); + + h->dev = ppdev[x]; + + if (probe(h, callback) == 0) { + libusb_ref_device(h->dev); + libusb_free_device_list(ppdev, 1); + return (h); + } + } + h.reset(); + libusb_free_device_list(ppdev, 1); + return (nullptr); +} + +ssize_t +LibusbUsbTransport::Write(const void *_data, size_t len) +{ + int actlen; + + if (libusb_bulk_transfer(h->handle, h->ep_out, + (unsigned char *)_data, len, &actlen, 0) < 0) + return (-1); + return (actlen); +} + +ssize_t +LibusbUsbTransport::Read(void *_data, size_t len) +{ + int actlen; + + if (libusb_bulk_transfer(h->handle, h->ep_in, + (unsigned char *)_data, len, &actlen, 0) < 0) + return (-1); + return (actlen); +} + +int +LibusbUsbTransport::Close() +{ + libusb_close(h->handle); + h->handle = NULL; + libusb_unref_device(h->dev); + h.reset(); + return (0); +} + +Transport * +usb_open(ifc_match_func callback) +{ + std::unique_ptr h = enumerate(callback); + return (h ? new LibusbUsbTransport(std::move(h)) : nullptr); +} diff --git a/devel/android-tools-fastboot-devel/files/util_freebsd.cpp b/devel/android-tools-fastboot-devel/files/util_freebsd.cpp new file mode 100644 index 000000000000..e962993e35a9 --- /dev/null +++ b/devel/android-tools-fastboot-devel/files/util_freebsd.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011 Hans Petter Selasky. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "fastboot.h" + +#include +#include + +void +get_my_path(char *path) +{ + getcwd(path, PATH_MAX - 1); +}