commit dd51593af3ba0da9aab06fab7e1a7817e347f43e Author: Paravis Date: Sat Nov 14 18:24:25 2026 +0300 Исходники Android-приложения Paravis Flash CBL diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eac601b --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.gradle/ +build/ +local.properties +*.iml +.idea/ +*.apk +*.aab +captures/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3877ae0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9296117 --- /dev/null +++ b/README.md @@ -0,0 +1,171 @@ +# Paravis Flash CBL + +Android-приложение для смены загрузчика флешки **Paravis Flash** без root. +Работает с Legacy BIOS и UEFI, читает файлы загрузчиков с самой флешки и +подсвечивает тот, который установлен сейчас. + +![Скриншот](docs/screenshot.png) + +## Что умеет + +- Находит USB-накопитель через OTG и показывает модель моста, VID:PID и режим + работы: **BOT** или **UAS**. +- Читает сектор 0 через SCSI `READ(10)`: подпись `0x55AA`, disk signature, + таблицу разделов и hex-дамп. +- Меняет Legacy-загрузчик: + - **XorBoot** — MBR `xmbr.bin` + PBR `xpbr.bin`; + - **Bootmgr** — MBR NT60 + PBR bootmgr + файл `bootmgr` в корне; + - **Grub4Dos** — MBR/PBR GRUB4DOS + файл `grldr` в корне; + - **Grub2** — MBR + `core.img`. +- Меняет UEFI-загрузчик копированием файлов в `\efi\boot`: + - **Bootmgr** — `bootx64.efi`, `bootia32.efi`; + - **Grub2** — `bootx64.efi`, `fbx64.efi`, `mmx64.efi`; + - **XorBoot** — `bootx64.efi`, `bootia32.efi`. +- Перед каждой записью Legacy сохраняет **первые 1 МБ** флешки в + `Android/data/ru.paravis.usbprobe/files`. +- После записи делает read-back проверку MBR, PBR и `core.img`. +- Проверяет маркеры сборки и не пишет на посторонние диски. +- Подсвечивает установленный Legacy- и UEFI-загрузчик. +- Показывает причину, если операция невозможна: UAS, нет маркеров, занятый + интерфейс, отсутствуют файлы загрузчика. + +## Требования + +- **Android 8.0 (API 26)** или новее. +- Поддержка **USB Host / OTG**. +- Накопитель в режиме **BOT** (не UAS). +- Для UEFI, Bootmgr и Grub4Dos — разрешение **«Все файлы»** + (`MANAGE_EXTERNAL_STORAGE`), иначе файлы не скопировать. + +## Как это работает + +### USB и сектора + +Обычное приложение не имеет доступа к MBR и PBR: это сектора, а не файлы. +Приложение забирает USB-интерфейс накопителя через `UsbManager` и работает по +SCSI Bulk-Only Transport: `READ(10)` и `WRITE(10)`. + +Загрузчик ставится так: + +- **MBR** = код загрузчика `[0..439]` + текущая таблица разделов `[440..511]`; +- **PBR** = код загрузчика с сохранением BPB (байты `0x0B..0x59`); +- **Legacy Grub2** — `boot.img` в LBA0 и `core.img` с LBA1 (592 сектора); +- **XorBoot** — 63 сектора MBR-образа + PBR раздела PARAVIS. + +### Файлы берутся с флешки + +Приложение не хранит EFI-файлы и `core.img` внутри APK. Источники: + +| Загрузчик | Путь на флешке | +|---|---| +| Legacy Grub2 | `efi/Paravis/Boot/grub2/bios/boot.img`, `core.img` | +| Legacy XorBoot | `efi/Paravis/Boot/xor/xmbr.bin`, `xpbr.bin` | +| Legacy Bootmgr | `efi/Paravis/Boot/mgr/bootmgr` | +| Legacy Grub4Dos | `efi/Paravis/Boot/g4d/grldr` | +| UEFI Bootmgr | `efi/Paravis/Boot/mgr/UEFI/*.efi` | +| UEFI Grub2 | `efi/Paravis/Boot/loaders/grub2/*.efi` | +| UEFI XorBoot | `efi/Paravis/Boot/xor/UEFI/*.efi` | + +В APK встроены только четыре маленьких блока MBR/PBR по 512 байт, которых нет +на флешке отдельными файлами (NT60, bootmgr PBR, GRUB4DOS MBR/PBR). + +Если файлов загрузчика нет — его кнопка неактивна. + +### Маркеры сборки + +Перед активацией кнопок проверяются: + +- `efi/Paravis/Boot/NOT.DEL` на разделе PARAVIS; +- `ISO/Ventoy/NOT.DEL` на разделе DATA. + +Без них приложение работает только как диагностика: можно прочитать LBA0, но +запись недоступна. Дополнительно перед Legacy-записью проверяется, что MBR +содержит подпись `0x55AA`, FAT32 (`0x0c`) и VTOYEFI (`0xef`). + +### Состояние загрузчиков + +Текущий загрузчик хранится в `efi/Paravis/Boot/bootstate.txt`: + +``` +legacy=3 +uefi=1 +``` + +Файл пишут и Android-приложение, и Windows-сменщик `Change_BootLoader.exe`. +По нему кнопки установленных загрузчиков подсвечиваются синим. UEFI +дополнительно определяется сравнением файлов в `efi/boot`, если файла +состояния нет. + +## Интерфейс + +- Тёмная шапка `#1E2A44`, светлый фон `#F1F4F9` — как у Windows-сменщика. +- **LEGACY BIOS**: XorBoot, Bootmgr, Grub4Dos, Grub2. +- **UEFI**: Bootmgr, Grub2, XorBoot. +- **ДИАГНОСТИКА**: «Извлечь накопитель» и «Читать LBA0». +- Текущий загрузчик выделен фоном `#D8E4F8` и рамкой `#9BB8E8`. +- Пока открыт диалог подтверждения или идёт запись, остальные кнопки + неактивны. + +## Сборка + +Нужны JDK 17, Android SDK (platform 34, build-tools 34) и Gradle 8.7. + +```bat +set JAVA_HOME=C:\path\to\jdk-17 +set ANDROID_HOME=C:\path\to\android-sdk +gradle assembleDebug +``` + +Результат: + +``` +app\build\outputs\apk\debug\app-debug.apk +``` + +Для сборки из Android Studio достаточно открыть корень проекта. + +## Структура + +``` +app/src/main/java/ru/paravis/usbprobe/MainActivity.java интерфейс и логика +app/src/main/AndroidManifest.xml разрешения и USB Host +app/src/main/res/ иконки и цвета +app/src/main/assets/legacy/ MBR/PBR-блоки (4×512) +docs/screenshot.png скриншот +docs/icon.png иконка 1024×1024 +``` + +## Ограничения + +- **UAS.** Если мост отдаёт UAS вместо BOT, raw-доступ без root невозможен. + Приложение сообщает об этом и не пытается писать. +- **Захват USB отключает файловую систему.** После Legacy-записи нужно + переподключить флешку, чтобы снова работать с файлами. Приложение пишет + об этом в результате. +- **Извлечение.** Публичного API для извлечения тома в Android нет; кнопка + открывает настройки хранилища, где нужно выбрать накопитель и нажать + «Извлечь». +- **Состояние.** Если загрузчик сменили программой, которая не пишет + `bootstate.txt`, подсветка Legacy может быть устаревшей до следующей смены + из приложения. +- Приложение не форматирует и не восстанавливает флешку — для этого нужен + ПК-установщик. + +## Безопасность + +- Запись выполняется только после проверки маркеров и таблицы разделов. +- Перед каждой Legacy-записью сохраняется 1 МБ. +- Данные разделов не затрагиваются: меняются только загрузочные области и + файлы загрузчиков. +- NVRAM UEFI не изменяется. + +## Лицензия + +GPL-3.0-or-later, см. `LICENSE`. Иконка и оформление — Paravis. + +## Что не входит + +- Готовые APK и другие двоичные сборки; +- ключи и сертификаты Secure Boot, подписанные EFI; +- образы Windows, `Data.pf`, `WindowsESD.pf`; +- сторонние библиотеки: приложение использует только Android API. diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..38656ff --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,27 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'ru.paravis.usbprobe' + compileSdk 34 + + defaultConfig { + applicationId 'ru.paravis.usbprobe' + minSdk 26 + targetSdk 34 + versionCode 1 + versionName '0.1' + } + + buildTypes { + release { + minifyEnabled false + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5aec463 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/legacy/bootmgr-pbr.bin b/app/src/main/assets/legacy/bootmgr-pbr.bin new file mode 100644 index 0000000..81fd0e0 Binary files /dev/null and b/app/src/main/assets/legacy/bootmgr-pbr.bin differ diff --git a/app/src/main/assets/legacy/g4d-mbr.bin b/app/src/main/assets/legacy/g4d-mbr.bin new file mode 100644 index 0000000..5f005c8 Binary files /dev/null and b/app/src/main/assets/legacy/g4d-mbr.bin differ diff --git a/app/src/main/assets/legacy/g4d-pbr.bin b/app/src/main/assets/legacy/g4d-pbr.bin new file mode 100644 index 0000000..a91f629 Binary files /dev/null and b/app/src/main/assets/legacy/g4d-pbr.bin differ diff --git a/app/src/main/assets/legacy/nt60-mbr.bin b/app/src/main/assets/legacy/nt60-mbr.bin new file mode 100644 index 0000000..23c5617 Binary files /dev/null and b/app/src/main/assets/legacy/nt60-mbr.bin differ diff --git a/app/src/main/java/ru/paravis/usbprobe/MainActivity.java b/app/src/main/java/ru/paravis/usbprobe/MainActivity.java new file mode 100644 index 0000000..0fb4c50 --- /dev/null +++ b/app/src/main/java/ru/paravis/usbprobe/MainActivity.java @@ -0,0 +1,1791 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2026 Paravis + +package ru.paravis.usbprobe; + +import android.app.Activity; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.PackageManager; +import android.graphics.Typeface; +import android.hardware.usb.UsbConstants; +import android.hardware.usb.UsbDevice; +import android.hardware.usb.UsbDeviceConnection; +import android.hardware.usb.UsbEndpoint; +import android.hardware.usb.UsbInterface; +import android.hardware.usb.UsbManager; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.storage.StorageManager; +import android.os.storage.StorageVolume; +import android.view.Gravity; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.ScrollView; +import android.widget.TextView; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Locale; + +public class MainActivity extends Activity { + + private static final String ACTION_USB_PERMISSION = "ru.paravis.usbprobe.USB_PERMISSION"; + private static final int TIMEOUT_MS = 5000; + + private UsbManager usbManager; + private UsbDevice device; + private TextView statusView; + private TextView infoView; + private TextView outputView; + private Button permissionButton; + private Button readButton; + private Button ejectButton; + private Button fileButton; + private Button xorButton; + private Button mgrButton; + private Button g4dButton; + private Button grubButton; + private Button uefiMgrButton; + private Button uefiGrubButton; + private Button uefiXorButton; + private ProgressBar progressBar; + private Button refreshButton; + private boolean markersOk; + private boolean checking; + private boolean dialogOpen; + private boolean xorAvailable; + private boolean mgrAvailable; + private boolean g4dAvailable; + private boolean grubAvailable; + private boolean uefiMgrAvailable; + private boolean uefiGrubAvailable; + private boolean uefiXorAvailable; + private int currentLegacy = -1; + private int currentUefi = -1; + private boolean receiverRegistered; + private boolean busy; + + private final BroadcastReceiver permissionReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (!ACTION_USB_PERMISSION.equals(intent.getAction())) { + return; + } + synchronized (this) { + UsbDevice granted = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); + boolean ok = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false); + if (granted != null && ok) { + device = granted; + statusView.setText("Доступ к USB получен"); + updateButtons(); + checkParavis(); + } else { + statusView.setText("Доступ к USB не выдан"); + } + updateInfo(); + } + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + usbManager = (UsbManager) getSystemService(Context.USB_SERVICE); + setContentView(buildUi()); + getWindow().setStatusBarColor(0xFF1E2A44); + getWindow().getDecorView().setSystemUiVisibility(0); + } + + @Override + protected void onStart() { + super.onStart(); + IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); + if (Build.VERSION.SDK_INT >= 33) { + registerReceiver(permissionReceiver, filter, Context.RECEIVER_EXPORTED); + } else { + registerReceiver(permissionReceiver, filter); + } + receiverRegistered = true; + } + + @Override + protected void onStop() { + if (receiverRegistered) { + unregisterReceiver(permissionReceiver); + receiverRegistered = false; + } + super.onStop(); + } + + @Override + protected void onResume() { + super.onResume(); + refreshDevices(); + } + + private View buildUi() { + ScrollView scroll = new ScrollView(this); + scroll.setBackgroundColor(0xFFF1F4F9); + + LinearLayout root = new LinearLayout(this); + root.setOrientation(LinearLayout.VERTICAL); + scroll.addView(root); + + LinearLayout header = new LinearLayout(this); + header.setOrientation(LinearLayout.VERTICAL); + header.setBackgroundColor(0xFF1E2A44); + header.setPadding(24, 18, 24, 14); + + TextView title = new TextView(this); + title.setText("Paravis Flash"); + title.setTextSize(24); + title.setTextColor(0xFFFFFFFF); + title.setTypeface(Typeface.DEFAULT_BOLD); + header.addView(title); + + TextView subtitle = new TextView(this); + subtitle.setText("Смена загрузчика флешки"); + subtitle.setTextSize(13); + subtitle.setTextColor(0xFFC7D0E0); + header.addView(subtitle); + + root.addView(header, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); + + LinearLayout content = new LinearLayout(this); + content.setOrientation(LinearLayout.VERTICAL); + content.setPadding(24, 18, 24, 24); + root.addView(content); + + statusView = new TextView(this); + statusView.setText("Поиск USB-устройств…"); + statusView.setTextSize(16); + statusView.setTextColor(0xFF14202E); + statusView.setPadding(0, 0, 0, 6); + content.addView(statusView); + + infoView = new TextView(this); + infoView.setTextSize(13); + infoView.setTypeface(Typeface.MONOSPACE); + infoView.setTextColor(0xFF6B7280); + infoView.setTextIsSelectable(true); + infoView.setPadding(0, 0, 0, 12); + content.addView(infoView); + + LinearLayout tools = new LinearLayout(this); + tools.setOrientation(LinearLayout.HORIZONTAL); + + refreshButton = new Button(this); + refreshButton.setText("Обновить"); + refreshButton.setTextSize(14); + refreshButton.setAllCaps(false); + compactButton(refreshButton); + refreshButton.setOnClickListener(v -> refreshDevices()); + int gap = (int) (8 * getResources().getDisplayMetrics().density); + LinearLayout.LayoutParams refreshLp = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); + refreshLp.rightMargin = gap; + tools.addView(refreshButton, refreshLp); + + permissionButton = new Button(this); + permissionButton.setText("Доступ к USB"); + permissionButton.setTextSize(14); + permissionButton.setAllCaps(false); + permissionButton.setEnabled(false); + compactButton(permissionButton); + permissionButton.setOnClickListener(v -> requestPermission()); + LinearLayout.LayoutParams permissionLp = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); + permissionLp.leftMargin = gap; + tools.addView(permissionButton, permissionLp); + + LinearLayout.LayoutParams toolsLp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + toolsLp.bottomMargin = (int) (10 * getResources().getDisplayMetrics().density); + content.addView(tools, toolsLp); + + fileButton = new Button(this); + fileButton.setText("Выдать доступ к файлам"); + fileButton.setTextSize(14); + fileButton.setAllCaps(false); + compactButton(fileButton); + fileButton.setOnClickListener(v -> { + if (hasFileAccess()) { + statusView.setText("Доступ к файлам: есть"); + } else { + requestFileAccess(); + } + }); + LinearLayout.LayoutParams fileLp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + fileLp.bottomMargin = 12; + content.addView(fileButton, fileLp); + + progressBar = new ProgressBar(this, null, + android.R.attr.progressBarStyleHorizontal); + progressBar.setIndeterminate(true); + progressBar.setVisibility(View.GONE); + progressBar.setIndeterminateTintList( + android.content.res.ColorStateList.valueOf(0xFF9BB8E8)); + content.addView(progressBar, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); + + addSection(content, "LEGACY BIOS"); + xorButton = addAction(content, "XorBoot", v -> confirmLegacy(LegacyType.XOR)); + mgrButton = addAction(content, "Bootmgr", v -> confirmLegacy(LegacyType.MGR)); + g4dButton = addAction(content, "Grub4Dos", v -> confirmLegacy(LegacyType.G4D)); + grubButton = addAction(content, "Grub2", v -> confirmLegacy(LegacyType.GRUB2)); + + addSection(content, "UEFI"); + uefiMgrButton = addAction(content, "Bootmgr", v -> confirmUefi(UefiType.MGR)); + uefiGrubButton = addAction(content, "Grub2", v -> confirmUefi(UefiType.GRUB2)); + uefiXorButton = addAction(content, "XorBoot", v -> confirmUefi(UefiType.XOR)); + + addSection(content, "ДИАГНОСТИКА"); + LinearLayout diagnostics = new LinearLayout(this); + diagnostics.setOrientation(LinearLayout.HORIZONTAL); + diagnostics.setPadding(0, 0, 0, 12); + + ejectButton = new Button(this); + ejectButton.setText("Извлечь накопитель"); + ejectButton.setTextSize(14); + ejectButton.setAllCaps(false); + ejectButton.setEnabled(false); + compactButton(ejectButton); + ejectButton.setOnClickListener(v -> ejectFlash()); + int diagGap = (int) (8 * getResources().getDisplayMetrics().density); + LinearLayout.LayoutParams ejectLp = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); + ejectLp.rightMargin = diagGap; + diagnostics.addView(ejectButton, ejectLp); + + readButton = new Button(this); + readButton.setText("Читать LBA0"); + readButton.setTextSize(14); + readButton.setAllCaps(false); + readButton.setEnabled(false); + compactButton(readButton); + readButton.setOnClickListener(v -> readSectorZero()); + LinearLayout.LayoutParams readLp = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); + readLp.leftMargin = diagGap; + diagnostics.addView(readButton, readLp); + + content.addView(diagnostics); + + outputView = new TextView(this); + outputView.setTextSize(14); + outputView.setTypeface(Typeface.MONOSPACE); + outputView.setTextColor(0xFF14202E); + outputView.setTextIsSelectable(true); + outputView.setGravity(Gravity.START); + content.addView(outputView); + + return scroll; + } + + private void compactButton(Button button) { + float density = getResources().getDisplayMetrics().density; + button.setMinHeight(0); + button.setMinimumHeight(0); + int horizontal = (int) (14 * density); + int vertical = (int) (10 * density); + button.setPadding(horizontal, vertical, horizontal, vertical); + } + private void addSection(LinearLayout parent, String title) { + TextView header = new TextView(this); + header.setText(title); + header.setTextSize(13); + header.setTypeface(Typeface.DEFAULT_BOLD); + header.setTextColor(0xFF6B7280); + header.setPadding(0, 22, 0, 10); + parent.addView(header); + } + + private Button addAction(LinearLayout parent, String text, View.OnClickListener listener) { + Button button = new Button(this); + button.setText(text); + button.setTextSize(17); + button.setAllCaps(false); + button.setEnabled(false); + button.setOnClickListener(listener); + compactButton(button); + LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + lp.bottomMargin = 12; + parent.addView(button, lp); + return button; + } + + private void refreshDevices() { + device = null; + markersOk = false; + if (usbManager == null) { + statusView.setText("USB-служба недоступна"); + updateButtons(); + return; + } + UsbDevice best = null; + int count = 0; + for (UsbDevice d : usbManager.getDeviceList().values()) { + count++; + if (hasMassStorage(d) && best == null) { + best = d; + } + } + device = best; + if (count == 0) { + statusView.setText("USB-устройства не найдены. Подключите флешку через OTG."); + } else if (best == null) { + statusView.setText("Найдено устройств: " + count + ", но накопитель не опознан"); + } else { + statusView.setText("Найдено устройств: " + count + ", выбран накопитель"); + } + updateInfo(); + updateButtons(); + if (device != null && usbManager.hasPermission(device)) { + checkParavis(); + } + } + + private void updateButtons() { + boolean hasUsb = device != null && usbManager != null + && usbManager.hasPermission(device); + boolean files = hasFileAccess(); + boolean idle = !busy && !dialogOpen; + boolean base = hasUsb && files && markersOk && idle; + + refreshButton.setEnabled(idle); + permissionButton.setEnabled(device != null && !hasUsb && idle); + fileButton.setEnabled(hasUsb && !files && idle); + readButton.setEnabled(hasUsb && idle); + ejectButton.setEnabled(hasUsb && markersOk && idle); + + xorButton.setEnabled(base && xorAvailable); + mgrButton.setEnabled(base && mgrAvailable); + g4dButton.setEnabled(base && g4dAvailable); + grubButton.setEnabled(base && grubAvailable); + uefiMgrButton.setEnabled(base && uefiMgrAvailable); + uefiGrubButton.setEnabled(base && uefiGrubAvailable); + uefiXorButton.setEnabled(base && uefiXorAvailable); + + styleButton(refreshButton, false); + styleButton(permissionButton, false); + styleButton(fileButton, false); + styleButton(ejectButton, false); + styleButton(readButton, false); + styleButton(xorButton, currentLegacy == 0); + styleButton(mgrButton, currentLegacy == 1); + styleButton(g4dButton, currentLegacy == 2); + styleButton(grubButton, currentLegacy == 3); + styleButton(uefiMgrButton, currentUefi == 0); + styleButton(uefiGrubButton, currentUefi == 1); + styleButton(uefiXorButton, currentUefi == 2); + + if (progressBar != null) { + progressBar.setVisibility(busy ? View.VISIBLE : View.GONE); + } + } + + private void checkParavis() { + if (device == null || usbManager == null || !usbManager.hasPermission(device)) { + markersOk = false; + updateButtons(); + return; + } + if (!hasFileAccess()) { + markersOk = false; + statusView.setText("Флешка найдена. Для проверки нужен доступ к файлам."); + updateButtons(); + return; + } + if (checking) { + return; + } + checking = true; + statusView.setText("Проверка флешки Paravis…"); + new Thread(() -> { + File paravis = findParavisRoot(); + if (paravis == null) { + try { + Thread.sleep(400); + } catch (InterruptedException ignored) { + } + paravis = findParavisRoot(); + } + File data = findDataRoot(paravis); + boolean markers = false; + String message; + boolean xorA = false; + boolean mgrA = false; + boolean g4dA = false; + boolean grubA = false; + boolean uMgrA = false; + boolean uGrubA = false; + boolean uXorA = false; + + if (paravis == null) { + message = "Раздел PARAVIS не найден. Если запись уже выполнялась — переподключите флешку."; + } else if (!new File(paravis, "efi/Paravis/Boot/NOT.DEL").exists()) { + message = "На разделе PARAVIS нет efi/Paravis/Boot/NOT.DEL."; + } else if (data == null) { + message = "Раздел DATA не найден."; + } else if (!new File(data, "ISO/Ventoy/NOT.DEL").exists()) { + message = "На разделе DATA нет ISO/Ventoy/NOT.DEL."; + } else { + markers = true; + File boot = new File(paravis, "efi/Paravis/Boot"); + xorA = isFile(boot, "xor/xmbr.bin") && isFile(boot, "xor/xpbr.bin"); + mgrA = isFile(boot, "mgr/bootmgr"); + g4dA = isFile(boot, "g4d/grldr"); + grubA = isFile(boot, "grub2/bios/boot.img") && isFile(boot, "grub2/bios/core.img"); + uMgrA = isFile(boot, "mgr/UEFI/bootx64.efi") + && isFile(boot, "mgr/UEFI/bootia32.efi"); + uGrubA = isFile(boot, "loaders/grub2/bootx64.efi") + && isFile(boot, "loaders/grub2/fbx64.efi") + && isFile(boot, "loaders/grub2/mmx64.efi"); + uXorA = isFile(boot, "xor/UEFI/bootx64.efi") + && isFile(boot, "xor/UEFI/bootia32.efi"); + + StringBuilder missing = new StringBuilder(); + if (!xorA) missing.append(" XorBoot"); + if (!mgrA) missing.append(" Bootmgr"); + if (!g4dA) missing.append(" Grub4Dos"); + if (!grubA) missing.append(" Grub2"); + if (!uMgrA) missing.append(" UEFI Bootmgr"); + if (!uGrubA) missing.append(" UEFI Grub2"); + if (!uXorA) missing.append(" UEFI XorBoot"); + + message = "Флешка Paravis проверена."; + if (missing.length() > 0) { + message += "\nНет файлов:" + missing; + } + } + + int legacy = -1; + int uefi = -1; + if (markers) { + uefi = readUefiState(paravis); + if (uefi < 0) { + uefi = detectUefi(paravis); + } + legacy = readLegacyState(paravis); + } + + final boolean result = markers; + final String text = message; + final int fLegacy = legacy; + final int fUefi = uefi; + final boolean fXor = xorA; + final boolean fMgr = mgrA; + final boolean fG4d = g4dA; + final boolean fGrub = grubA; + final boolean fUMgr = uMgrA; + final boolean fUGrub = uGrubA; + final boolean fUXor = uXorA; + runOnUiThread(() -> { + checking = false; + markersOk = result; + currentLegacy = fLegacy; + currentUefi = fUefi; + xorAvailable = fXor; + mgrAvailable = fMgr; + g4dAvailable = fG4d; + grubAvailable = fGrub; + uefiMgrAvailable = fUMgr; + uefiGrubAvailable = fUGrub; + uefiXorAvailable = fUXor; + statusView.setText(text); + updateButtons(); + }); + }).start(); + } + + private static boolean isFile(File base, String relative) { + return new File(base, relative).isFile(); + } + + private byte[] readFileBytes(File file) { + try { + return java.nio.file.Files.readAllBytes(file.toPath()); + } catch (Exception e) { + return null; + } + } + + private boolean copyFileBytes(File source, File destination) { + try (InputStream in = new java.io.FileInputStream(source); + FileOutputStream out = new FileOutputStream(destination)) { + byte[] buffer = new byte[65536]; + int read; + while ((read = in.read(buffer)) > 0) { + out.write(buffer, 0, read); + } + out.flush(); + out.getFD().sync(); + return destination.length() == source.length(); + } catch (Exception e) { + return false; + } + } + + private File findDataRoot(File paravisRoot) { + try { + StorageManager manager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); + for (StorageVolume volume : manager.getStorageVolumes()) { + File dir = null; + if (Build.VERSION.SDK_INT >= 30) { + dir = volume.getDirectory(); + } + if (dir == null || dir.equals(paravisRoot)) { + continue; + } + if (new File(dir, "ISO/Ventoy/NOT.DEL").exists()) { + return dir; + } + } + } catch (Exception ignored) { + } + File[] children = new File("/storage").listFiles(); + if (children != null) { + for (File dir : children) { + if (dir.equals(paravisRoot)) { + continue; + } + if (new File(dir, "ISO/Ventoy/NOT.DEL").exists()) { + return dir; + } + } + } + return null; + } + + private void updateInfo() { + if (device == null) { + infoView.setText(""); + return; + } + StringBuilder sb = new StringBuilder(); + String product = null; + try { + product = device.getProductName(); + } catch (SecurityException ignored) { + } + if (product != null && !product.trim().isEmpty()) { + sb.append(product.trim()); + } else { + sb.append(device.getDeviceName()); + } + sb.append(String.format(Locale.US, " (%04x:%04x)%n", + device.getVendorId(), device.getProductId())); + + int protocol = -1; + for (int i = 0; i < device.getInterfaceCount(); i++) { + UsbInterface iface = device.getInterface(i); + if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_MASS_STORAGE + && iface.getInterfaceSubclass() == 6) { + protocol = iface.getInterfaceProtocol(); + break; + } + } + if (protocol == 0x50) { + sb.append("USB: BOT, raw доступен"); + } else if (protocol == 0x62) { + sb.append("USB: UAS, raw недоступен"); + } else { + sb.append(String.format(Locale.US, "USB: protocol 0x%02x", protocol)); + } + sb.append('\n'); + + boolean granted = usbManager != null && usbManager.hasPermission(device); + sb.append("Доступ: ").append(granted ? "есть" : "нет"); + sb.append(" · Файлы: ").append(hasFileAccess() ? "есть" : "нет"); + infoView.setText(sb.toString()); + } + + private static boolean hasMassStorage(UsbDevice d) { + for (int i = 0; i < d.getInterfaceCount(); i++) { + UsbInterface iface = d.getInterface(i); + if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_MASS_STORAGE + && iface.getInterfaceSubclass() == 6) { + return true; + } + } + return false; + } + + private void requestPermission() { + if (device == null) { + return; + } + Intent intent = new Intent(ACTION_USB_PERMISSION); + intent.setPackage(getPackageName()); + int flags = Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0; + PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, flags); + usbManager.requestPermission(device, pi); + statusView.setText("Запрос доступа… подтвердите в системном окне"); + } + + private void readSectorZero() { + final UsbDevice target = device; + if (target == null) { + return; + } + if (!usbManager.hasPermission(target)) { + statusView.setText("Сначала выдайте доступ к USB"); + return; + } + busy = true; + updateButtons(); + statusView.setText("Чтение сектора 0…"); + new Thread(() -> { + String result; + try { + result = probeStorage(target); + } catch (Exception e) { + result = "Ошибка: " + e.getClass().getSimpleName() + ": " + e.getMessage(); + } + final String text = result; + runOnUiThread(() -> { + outputView.setText(text); + statusView.setText("Готово"); + busy = false; + updateButtons(); + }); + }).start(); + } + + private String probeStorage(UsbDevice target) { + UsbInterface storage = null; + for (int i = 0; i < target.getInterfaceCount(); i++) { + UsbInterface iface = target.getInterface(i); + if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_MASS_STORAGE + && iface.getInterfaceSubclass() == 6) { + storage = iface; + break; + } + } + if (storage == null) { + return "Накопитель не найден"; + } + if (storage.getInterfaceProtocol() == 0x62) { + return "Устройство работает через UAS.\nБез root чтение/запись секторов на этом телефоне недоступны."; + } + if (storage.getInterfaceProtocol() != 0x50) { + return String.format(Locale.US, "Неизвестный протокол 0x%02x", + storage.getInterfaceProtocol()); + } + + UsbEndpoint in = null; + UsbEndpoint out = null; + for (int e = 0; e < storage.getEndpointCount(); e++) { + UsbEndpoint ep = storage.getEndpoint(e); + if (ep.getType() != UsbConstants.USB_ENDPOINT_XFER_BULK) { + continue; + } + if (ep.getDirection() == UsbConstants.USB_DIR_IN) { + in = ep; + } else { + out = ep; + } + } + if (in == null || out == null) { + return "Bulk-эндпоинты не найдены"; + } + + UsbDeviceConnection connection = usbManager.openDevice(target); + if (connection == null) { + return "Не удалось открыть устройство"; + } + try { + if (!connection.claimInterface(storage, true)) { + return "Интерфейс занят системой.\nИзвлеките накопитель в настройках Android и повторите."; + } + try { + return probeLuns(connection, in, out); + } finally { + connection.releaseInterface(storage); + } + } finally { + connection.close(); + } + } + + private String probeLuns(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out) { + StringBuilder report = new StringBuilder(); + byte[] mbr = null; + int mbrLun = -1; + + for (int lun = 0; lun < 4; lun++) { + byte[] inquiry = scsiIn(connection, in, out, lun, inquiryCdb(36), 36); + if (inquiry == null || inquiry.length < 36) { + report.append("LUN ").append(lun).append(": нет устройства\n"); + continue; + } + String vendor = ascii(inquiry, 8, 8); + String product = ascii(inquiry, 16, 16); + long blockSize = 512; + long lastLba = -1; + byte[] cap = scsiIn(connection, in, out, lun, readCapacityCdb(), 8); + if (cap != null && cap.length == 8) { + lastLba = ((long) (cap[0] & 0xFF) << 24) | ((long) (cap[1] & 0xFF) << 16) + | ((long) (cap[2] & 0xFF) << 8) | (cap[3] & 0xFF); + blockSize = ((long) (cap[4] & 0xFF) << 24) | ((long) (cap[5] & 0xFF) << 16) + | ((long) (cap[6] & 0xFF) << 8) | (cap[7] & 0xFF); + if (blockSize <= 0 || blockSize > 65536) { + blockSize = 512; + } + } + report.append(String.format(Locale.US, + "LUN %d: %s / %s, блок %d, секторов %d%n", + lun, vendor, product, blockSize, lastLba < 0 ? -1 : lastLba + 1)); + + byte[] data = scsiIn(connection, in, out, lun, read10Cdb(0, 1), (int) blockSize); + if (data == null) { + report.append(" чтение LBA0 не удалось\n"); + continue; + } + boolean sig = data.length >= 512 + && (data[510] & 0xFF) == 0x55 && (data[511] & 0xFF) == 0xAA; + report.append(" LBA0: ").append(sig ? "MBR найден" : "подписи 0x55AA нет").append('\n'); + if (sig && mbr == null) { + mbr = data; + mbrLun = lun; + } + } + + report.append('\n'); + if (mbr != null) { + report.append("Рабочий LUN: ").append(mbrLun).append("\n\n"); + report.append(formatSector(mbr)); + } else { + report.append("MBR не найден ни на одном LUN.\n"); + } + return report.toString(); + } + + private static String ascii(byte[] b, int off, int len) { + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) { + int c = b[off + i] & 0xFF; + sb.append(c >= 32 && c < 127 ? (char) c : ' '); + } + return sb.toString().trim(); + } + + private static byte[] inquiryCdb(int length) { + return new byte[]{0x12, 0, 0, 0, (byte) length, 0}; + } + + private static byte[] readCapacityCdb() { + return new byte[]{0x25, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + } + + private static byte[] read10Cdb(long lba, int blocks) { + return new byte[]{0x28, 0, + (byte) (lba >> 24), (byte) (lba >> 16), (byte) (lba >> 8), (byte) lba, + 0, (byte) (blocks >> 8), (byte) blocks, 0}; + } + + private byte[] scsiIn(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out, + int lun, byte[] cdb, int dataLen) { + byte[] cbw = new byte[31]; + putIntLE(cbw, 0, 0x43425355); + putIntLE(cbw, 4, 1); + putIntLE(cbw, 8, dataLen); + cbw[12] = (byte) 0x80; + cbw[13] = (byte) lun; + cbw[14] = (byte) cdb.length; + System.arraycopy(cdb, 0, cbw, 15, cdb.length); + + if (connection.bulkTransfer(out, cbw, cbw.length, TIMEOUT_MS) != cbw.length) { + clearHalt(connection, in, out); + return null; + } + byte[] csw = new byte[13]; + if (dataLen > 0) { + byte[] data = new byte[dataLen]; + int got = 0; + while (got < dataLen) { + int chunk = Math.min(16384, dataLen - got); + byte[] part = new byte[chunk]; + int n = connection.bulkTransfer(in, part, chunk, TIMEOUT_MS); + if (n <= 0) { + clearHalt(connection, in, out); + return null; + } + System.arraycopy(part, 0, data, got, n); + got += n; + } + if (connection.bulkTransfer(in, csw, csw.length, TIMEOUT_MS) != csw.length) { + clearHalt(connection, in, out); + return null; + } + if (getIntLE(csw, 0) != 0x53425355 || (csw[12] & 0xFF) != 0) { + clearHalt(connection, in, out); + return null; + } + return data; + } + if (connection.bulkTransfer(in, csw, csw.length, TIMEOUT_MS) != csw.length) { + clearHalt(connection, in, out); + return null; + } + if (getIntLE(csw, 0) != 0x53425355 || (csw[12] & 0xFF) != 0) { + clearHalt(connection, in, out); + return null; + } + return new byte[0]; + } + + private static void clearHalt(UsbDeviceConnection connection, + UsbEndpoint in, UsbEndpoint out) { + try { + connection.controlTransfer(0x02, 0x01, 0, out.getAddress(), null, 0, 1000); + connection.controlTransfer(0x02, 0x01, 0, in.getAddress(), null, 0, 1000); + } catch (Exception ignored) { + } + } + + private interface StorageTask { + String run(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out) throws Exception; + } + + private UsbInterface findStorage(UsbDevice target) { + for (int i = 0; i < target.getInterfaceCount(); i++) { + UsbInterface iface = target.getInterface(i); + if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_MASS_STORAGE + && iface.getInterfaceSubclass() == 6) { + return iface; + } + } + return null; + } + + private String withStorage(UsbDevice target, StorageTask task) { + UsbInterface storage = findStorage(target); + if (storage == null) { + return "Накопитель не найден"; + } + if (storage.getInterfaceProtocol() == 0x62) { + return "Устройство работает через UAS.\nБез root запись секторов недоступна."; + } + if (storage.getInterfaceProtocol() != 0x50) { + return String.format(Locale.US, "Неизвестный протокол 0x%02x", + storage.getInterfaceProtocol()); + } + UsbEndpoint in = null; + UsbEndpoint out = null; + for (int e = 0; e < storage.getEndpointCount(); e++) { + UsbEndpoint ep = storage.getEndpoint(e); + if (ep.getType() != UsbConstants.USB_ENDPOINT_XFER_BULK) { + continue; + } + if (ep.getDirection() == UsbConstants.USB_DIR_IN) { + in = ep; + } else { + out = ep; + } + } + if (in == null || out == null) { + return "Bulk-эндпоинты не найдены"; + } + UsbDeviceConnection connection = usbManager.openDevice(target); + if (connection == null) { + return "Не удалось открыть устройство"; + } + try { + if (!connection.claimInterface(storage, true)) { + return "Интерфейс занят системой.\nИзвлеките накопитель в настройках Android и повторите."; + } + try { + return task.run(connection, in, out); + } catch (Exception e) { + return "Ошибка: " + e.getClass().getSimpleName() + ": " + e.getMessage(); + } finally { + connection.releaseInterface(storage); + } + } finally { + connection.close(); + } + } + + private enum LegacyType { XOR, MGR, G4D, GRUB2 } + + private void ejectFlash() { + if (Build.VERSION.SDK_INT < 24) { + statusView.setText("Безопасное извлечение не поддерживается на этой версии Android."); + return; + } + File root = findParavisRoot(); + if (root == null) { + statusView.setText("Флешка не найдена. Возможно, она уже извлечена."); + return; + } + try { + StorageManager manager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); + String uuid = root.getName(); + for (StorageVolume volume : manager.getStorageVolumes()) { + File dir = null; + if (Build.VERSION.SDK_INT >= 30) { + dir = volume.getDirectory(); + } + String volumeUuid = volume.getUuid(); + boolean match = (dir != null && dir.equals(root)) + || (uuid != null && uuid.equalsIgnoreCase(volumeUuid)); + if (!match) { + continue; + } + Intent intent = new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS); + statusView.setText("В настройках выберите накопитель и нажмите «Извлечь»."); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + return; + } + statusView.setText("Том для извлечения не найден."); + } catch (Exception e) { + statusView.setText("Не удалось извлечь: " + e.getMessage()); + } + } + + private void confirmLegacy(LegacyType type) { + if (device == null || busy || dialogOpen) { + return; + } + String name; + String extra = ""; + switch (type) { + case XOR: + name = "XorBoot"; + break; + case MGR: + name = "Bootmgr"; + extra = "\n\nВ корне флешки должен быть файл bootmgr."; + break; + case G4D: + name = "Grub4Dos"; + extra = "\n\nВ корне флешки должен быть файл grldr."; + break; + default: + name = "Grub2"; + break; + } + android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this) + .setTitle("Сменить загрузчик на " + name + "?") + .setMessage("Будет перезаписан MBR и загрузочный сектор раздела PARAVIS.\n" + + "Данные разделов не затрагиваются.\n" + + "Перед записью сохраняется 1 МБ." + extra) + .setPositiveButton("Записать", (dialog, which) -> runLegacy(type)) + .setNegativeButton("Отмена", null); + showDialog(builder); + } + + private void runLegacy(LegacyType type) { + final UsbDevice target = device; + if (target == null || busy) { + return; + } + busy = true; + updateButtons(); + statusView.setText("Запись загрузчика…"); + new Thread(() -> { + String prep = prepareFiles(type); + byte[] first = null; + byte[] second = null; + if (prep == null && (type == LegacyType.GRUB2 || type == LegacyType.XOR)) { + File root = findParavisRoot(); + if (root == null) { + prep = "Не найден раздел PARAVIS."; + } else { + File boot = new File(root, "efi/Paravis/Boot"); + if (type == LegacyType.GRUB2) { + first = readFileBytes(new File(boot, "grub2/bios/boot.img")); + second = readFileBytes(new File(boot, "grub2/bios/core.img")); + } else { + first = readFileBytes(new File(boot, "xor/xmbr.bin")); + second = readFileBytes(new File(boot, "xor/xpbr.bin")); + } + if (first == null || second == null) { + prep = "Нет файлов загрузчика на флешке."; + } + } + } + if (prep == null) { + File stateRoot = findParavisRoot(); + if (stateRoot != null) { + writeBootState(stateRoot, legacyIndex(type), currentUefi); + } + } + final byte[] f1 = first; + final byte[] f2 = second; + final String result = prep != null ? prep + : withStorage(target, (connection, in, out) -> + writeLegacy(connection, in, out, type, f1, f2)); + runOnUiThread(() -> { + outputView.setText(result); + statusView.setText("Готово"); + if (result != null && result.contains("записан и проверен")) { + currentLegacy = type == LegacyType.XOR ? 0 + : type == LegacyType.MGR ? 1 + : type == LegacyType.G4D ? 2 : 3; + } + busy = false; + updateButtons(); + }); + }).start(); + } + + private String writeLegacy(UsbDeviceConnection connection, UsbEndpoint in, + UsbEndpoint out, LegacyType type, + byte[] first, byte[] second) { + byte[] mbr = read10(connection, in, out, 0, 1); + if (mbr == null || mbr.length != 512) { + return "Не удалось прочитать MBR — запись отменена"; + } + if ((mbr[510] & 0xFF) != 0x55 || (mbr[511] & 0xFF) != 0xAA) { + return "На диске нет подписи MBR — запись отменена"; + } + if (!looksLikeParavis(mbr)) { + return "Таблица разделов не похожа на Paravis — запись отменена"; + } + + byte[] backupData = read10(connection, in, out, 0, 2048); + if (backupData == null) { + return "Не удалось сохранить бэкап — запись отменена"; + } + String backupPath = saveBackup(backupData); + if (backupPath == null) { + return "Не удалось сохранить бэкап — запись отменена"; + } + + int partStart = partitionStart(mbr); + if (partStart <= 0) { + return "Не удалось найти раздел PARAVIS — запись отменена"; + } + + + boolean okMbr; + boolean okPbr = true; + boolean okCore = true; + int coreSectors = 0; + + switch (type) { + case GRUB2: { + byte[] bootImage = first; + byte[] core = second; + if (bootImage == null || bootImage.length < 440 + || core == null || core.length < 512) { + return "Нет файлов efi/Paravis/Boot/grub2/bios/boot.img или core.img"; + } + byte[] image = mbrImage(bootImage, mbr); + if (!write10(connection, in, out, 0, image)) { + return "Ошибка записи LBA0\nБэкап: " + backupPath; + } + coreSectors = (core.length + 511) / 512; + byte[] padded = java.util.Arrays.copyOf(core, coreSectors * 512); + if (!write10(connection, in, out, 1, padded)) { + return "Ошибка записи core.img\nБэкап: " + backupPath; + } + okMbr = sameSector(image, read10(connection, in, out, 0, 1)); + byte[] check = read10(connection, in, out, 1, coreSectors); + okCore = check != null && regionEquals(padded, check, core.length); + break; + } + case XOR: { + byte[] code = first; + byte[] pbrCode = second; + if (code == null || code.length < 1024 || pbrCode == null) { + return "Нет файлов efi/Paravis/Boot/xor/xmbr.bin или xpbr.bin"; + } + byte[] image = mbrImage(code, mbr); + if (!write10(connection, in, out, 0, image)) { + return "Ошибка записи LBA0\nБэкап: " + backupPath; + } + byte[] rest = java.util.Arrays.copyOfRange(code, 512, code.length); + if (rest.length > 0 && !write10(connection, in, out, 1, rest)) { + return "Ошибка записи MBR XorBoot\nБэкап: " + backupPath; + } + okPbr = writePbr(connection, in, out, partStart, pbrCode); + okMbr = sameSector(image, read10(connection, in, out, 0, 1)); + break; + } + case MGR: + case G4D: { + String mbrAsset = type == LegacyType.MGR + ? "legacy/nt60-mbr.bin" : "legacy/g4d-mbr.bin"; + String pbrAsset = type == LegacyType.MGR + ? "legacy/bootmgr-pbr.bin" : "legacy/g4d-pbr.bin"; + byte[] code = readAsset(mbrAsset); + byte[] pbrCode = readAsset(pbrAsset); + if (code == null || code.length < 440 || pbrCode == null) { + return "Не найдены встроенные MBR/PBR"; + } + byte[] image = mbrImage(code, mbr); + if (!write10(connection, in, out, 0, image)) { + return "Ошибка записи LBA0\nБэкап: " + backupPath; + } + okPbr = writePbr(connection, in, out, partStart, pbrCode); + okMbr = sameSector(image, read10(connection, in, out, 0, 1)); + break; + } + default: + return "Неизвестный загрузчик"; + } + + String name = type == LegacyType.XOR ? "XorBoot" + : type == LegacyType.MGR ? "Bootmgr" + : type == LegacyType.G4D ? "Grub4Dos" : "Grub2"; + + StringBuilder sb = new StringBuilder(); + boolean ok = okMbr && okPbr && okCore; + sb.append(name).append(ok ? " записан и проверен" : " записан, проверка не прошла"); + sb.append("\n\nLBA0: ").append(okMbr ? "совпадает" : "не совпадает"); + if (type != LegacyType.GRUB2) { + sb.append("\nPBR: ").append(okPbr ? "совпадает" : "не совпадает"); + } + if (type == LegacyType.GRUB2) { + sb.append("\ncore.img: ").append(okCore ? "совпадает" : "не совпадает"); + sb.append("\nсекторов core: ").append(coreSectors); + } + sb.append("\n\nБэкап 1 МБ:\n").append(backupPath); + sb.append("\n\nДля следующих операций переподключите флешку."); + return sb.toString(); + } + + private boolean writePbr(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out, + int partStart, byte[] code) { + if (code == null || code.length != 512) { + return false; + } + byte[] current = read10(connection, in, out, partStart, 1); + if (current == null || current.length != 512) { + return false; + } + byte[] image = code.clone(); + for (int i = 0x0B; i <= 0x59; i++) { + image[i] = current[i]; + } + if (!write10(connection, in, out, partStart, image)) { + return false; + } + return sameSector(image, read10(connection, in, out, partStart, 1)); + } + + private static byte[] mbrImage(byte[] code, byte[] current) { + byte[] image = new byte[512]; + System.arraycopy(code, 0, image, 0, 440); + System.arraycopy(current, 440, image, 440, 72); + return image; + } + + private static boolean sameSector(byte[] expected, byte[] actual) { + return actual != null && actual.length >= 512 + && java.util.Arrays.equals(java.util.Arrays.copyOf(expected, 512), + java.util.Arrays.copyOf(actual, 512)); + } + + private static int partitionStart(byte[] mbr) { + int fallback = -1; + for (int i = 0; i < 4; i++) { + int off = 446 + i * 16; + int type = mbr[off + 4] & 0xFF; + int start = (mbr[off + 8] & 0xFF) | ((mbr[off + 9] & 0xFF) << 8) + | ((mbr[off + 10] & 0xFF) << 16) | ((mbr[off + 11] & 0xFF) << 24); + if (start <= 0) { + continue; + } + if (type == 0x0C || type == 0x0B) { + return start; + } + if (fallback < 0) { + fallback = start; + } + } + return fallback; + } + + private boolean hasFileAccess() { + if (Build.VERSION.SDK_INT >= 30) { + return Environment.isExternalStorageManager(); + } + return checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) + == PackageManager.PERMISSION_GRANTED; + } + + private void requestFileAccess() { + try { + if (Build.VERSION.SDK_INT >= 30) { + Intent intent = new Intent( + android.provider.Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); + intent.setData(android.net.Uri.parse("package:" + getPackageName())); + startActivity(intent); + } else if (Build.VERSION.SDK_INT >= 23) { + requestPermissions(new String[]{ + android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 42); + } + } catch (Exception e) { + try { + startActivity(new Intent( + android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)); + } catch (Exception ignored) { + } + } + } + + private File findParavisRoot() { + try { + StorageManager manager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); + for (StorageVolume volume : manager.getStorageVolumes()) { + File dir = null; + if (Build.VERSION.SDK_INT >= 30) { + dir = volume.getDirectory(); + } + if (dir == null) { + continue; + } + if (new File(dir, "efi/Paravis/Boot/NOT.DEL").exists()) { + return dir; + } + } + } catch (Exception ignored) { + } + File[] children = new File("/storage").listFiles(); + if (children != null) { + for (File dir : children) { + if (new File(dir, "efi/Paravis/Boot/NOT.DEL").exists()) { + return dir; + } + } + } + return null; + } + + private String prepareFiles(LegacyType type) { + if (!hasFileAccess()) { + return (type == LegacyType.MGR || type == LegacyType.G4D) + ? "Нужен доступ ко всем файлам — нажмите «Выдать доступ к файлам»." + : null; + } + File root = findParavisRoot(); + if (root == null) { + return (type == LegacyType.MGR || type == LegacyType.G4D) + ? "Не найден раздел PARAVIS." : null; + } + File boot = new File(root, "efi/Paravis/Boot"); + try { + switch (type) { + case MGR: { + File source = new File(boot, "mgr/bootmgr"); + if (!source.isFile()) { + return "Нет файла efi/Paravis/Boot/mgr/bootmgr."; + } + if (!copyFileBytes(source, new File(root, "bootmgr"))) { + return "Не удалось скопировать bootmgr."; + } + new File(root, "grldr").delete(); + break; + } + case G4D: { + File source = new File(boot, "g4d/grldr"); + if (!source.isFile()) { + return "Нет файла efi/Paravis/Boot/g4d/grldr."; + } + if (!copyFileBytes(source, new File(root, "grldr"))) { + return "Не удалось скопировать grldr."; + } + new File(root, "bootmgr").delete(); + break; + } + default: + new File(root, "bootmgr").delete(); + new File(root, "grldr").delete(); + break; + } + } catch (Exception e) { + return "Ошибка доступа к файлам: " + e.getMessage(); + } + return null; + } + + private boolean copyAssetToFile(String asset, File destination) { + return writeAssetToFile(asset, destination) > 0; + } + + private long writeAssetToFile(String asset, File destination) { + try (InputStream in = getAssets().open(asset); + FileOutputStream out = new FileOutputStream(destination)) { + byte[] buffer = new byte[65536]; + int read; + long total = 0; + while ((read = in.read(buffer)) > 0) { + out.write(buffer, 0, read); + total += read; + } + return total > 0 ? total : -1; + } catch (Exception e) { + return -1; + } + } + + private enum UefiType { MGR, GRUB2, XOR } + + private void confirmUefi(UefiType type) { + if (busy || dialogOpen) { + return; + } + String name = type == UefiType.MGR ? "Bootmgr" + : type == UefiType.XOR ? "XorBoot" : "Grub2"; + android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this) + .setTitle("UEFI: " + name + "?") + .setMessage("Файлы в \\efi\\boot будут заменены.\n" + + "Данные разделов не затрагиваются.\n" + + "Загрузчик UEFI в NVRAM не меняется.") + .setPositiveButton("Записать", (dialog, which) -> runUefi(type)) + .setNegativeButton("Отмена", null); + showDialog(builder); + } + + private void showDialog(android.app.AlertDialog.Builder builder) { + dialogOpen = true; + updateButtons(); + android.app.AlertDialog dialog = builder.create(); + dialog.setOnDismissListener(d -> { + dialogOpen = false; + updateButtons(); + }); + dialog.show(); + } + + private void runUefi(UefiType type) { + if (busy) { + return; + } + busy = true; + updateButtons(); + statusView.setText("Копирование UEFI…"); + new Thread(() -> { + String result = writeUefi(type); + runOnUiThread(() -> { + outputView.setText(result); + statusView.setText("Готово"); + if (result != null && result.contains("установлен")) { + currentUefi = type == UefiType.MGR ? 0 + : type == UefiType.XOR ? 2 : 1; + } + busy = false; + updateButtons(); + }); + }).start(); + } + + private String writeUefi(UefiType type) { + if (!hasFileAccess()) { + return "Нужен доступ ко всем файлам — нажмите «Выдать доступ к файлам»."; + } + File root = findParavisRoot(); + if (root == null) { + return "Не найден раздел PARAVIS на флешке."; + } + File sourceBase = new File(root, "efi/Paravis/Boot"); + File bootDir = new File(root, "efi/boot"); + if (!bootDir.exists() && !bootDir.mkdirs()) { + return "Не удалось создать папку efi/boot."; + } + for (String name : new String[]{"bootx64.efi", "bootia32.efi", "fbx64.efi", "mmx64.efi"}) { + new File(bootDir, name).delete(); + } + + String label; + String base; + String[] names; + switch (type) { + case MGR: + label = "Bootmgr"; + base = "mgr/UEFI"; + names = new String[]{"bootx64.efi", "bootia32.efi"}; + break; + case XOR: + label = "XorBoot"; + base = "xor/UEFI"; + names = new String[]{"bootx64.efi", "bootia32.efi"}; + break; + default: + label = "Grub2"; + base = "loaders/grub2"; + names = new String[]{"bootx64.efi", "fbx64.efi", "mmx64.efi"}; + break; + } + + StringBuilder report = new StringBuilder(); + report.append("UEFI ").append(label).append(" установлен\n\n"); + for (String name : names) { + File source = new File(sourceBase, base + "/" + name); + if (!source.isFile()) { + return "Нет файла efi/Paravis/Boot/" + base + "/" + name; + } + File destination = new File(bootDir, name); + if (!copyFileBytes(source, destination)) { + return "Не удалось скопировать " + name + "."; + } + report.append(name).append(" ").append(destination.length()).append(" байт\n"); + } + writeBootState(root, currentLegacy, uefiIndex(type)); + report.append('\n').append(bootDir.getAbsolutePath()); + return report.toString(); + } + + private int detectUefi(File paravis) { + if (paravis == null) { + return -1; + } + File src = new File(paravis, "efi/Paravis/Boot"); + File dst = new File(paravis, "efi/boot"); + if (!dst.isDirectory()) { + return -1; + } + if (filesEqual(new File(dst, "bootx64.efi"), + new File(src, "loaders/grub2/bootx64.efi")) + && filesEqual(new File(dst, "fbx64.efi"), + new File(src, "loaders/grub2/fbx64.efi")) + && filesEqual(new File(dst, "mmx64.efi"), + new File(src, "loaders/grub2/mmx64.efi"))) { + return 1; + } + if (filesEqual(new File(dst, "bootx64.efi"), + new File(src, "mgr/UEFI/bootx64.efi")) + && filesEqual(new File(dst, "bootia32.efi"), + new File(src, "mgr/UEFI/bootia32.efi"))) { + return 0; + } + if (filesEqual(new File(dst, "bootx64.efi"), + new File(src, "xor/UEFI/bootx64.efi")) + && filesEqual(new File(dst, "bootia32.efi"), + new File(src, "xor/UEFI/bootia32.efi"))) { + return 2; + } + return -1; + } + + private static boolean filesEqual(File first, File second) { + if (!first.isFile() || !second.isFile() || first.length() != second.length()) { + return false; + } + try (InputStream in1 = new java.io.FileInputStream(first); + InputStream in2 = new java.io.FileInputStream(second)) { + byte[] buffer1 = new byte[8192]; + byte[] buffer2 = new byte[8192]; + while (true) { + int read1 = in1.read(buffer1); + int read2 = in2.read(buffer2); + if (read1 != read2) { + return false; + } + if (read1 < 0) { + return true; + } + for (int i = 0; i < read1; i++) { + if (buffer1[i] != buffer2[i]) { + return false; + } + } + } + } catch (Exception e) { + return false; + } + } + + private void styleButton(Button button, boolean active) { + if (button == null) { + return; + } + boolean enabled = button.isEnabled(); + int background; + int border; + int text; + if (active) { + background = 0xFFD8E4F8; + border = 0xFF9BB8E8; + text = 0xFF2E4A78; + } else if (!enabled) { + background = 0xFFE9ECF1; + border = 0xFFD5DAE2; + text = 0xFFA7AEBA; + } else { + background = 0xFFFFFFFF; + border = 0xFFBFC9D6; + text = 0xFF14202E; + } + float density = getResources().getDisplayMetrics().density; + android.graphics.drawable.GradientDrawable drawable = + new android.graphics.drawable.GradientDrawable(); + drawable.setColor(background); + drawable.setCornerRadius(3 * density); + drawable.setStroke((int) ((active ? 2 : 1) * density), border); + button.setBackground(drawable); + button.setTextColor(text); + button.setAllCaps(false); + } + + private int readLegacyState(File paravis) { + if (paravis == null) { + return -1; + } + File state = new File(paravis, "efi/Paravis/Boot/bootstate.txt"); + if (!state.isFile()) { + return -1; + } + try { + for (String line : java.nio.file.Files.readAllLines(state.toPath())) { + String value = line.trim(); + if (value.startsWith("legacy=")) { + try { + return Integer.parseInt(value.substring(7).trim()); + } catch (NumberFormatException ignored) { + return -1; + } + } + } + } catch (Exception ignored) { + } + return -1; + } + + private int readUefiState(File paravis) { + if (paravis == null) { + return -1; + } + File state = new File(paravis, "efi/Paravis/Boot/bootstate.txt"); + if (!state.isFile()) { + return -1; + } + try { + for (String line : java.nio.file.Files.readAllLines(state.toPath())) { + String value = line.trim(); + if (value.startsWith("uefi=")) { + try { + return Integer.parseInt(value.substring(5).trim()); + } catch (NumberFormatException ignored) { + return -1; + } + } + } + } catch (Exception ignored) { + } + return -1; + } + private void writeBootState(File paravis, int legacy, int uefi) { + if (paravis == null) { + return; + } + File state = new File(paravis, "efi/Paravis/Boot/bootstate.txt"); + String text = "legacy=" + legacy + "\nuefi=" + uefi + "\n"; + try (FileOutputStream out = new FileOutputStream(state)) { + out.write(text.getBytes(java.nio.charset.StandardCharsets.UTF_8)); + out.flush(); + out.getFD().sync(); + } catch (Exception ignored) { + } + } + + private static int legacyIndex(LegacyType type) { + switch (type) { + case XOR: + return 0; + case MGR: + return 1; + case G4D: + return 2; + default: + return 3; + } + } + + private static int uefiIndex(UefiType type) { + switch (type) { + case MGR: + return 0; + case XOR: + return 2; + default: + return 1; + } + } + + private static boolean looksLikeParavis(byte[] mbr) { + boolean fat32 = false; + boolean vtoy = false; + for (int i = 0; i < 4; i++) { + int off = 446 + i * 16; + int type = mbr[off + 4] & 0xFF; + long start = ((long) (mbr[off + 8] & 0xFF)) + | ((long) (mbr[off + 9] & 0xFF) << 8) + | ((long) (mbr[off + 10] & 0xFF) << 16) + | ((long) (mbr[off + 11] & 0xFF) << 24); + if (start <= 0) { + continue; + } + if (type == 0x0C || type == 0x0B) { + fat32 = true; + } + if (type == 0xEF) { + vtoy = true; + } + } + return fat32 && vtoy; + } + + private static boolean regionEquals(byte[] expected, byte[] actual, int length) { + for (int i = 0; i < length; i++) { + if (expected[i] != actual[i]) { + return false; + } + } + return true; + } + + private byte[] readAsset(String name) { + try (java.io.InputStream stream = getAssets().open(name)) { + java.io.ByteArrayOutputStream buffer = new java.io.ByteArrayOutputStream(); + byte[] chunk = new byte[8192]; + int read; + while ((read = stream.read(chunk)) > 0) { + buffer.write(chunk, 0, read); + } + return buffer.toByteArray(); + } catch (Exception e) { + return null; + } + } + + private String saveBackup(byte[] data) { + try { + java.io.File dir = getExternalFilesDir(null); + if (dir == null) { + dir = getFilesDir(); + } + String name = "paravis-mbr-" + + new java.text.SimpleDateFormat("yyyyMMdd-HHmmss", Locale.US) + .format(new java.util.Date()) + ".bin"; + java.io.File file = new java.io.File(dir, name); + try (java.io.FileOutputStream out = new java.io.FileOutputStream(file)) { + out.write(data); + } + return file.getAbsolutePath(); + } catch (Exception e) { + return null; + } + } + + private byte[] read10(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out, + long lba, int blocks) { + return scsiIn(connection, in, out, 0, read10Cdb(lba, blocks), blocks * 512); + } + + private boolean write10(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out, + long lba, byte[] data) { + int blocks = (data.length + 511) / 512; + byte[] padded = java.util.Arrays.copyOf(data, blocks * 512); + return scsiOut(connection, in, out, 0, write10Cdb(lba, blocks), padded); + } + + private static byte[] write10Cdb(long lba, int blocks) { + return new byte[]{0x2A, 0, (byte) (lba >> 24), (byte) (lba >> 16), + (byte) (lba >> 8), (byte) lba, 0, (byte) (blocks >> 8), (byte) blocks, 0}; + } + + private boolean scsiOut(UsbDeviceConnection connection, UsbEndpoint in, UsbEndpoint out, + int lun, byte[] cdb, byte[] data) { + byte[] cbw = new byte[31]; + putIntLE(cbw, 0, 0x43425355); + putIntLE(cbw, 4, 2); + putIntLE(cbw, 8, data.length); + cbw[12] = 0; + cbw[13] = (byte) lun; + cbw[14] = (byte) cdb.length; + System.arraycopy(cdb, 0, cbw, 15, cdb.length); + + if (connection.bulkTransfer(out, cbw, cbw.length, TIMEOUT_MS) != cbw.length) { + clearHalt(connection, in, out); + return false; + } + int offset = 0; + while (offset < data.length) { + int chunk = Math.min(16384, data.length - offset); + byte[] part = new byte[chunk]; + System.arraycopy(data, offset, part, 0, chunk); + int sent = connection.bulkTransfer(out, part, chunk, TIMEOUT_MS); + if (sent != chunk) { + clearHalt(connection, in, out); + return false; + } + offset += sent; + } + byte[] csw = new byte[13]; + if (connection.bulkTransfer(in, csw, csw.length, TIMEOUT_MS) != csw.length) { + clearHalt(connection, in, out); + return false; + } + if (getIntLE(csw, 0) != 0x53425355 || (csw[12] & 0xFF) != 0) { + clearHalt(connection, in, out); + return false; + } + return true; + } + + private static byte[] slice(byte[] src, int offset, int length) { + byte[] out = new byte[length]; + System.arraycopy(src, offset, out, 0, length); + return out; + } + + private static void putIntLE(byte[] b, int off, int v) { + b[off] = (byte) v; + b[off + 1] = (byte) (v >> 8); + b[off + 2] = (byte) (v >> 16); + b[off + 3] = (byte) (v >> 24); + } + + private static int getIntLE(byte[] b, int off) { + return (b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8) + | ((b[off + 2] & 0xFF) << 16) | ((b[off + 3] & 0xFF) << 24); + } + + private static String formatSector(byte[] sector) { + StringBuilder sb = new StringBuilder(); + boolean signature = (sector[510] & 0xFF) == 0x55 && (sector[511] & 0xFF) == 0xAA; + sb.append("Сектор 0 прочитан, 512 байт\n"); + sb.append("Подпись 0x55AA: ").append(signature ? "есть (MBR)" : "нет").append('\n'); + sb.append(String.format(Locale.US, "Disk signature: %02X%02X%02X%02X%n", + sector[440], sector[441], sector[442], sector[443])); + sb.append("\nТаблица разделов:\n"); + for (int i = 0; i < 4; i++) { + int off = 446 + i * 16; + int type = sector[off + 4] & 0xFF; + long start = getIntLE(sector, off + 8) & 0xFFFFFFFFL; + long count = getIntLE(sector, off + 12) & 0xFFFFFFFFL; + sb.append(String.format(Locale.US, + " #%d type=0x%02x start=%d sectors=%d%n", i + 1, type, start, count)); + } + sb.append("\nПервые 512 байт:\n"); + for (int row = 0; row < 512; row += 16) { + sb.append(String.format(Locale.US, "%04x ", row)); + for (int c = 0; c < 16; c++) { + sb.append(String.format(Locale.US, "%02x ", sector[row + c] & 0xFF)); + } + sb.append('\n'); + } + return sb.toString(); + } +} diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..be43858 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..be43858 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..92bf584 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..dc55879 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..92bf584 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..a3b6c3a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..8a20edd Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..a3b6c3a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..280717d Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f805d3a Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..280717d Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..6125452 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..46c02a5 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..6125452 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..13f4750 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e487fa9 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..13f4750 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..1c24a6b --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #1E2A44 + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..4897847 --- /dev/null +++ b/build.gradle @@ -0,0 +1,3 @@ +plugins { + id 'com.android.application' version '8.5.2' apply false +} diff --git a/docs/icon.png b/docs/icon.png new file mode 100644 index 0000000..ff09ca6 Binary files /dev/null and b/docs/icon.png differ diff --git a/docs/screenshot.png b/docs/screenshot.png new file mode 100644 index 0000000..81cc05f Binary files /dev/null and b/docs/screenshot.png differ diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..ed2d02a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +android.useAndroidX=false +android.nonTransitiveRClass=true diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..adcd7a9 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} +rootProject.name = 'ParavisUsbProbe' +include ':app'