Repository: SakuraKoi/DgLabUnlocker Branch: master Commit: 5312e57ed046 Files: 83 Total size: 178.6 KB Directory structure: gitextract_ue4k0bt2/ ├── .github/ │ └── stale.yml ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── assets/ │ │ └── xposed_init │ ├── java/ │ │ ├── dev/ │ │ │ └── sakurakooi/ │ │ │ └── dglabunlocker/ │ │ │ └── XposedModuleInit.java │ │ └── sakura/ │ │ └── kooi/ │ │ └── dglabunlocker/ │ │ ├── XposedModuleInit.java │ │ ├── features/ │ │ │ ├── AbstractFeature.java │ │ │ ├── ClickableFeature.java │ │ │ ├── ToggleableFeature.java │ │ │ ├── WithExtraConfiguration.java │ │ │ ├── clickable/ │ │ │ │ ├── FeatureExportWave.java │ │ │ │ ├── FeatureIgnoreBatteryOptimization.java │ │ │ │ └── FeatureImportWave.java │ │ │ └── toggleable/ │ │ │ ├── FeatureBypassRemoteMaxStrength.java │ │ │ ├── FeatureEnforceLocalStrength.java │ │ │ ├── FeatureEnforceRemoteMaxStrength.java │ │ │ ├── FeatureUnlockRemoteMax.java │ │ │ └── FeatureWebsocketRpc.java │ │ ├── hooks/ │ │ │ ├── AbstractHook.java │ │ │ ├── business/ │ │ │ │ ├── HookActivityResult.java │ │ │ │ ├── HookBluetoothStrengthSender.java │ │ │ │ ├── HookCurrentActivity.java │ │ │ │ ├── HookLongPressStrengthHandler.java │ │ │ │ ├── HookProtocolStrengthDecoder.java │ │ │ │ ├── HookRemoteSettingsDialog.java │ │ │ │ ├── HookStrengthButton.java │ │ │ │ ├── HookStrengthText.java │ │ │ │ └── HookWaveAdapterCollector.java │ │ │ └── preload/ │ │ │ ├── HookDisableForceUpdate.java │ │ │ ├── HookSettingsDialog.java │ │ │ └── HookUpdateClientSide.java │ │ ├── remote/ │ │ │ └── WebsocketRPC.java │ │ ├── ui/ │ │ │ ├── ClickableFeatureDialog.java │ │ │ ├── ConfigurationDialog.java │ │ │ ├── DevTestDialog.java │ │ │ ├── ExtraConfigurationDialog.java │ │ │ ├── ModuleDialog.java │ │ │ ├── StatusDialog.java │ │ │ └── WaveSelectDialog.java │ │ ├── utils/ │ │ │ ├── DgLabVersion.java │ │ │ ├── ExceptionLogger.java │ │ │ ├── FieldAccessor.java │ │ │ ├── ModuleException.java │ │ │ ├── ModuleUtils.java │ │ │ ├── UiUtils.java │ │ │ └── WaveUtils.java │ │ ├── variables/ │ │ │ ├── Accessors.java │ │ │ ├── HookRegistry.java │ │ │ ├── InjectPoints.java │ │ │ ├── ModuleSettings.java │ │ │ └── ResourceInject.java │ │ └── ver/ │ │ ├── AbstractVersionedCompatibilityProvider.java │ │ ├── Version126.java │ │ ├── Version131.java │ │ └── Version132.java │ └── res/ │ ├── drawable/ │ │ ├── button_yellow.xml │ │ ├── check_off.xml │ │ ├── check_on.xml │ │ ├── ic_launcher_foreground.xml │ │ ├── icon_settings.xml │ │ ├── settings_bg.xml │ │ ├── switch_close_thumb.xml │ │ ├── switch_close_track.xml │ │ ├── switch_open_thumb.xml │ │ └── switch_open_track.xml │ ├── mipmap-anydpi │ ├── mipmap-anydpi-v26/ │ │ └── ic_launcher.xml │ └── values/ │ ├── arrays.xml │ ├── colors.xml │ ├── ic_launcher_background.xml │ └── strings.xml ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/stale.yml ================================================ # Number of days of inactivity before an issue becomes stale daysUntilStale: 15 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 # Issues with these labels will never be considered stale exemptLabels: - 'Status: Confirmed' - 'Status: In Progress' - 'Status: Unplanned' - 'Status: Needs review' - 'Type: Pinned' # Label to use when marking an issue as stale staleLabel: 'Status: Archived' # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false ================================================ FILE: .gitignore ================================================ *.iml .gradle /local.properties /.idea/caches /.idea/libraries /.idea/modules.xml /.idea/workspace.xml /.idea/navEditor.xml /.idea/assetWizardSettings.xml .DS_Store /build /captures .externalNativeBuild .cxx local.properties /.idea/ /app/release/ *.apk ================================================ FILE: LICENSE ================================================ 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 . ================================================ FILE: README.md ================================================ # DG-Lab Unlocker 某APP的奇怪xposed模块 ![](https://img.shields.io/badge/Module-Xposed-green?style=for-the-badge&logo=Android&logoColor=white) ![](https://img.shields.io/github/license/SakuraKoi/DgLabUnlocker?style=for-the-badge) ![](https://img.shields.io/github/languages/top/SakuraKoi/DgLabUnlocker?style=for-the-badge) ![](https://img.shields.io/github/downloads/SakuraKoi/DgLabUnlocker/total?style=for-the-badge) ![](https://img.shields.io/github/v/release/SakuraKoi/DgLabUnlocker?style=for-the-badge) ## 暂停更新 官方APP的新功能整挺好\ 强度上限什么的安全功能都安排上了\ ~~波形导入导出. 远程协议之类的也被官方抄走了~~ 目前来看这个模块应该暂时没有继续开发的必要\ (主要是...想不出来还有什么脑洞可以整活了x 所以, **暂时停止模块开发** > ~~除非咱想到了什么新活, 但是只靠官方又整不出来~~ --- ### 说明 > 当前适配版本: `1.2.6` `1.3.1` `1.3.2`\ > 项目开发将以当前支持的最新版本为目标, 在老版本中不保证所有功能可用 ### 功能 - **解锁远程控制最大强度到276**\ 最高100完全不够用好吧\ `再也不用担心high到一半自己起来调强度了 (超小声` - **暴力锁死基础强度**\ 理论上拦截所有远程加基础强度的BUG, 有效避免突然惨遭弹射起飞\ `有坏蛋试了半小时翻倍bug, 咱不说是谁` - **无视远程最大强度限制**\ 字面意思, 想拉多高拉多高 (坏.jpg\ `不要拿去干坏事qwq` - **强制确保远程强度不超过限制**\ 避免魔改客户端搞事情\ `上面那个功能的防御` - **导入/导出波形**\ 以JSON格式从文件导入波形/导出波形到文件\ `用别人的波形算不算也是一种NTR` - **开放强度调整接口**\ 对外开放[Websocket RPC服务](https://github.com/SakuraKoi/DgLabUnlocker/wiki/Websocket-RPC-Spec)端口, 便于程序员整点花活 #8\ `此功能最终解释权归永仪所有`\ `咱不对小可爱被玩坏承担任何责任` ================================================ FILE: app/.gitignore ================================================ /build /pos ================================================ FILE: app/build.gradle ================================================ plugins { id 'com.android.application' } android { compileSdk 31 defaultConfig { applicationId "sakura.kooi.dglabunlocker" minSdk 26 targetSdk 31 versionCode 9 versionName "1.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } } dependencies { implementation 'org.java-websocket:Java-WebSocket:1.5.3' implementation 'com.google.code.gson:gson:2.9.0' compileOnly 'de.robv.android.xposed:api:82' compileOnly "org.projectlombok:lombok:1.18.24" annotationProcessor 'org.projectlombok:lombok:1.18.24' compileOnly 'androidx.annotation:annotation:1.3.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } ================================================ FILE: app/proguard-rules.pro ================================================ -keep class sakura.kooi.dglabunlocker.XposedModuleInit -repackageclasses -allowaccessmodification -overloadaggressively -keepattributes SourceFile,LineNumberTable -renamesourcefileattribute SourceFile ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/assets/xposed_init ================================================ dev.sakurakooi.dglabunlocker.XposedModuleInit ================================================ FILE: app/src/main/java/dev/sakurakooi/dglabunlocker/XposedModuleInit.java ================================================ package dev.sakurakooi.dglabunlocker; import de.robv.android.xposed.IXposedHookInitPackageResources; import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.IXposedHookZygoteInit; import de.robv.android.xposed.callbacks.XC_InitPackageResources; import de.robv.android.xposed.callbacks.XC_LoadPackage; public class XposedModuleInit implements IXposedHookLoadPackage, IXposedHookZygoteInit, IXposedHookInitPackageResources { @Override public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable { } @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { } @Override public void initZygote(StartupParam startupParam) throws Throwable { } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/XposedModuleInit.java ================================================ package sakura.kooi.dglabunlocker; import static sakura.kooi.dglabunlocker.utils.DgLabVersion.*; import android.content.Context; import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; import java.util.HashSet; import de.robv.android.xposed.IXposedHookInitPackageResources; import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.IXposedHookZygoteInit; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.callbacks.XC_InitPackageResources; import de.robv.android.xposed.callbacks.XC_LoadPackage; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.preload.HookSettingsDialog; import sakura.kooi.dglabunlocker.ui.StatusDialog; import sakura.kooi.dglabunlocker.utils.ModuleException; import sakura.kooi.dglabunlocker.utils.ModuleUtils; import sakura.kooi.dglabunlocker.variables.HookRegistry; import sakura.kooi.dglabunlocker.variables.ModuleSettings; import sakura.kooi.dglabunlocker.variables.ResourceInject; import sakura.kooi.dglabunlocker.ver.AbstractVersionedCompatibilityProvider; import sakura.kooi.dglabunlocker.ver.Version126; import sakura.kooi.dglabunlocker.ver.Version131; import sakura.kooi.dglabunlocker.ver.Version132; public class XposedModuleInit implements IXposedHookLoadPackage, IXposedHookZygoteInit, IXposedHookInitPackageResources { @NonNull private static AbstractVersionedCompatibilityProvider detectAppVersion(Context context) { AbstractVersionedCompatibilityProvider versionedFieldInitializer; int versionCode = ModuleUtils.getAppVersion(context); HookRegistry.versionCode = versionCode; switch (versionCode) { case V_1_3_3: versionedFieldInitializer = new Version132(); // FIXME StatusDialog.currentLoadedVersion = "1.3.3"; break; case V_1_3_2: versionedFieldInitializer = new Version132(); StatusDialog.currentLoadedVersion = "1.3.2"; break; case V_1_3_1: versionedFieldInitializer = new Version131(); StatusDialog.currentLoadedVersion = "1.3.1"; break; case V_1_2_6: versionedFieldInitializer = new Version126(); StatusDialog.currentLoadedVersion = "1.2.6"; break; default: versionedFieldInitializer = new Version126(); StatusDialog.currentLoadedVersion = null; } return versionedFieldInitializer; } @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) { Log.i("DgLabUnlocker", "Init Loading: running on app " + lpparam.packageName); if (!lpparam.packageName.equals("com.bjsm.dungeonlab")) { Log.e("DgLabUnlocker", "Init Loading: app not match! " + lpparam.packageName); return; } Log.i("DgLabUnlocker", "Init Loading: found target app " + lpparam.packageName); try { Class.forName("com.netease.nis.wrapper.MyApplication", false, lpparam.classLoader); XposedHelpers.findAndHookMethod("com.netease.nis.wrapper.MyApplication", lpparam.classLoader, "attachBaseContext", Context.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Context context = (Context) param.args[0]; ClassLoader classLoader = context.getClassLoader(); onAppLoaded(context, classLoader); } }); return; } catch (ClassNotFoundException e) { Log.i("DgLabUnlocker", "nesec packer not found, try hook as tencent packed..."); } try { Class.forName("com.wrapper.proxyapplication.WrapperProxyApplication", false, lpparam.classLoader); XposedHelpers.findAndHookMethod("com.wrapper.proxyapplication.WrapperProxyApplication", lpparam.classLoader, "attachBaseContext", Context.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Context context = (Context) param.args[0]; ClassLoader classLoader = context.getClassLoader(); onAppLoaded(context, classLoader); } }); return; } catch (ClassNotFoundException e) { Log.i("DgLabUnlocker", "tencent packer not found, try hook as unpacked app..."); } try { XposedHelpers.findAndHookMethod("com.bjsm.dungeonlab.global.BaseLocalApplication", lpparam.classLoader, "onCreate", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { Context context = (Context) param.thisObject; ClassLoader classLoader = context.getClassLoader(); onAppLoaded(context, classLoader); } }); } catch (Exception e) { } } private void onAppLoaded(Context context, ClassLoader classLoader) { Log.i("DgLabUnlocker", "Hook Loading: App loaded! Trying to take over the world..."); ModuleUtils.applicationContext = context; // region load configuration Log.i("DgLabUnlocker", "Hook Loading: Injecting settings dialog..."); try { HookSettingsDialog.apply(context, classLoader); StatusDialog.moduleSettingsDialogInject = true; } catch (Exception e) { ModuleUtils.logError("DgLabUnlocker", "An error occurred while injecting settings dialog", e); Toast.makeText(context, "DG-Lab Unlocker 加载失败", Toast.LENGTH_LONG).show(); return; } // endregion // region detect app version and initialize reflection try { detectAppVersion(context).initializeAccessors(classLoader); Log.i("DgLabUnlocker", "Hook Loading: Fields lookup done"); StatusDialog.fieldsLookup = true; } catch (Exception e) { ModuleUtils.logError("DgLabUnlocker", "An error occurred in initializeAccessors()", e); Toast.makeText(context, "DG-Lab Unlocker 加载失败", Toast.LENGTH_LONG).show(); return; } // endregion // region load features and collect hook classes HashSet>> hookClasses = new HashSet<>(HookRegistry.preloadHooks); for (Class featureClass : HookRegistry.features) { try { AbstractFeature feature = featureClass.newInstance(); hookClasses.addAll(feature.getRequiredHooks()); HookRegistry.featureInstances.put(featureClass, feature); } catch (Exception e) { ModuleUtils.logError("DgLabUnlocker", "Could not initialize feature " + featureClass.getName(), e); } } // endregion // region inject hooks for (Class> hookClass : hookClasses) { try { AbstractHook hook = hookClass.newInstance(); if (!hook.isUnsupported()) { hook.applyHook(context, classLoader); hook.setHooked(true); Log.i("DgLabUnlocker", "Hook " + hook.getName() + " loaded"); } HookRegistry.hookInstances.put(hookClass, hook); } catch (Exception e) { ModuleUtils.logError("DgLabUnlocker", "Could not apply hook " + hookClass.getName(), e); } } // endregion // region register hook handlers for (Class featureClass : HookRegistry.features) { AbstractFeature feature = null; try { feature = HookRegistry.featureInstances.get(featureClass); if (feature == null) continue; if (feature.isUnsupported()) { ModuleUtils.logError("DgLabUnlocker", "Cannot register feature " + featureClass.getName() + ": minVersion not match"); continue; } for (Class> hookClass : feature.getRequiredHooks()) { AbstractHook hook = HookRegistry.hookInstances.get(hookClass); if (hook == null) throw new ModuleException("Cannot register feature " + featureClass.getName() + " to hook " + hookClass.getName() + ": hook not initialized"); if (!hook.isHooked()) throw new ModuleException("Cannot register feature " + featureClass.getName() + " to hook " + hookClass.getName() + ": hook not working"); hook.registerHandler(feature); } Log.i("DgLabUnlocker", "Feature " + feature.getName() + " registered"); } catch (Exception e) { ModuleUtils.logError("DgLabUnlocker", "Could not register hook handler for feature " + featureClass.getName(), e); if (feature != null) feature.setLoaded(false); } } // endregion // region load configurations Log.i("DgLabUnlocker", "Hook Loading: Loading configuration..."); try { ModuleSettings.loadConfiguration(context); Log.i("DgLabUnlocker", "Hook Loading: Configuration loaded"); } catch (Exception e) { ModuleUtils.logError("DgLabUnlocker", "An error occurred in loadConfiguration()", e); } // endregion // region test features Log.i("DgLabUnlocker", "Hook Loading: Testing features..."); for (AbstractFeature feature : HookRegistry.featureInstances.values()) { try { if (feature.isUnsupported()) continue; feature.initialize(); feature.setLoaded(true); } catch (Exception e) { feature.setLoaded(false); ModuleUtils.logError("DgLabUnlocker", "An error occurred while testing feature " + feature.getClass().getName(), e); } } // endregion Toast.makeText(context, "DG-Lab Unlocker 注入成功\nGithub @SakuraKoi/DgLabUnlocker", Toast.LENGTH_LONG).show(); } @Override public void initZygote(StartupParam startupParam) { ResourceInject.modulePath = startupParam.modulePath; } @Override public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) { if (!resparam.packageName.equals("com.bjsm.dungeonlab")) return; ResourceInject.doResourceInject(resparam); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/AbstractFeature.java ================================================ package sakura.kooi.dglabunlocker.features; import java.util.List; import lombok.Getter; import lombok.Setter; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.variables.HookRegistry; public abstract class AbstractFeature { @Getter @Setter private boolean isLoaded = false; public abstract String getName(); public abstract List>> getRequiredHooks(); public boolean isUnsupported() { for (Class> hook : getRequiredHooks()) { AbstractHook hookInstance = HookRegistry.hookInstances.get(hook); // every required hook's instance should has been created if (hookInstance == null) return true; if (hookInstance.isUnsupported()) return true; } return false; } public abstract ClientSide getSide(); public void initialize() throws Exception {} public enum ClientSide { ALL, CONTROLLER, CONTROLLED; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/ClickableFeature.java ================================================ package sakura.kooi.dglabunlocker.features; import android.content.Context; import android.widget.LinearLayout; public abstract class ClickableFeature extends AbstractFeature { public abstract void inflateFeatureLayout(Context context, LinearLayout layout); } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/ToggleableFeature.java ================================================ package sakura.kooi.dglabunlocker.features; import lombok.Getter; public abstract class ToggleableFeature extends AbstractFeature { @Getter private boolean isEnabled = false; @Override public String getName() { return getSettingName(); } public abstract String getSettingName(); public abstract String getSettingDesc(); public abstract String getConfigurationKey(); public void setEnabled(boolean enabled) { updateFeatureStatus(enabled); this.isEnabled = enabled; } public abstract void updateFeatureStatus(boolean enabled); } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/WithExtraConfiguration.java ================================================ package sakura.kooi.dglabunlocker.features; import android.content.Context; import android.view.View; import java.lang.annotation.Retention; import sakura.kooi.dglabunlocker.ui.ExtraConfigurationDialog; import sakura.kooi.dglabunlocker.utils.UiUtils; public interface WithExtraConfiguration { default View createSettingButton(Context context) { return UiUtils.createSettingButton(context, e -> { new ExtraConfigurationDialog(context, (AbstractFeature) this).show(); }); } @Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @interface ExtraConfigurationField { String key(); String name(); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/clickable/FeatureExportWave.java ================================================ package sakura.kooi.dglabunlocker.features.clickable; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.util.Log; import android.widget.LinearLayout; import android.widget.Toast; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Map; import sakura.kooi.dglabunlocker.features.ClickableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookActivityResult; import sakura.kooi.dglabunlocker.hooks.business.HookCurrentActivity; import sakura.kooi.dglabunlocker.ui.WaveSelectDialog; import sakura.kooi.dglabunlocker.utils.UiUtils; import sakura.kooi.dglabunlocker.utils.WaveUtils; public class FeatureExportWave extends ClickableFeature implements HookActivityResult.IActivityResultInterceptor { private List pendingWaves; @Override public String getName() { return "导出波形"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookCurrentActivity.class, HookActivityResult.class); } @Override public ClientSide getSide() { return ClientSide.ALL; } @Override public void inflateFeatureLayout(Context context, LinearLayout layout) { UiUtils.createButton(layout, "导出波形", e -> { displayExportWaveDialog(); }); } private void displayExportWaveDialog() { Context context = HookCurrentActivity.getCurrentActivity(); Map waveList; try { waveList = WaveUtils.getWaveListWithName(true); } catch (ReflectiveOperationException e) { Log.e("DgLabUnlocker", "An error occurred while getting wave list", e); Toast.makeText(context, "获取波形列表失败", Toast.LENGTH_LONG).show(); return; } new WaveSelectDialog(context, "选择要导出的波形", waveList, selectedWaves -> { if (selectedWaves.isEmpty()) { return; } pendingWaves = selectedWaves; Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("application/json"); intent.putExtra(Intent.EXTRA_TITLE, "DG-Lab_Unlocker_Wave-Export.json"); Log.i("DgLabUnlocker", "Sending ACTION_CREATE_DOCUMENT from activity " + HookCurrentActivity.getCurrentActivity().getClass().getName()); HookCurrentActivity.getCurrentActivity().startActivityForResult(intent, 11451); }).show(); } private JsonArray cleanupWaves(Gson gson, List selectedWaves) { JsonArray out = new JsonArray(); for (Object wave : selectedWaves) { JsonObject element = gson.toJsonTree(wave).getAsJsonObject(); element.remove("selectedStateA"); element.add("selectedStateA", new JsonPrimitive(3)); element.remove("selectedStateB"); element.add("selectedStateB", new JsonPrimitive(3)); element.remove("stateA"); element.add("stateA", new JsonPrimitive(1)); element.remove("stateB"); element.add("stateB", new JsonPrimitive(1)); element.remove("playOrderA"); element.add("playOrderA", new JsonPrimitive(-1)); element.remove("playOrderB"); element.add("playOrderB", new JsonPrimitive(-1)); element.remove("channel"); out.add(element); } return out; } @Override public void onActivityResult(Context context, int requestCode, int resultCode, Intent data) { if (requestCode == 11451 && resultCode == Activity.RESULT_OK) { if (data != null) { Uri uri = data.getData(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String pendingJson = gson.toJson(cleanupWaves(gson, pendingWaves)); try { try (ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "w")) { try (FileOutputStream fileOutputStream = new FileOutputStream(pfd.getFileDescriptor())) { fileOutputStream.write(pendingJson.getBytes(StandardCharsets.UTF_8)); fileOutputStream.flush(); } } Toast.makeText(context, "成功导出了 " + pendingWaves.size() + " 个波形", Toast.LENGTH_LONG).show(); } catch (IOException e) { Log.e("DgLabUnlocker", "An error occurred while writing wave list", e); Toast.makeText(context, "导出波形列表失败", Toast.LENGTH_LONG).show(); } } } } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/clickable/FeatureIgnoreBatteryOptimization.java ================================================ package sakura.kooi.dglabunlocker.features.clickable; import android.Manifest; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.os.PowerManager; import android.provider.Settings; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import java.util.Arrays; import java.util.List; import sakura.kooi.dglabunlocker.features.ClickableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookCurrentActivity; import sakura.kooi.dglabunlocker.utils.UiUtils; public class FeatureIgnoreBatteryOptimization extends ClickableFeature { @Override public String getName() { return "忽略电池优化"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookCurrentActivity.class); } @Override public ClientSide getSide() { return ClientSide.ALL; } @Override public void inflateFeatureLayout(Context context, LinearLayout layout) { TextView btn = UiUtils.createButton(layout, "忽略电池优化", e -> { requestIgnoreBatteryOptimization(context); }); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations("com.bjsm.dungeonlab")) { btn.setEnabled(false); btn.setText("忽略电池优化 (已生效)"); } } private void requestIgnoreBatteryOptimization(Context context) { if (context.checkSelfPermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) == PackageManager.PERMISSION_GRANTED) { @SuppressLint("BatteryLife") Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:com.bjsm.dungeonlab")); context.startActivity(intent); } else { Toast.makeText(context, "请授予所需权限后重试", Toast.LENGTH_LONG).show(); HookCurrentActivity.getCurrentActivity().requestPermissions(new String[] {Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}, 114513); } } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/clickable/FeatureImportWave.java ================================================ package sakura.kooi.dglabunlocker.features.clickable; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.util.Log; import android.widget.LinearLayout; import android.widget.Toast; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import sakura.kooi.dglabunlocker.features.ClickableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookActivityResult; import sakura.kooi.dglabunlocker.hooks.business.HookCurrentActivity; import sakura.kooi.dglabunlocker.hooks.business.HookWaveAdapterCollector; import sakura.kooi.dglabunlocker.ui.WaveSelectDialog; import sakura.kooi.dglabunlocker.utils.UiUtils; import sakura.kooi.dglabunlocker.utils.WaveUtils; import sakura.kooi.dglabunlocker.variables.Accessors; public class FeatureImportWave extends ClickableFeature implements HookActivityResult.IActivityResultInterceptor { @Override public String getName() { return "导入波形"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookCurrentActivity.class, HookActivityResult.class); } @Override public ClientSide getSide() { return ClientSide.ALL; } @Override public void inflateFeatureLayout(Context context, LinearLayout layout) { UiUtils.createButton(layout, "导入波形", e -> { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("application/json"); Log.i("DgLabUnlocker", "Sending ACTION_OPEN_DOCUMENT from activity " + HookCurrentActivity.getCurrentActivity().getClass().getName()); HookCurrentActivity.getCurrentActivity().startActivityForResult(intent, 11452); }); } @Override public void onActivityResult(Context context, int requestCode, int resultCode, Intent data) { if (requestCode == 11452 && resultCode == Activity.RESULT_OK) { if (data != null) { Uri uri = data.getData(); try { try (ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "r")) { try (FileInputStream fileInputStream = new FileInputStream(pfd.getFileDescriptor())) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int nRead; byte[] block = new byte[16384]; while ((nRead = fileInputStream.read(block, 0, block.length)) != -1) { buffer.write(block, 0, nRead); } handleImportedData(buffer.toByteArray()); } } } catch (IOException e) { Log.e("DgLabUnlocker", "An error occurred while reading wave list", e); Toast.makeText(context, "读取波形列表失败", Toast.LENGTH_LONG).show(); } } } } private void handleImportedData(byte[] data) { Gson gson = new Gson(); List waves = gson.fromJson(new String(data), TypeToken.getParameterized(List.class, Accessors.classWaveClassicBean).getType()); LinkedHashMap waveList = waves.stream().collect(Collectors.toMap(wave -> { try { return Accessors.waveName.get(wave); } catch (ReflectiveOperationException e) { Log.e("DgLabUnlocker", "An error occurred while getting wave name", e); return null; } }, wave -> wave, (o1, o2) -> o1, LinkedHashMap::new)); Context context = HookCurrentActivity.getCurrentActivity(); new WaveSelectDialog(context, "选择要导入的波形", waveList, selectedWaves -> { if (selectedWaves.isEmpty()) { return; } Set currentWaveNameList = null; try { currentWaveNameList = WaveUtils.getWaveListWithName(true).keySet(); } catch (ReflectiveOperationException e) { Log.w("DgLabUnlocker", "An error occurred while deduplicating wave name", e); } int success = 0; for (Object wave : selectedWaves) { try { Accessors.funcSaveWave.invoke(8, wave, 1, deduplicateWaveName(currentWaveNameList, Accessors.waveName.get(wave)), 1); success++; } catch (Throwable e) { Log.e("DgLabUnlocker", "An error occurred while importing wave", e); } } boolean refreshed = false; try { refreshWaveList(); refreshed = true; } catch (ReflectiveOperationException e) { Log.e("DgLabUnlocker", "An error occurred while refreshing wave list", e); } Toast.makeText(context, "成功导入" + success + " / " + selectedWaves.size() + " 个波形" + (refreshed ? "" : " (可能需要重启APP以生效)"), Toast.LENGTH_LONG).show(); }).show(); } private String deduplicateWaveName(Set currentWaveNameList, String origName) { if (currentWaveNameList == null) { return origName; } int id = 0; String name = origName; while (currentWaveNameList.contains(name)) { name = origName + ++id; } return name; } private void refreshWaveList() throws ReflectiveOperationException { List waveList = WaveUtils.getWaveList(true); for (Object adapter : HookWaveAdapterCollector.getAdapters()) { try { Accessors.funcSaveWave.invoke(adapter, waveList); } catch (Throwable e) { throw new ReflectiveOperationException(e); } } } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/toggleable/FeatureBypassRemoteMaxStrength.java ================================================ package sakura.kooi.dglabunlocker.features.toggleable; import static sakura.kooi.dglabunlocker.variables.Accessors.localStrengthA; import static sakura.kooi.dglabunlocker.variables.Accessors.localStrengthB; import static sakura.kooi.dglabunlocker.variables.Accessors.maxStrengthA; import static sakura.kooi.dglabunlocker.variables.Accessors.maxStrengthB; import static sakura.kooi.dglabunlocker.variables.Accessors.totalStrengthA; import static sakura.kooi.dglabunlocker.variables.Accessors.totalStrengthB; import android.content.Context; import android.widget.TextView; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookBluetoothStrengthSender; import sakura.kooi.dglabunlocker.hooks.business.HookLongPressStrengthHandler; import sakura.kooi.dglabunlocker.hooks.business.HookStrengthButton; import sakura.kooi.dglabunlocker.hooks.business.HookStrengthText; public class FeatureBypassRemoteMaxStrength extends ToggleableFeature implements HookBluetoothStrengthSender.IBluetoothStrengthSendInterceptor, HookStrengthButton.IStrengthButtonInterceptor, HookLongPressStrengthHandler.IStrengthButtonInterceptor, HookStrengthText.StrengthTextHandler { private final AtomicInteger realMaxA = new AtomicInteger(); private final AtomicInteger realMaxB = new AtomicInteger(); @Override public String getSettingName() { return "主控 | 无视强度上限设置"; } @Override public String getSettingDesc() { return "想拉多高拉多高 (坏.jpg"; } @Override public String getConfigurationKey() { return "FeatureBypassRemoteMaxStrength"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookBluetoothStrengthSender.class, HookStrengthButton.class, HookLongPressStrengthHandler.class, HookStrengthText.class); } @Override public ClientSide getSide() { return ClientSide.CONTROLLER; } @Override public void updateFeatureStatus(boolean enabled) { } // helper method to prevent desync write (filter spoofed max strength) public void updateRealMax() throws ReflectiveOperationException { int maxA = maxStrengthA.get(); if (maxA != 300) realMaxA.set(maxA); int maxB = maxStrengthB.get(); if (maxB != 300) realMaxB.set(maxB); maxStrengthA.set(300); maxStrengthB.set(300); } @Override public void interceptBeforeStrength(Context context, AtomicInteger strengthA, AtomicInteger strengthB) throws ReflectiveOperationException { updateRealMax(); } @Override public void interceptAfterStrength(Context context, AtomicInteger strengthA, AtomicInteger strengthB) throws ReflectiveOperationException { maxStrengthA.set(realMaxA.get()); maxStrengthB.set(realMaxB.get()); } @Override public void beforeStrengthChange(Context context) throws ReflectiveOperationException { updateRealMax(); } @Override public void afterStrengthChange(Context context) throws ReflectiveOperationException { maxStrengthA.set(realMaxA.get()); maxStrengthB.set(realMaxB.get()); } @Override public void interceptStrengthText(TextView textA, TextView textB) throws ReflectiveOperationException { boolean bypassedA = totalStrengthA.get() > localStrengthA.get() + Math.max(1, realMaxA.get()); textA.setTextColor(bypassedA ? 0xffffa500 : 0xffffe99d); boolean bypassedB = totalStrengthB.get() > localStrengthB.get() + Math.max(1, realMaxB.get()); textB.setTextColor(bypassedB ? 0xffffa500 : 0xffffe99d); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/toggleable/FeatureEnforceLocalStrength.java ================================================ package sakura.kooi.dglabunlocker.features.toggleable; import android.content.Context; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookLongPressStrengthHandler; import sakura.kooi.dglabunlocker.hooks.business.HookProtocolStrengthDecoder; import sakura.kooi.dglabunlocker.hooks.business.HookStrengthButton; import sakura.kooi.dglabunlocker.variables.Accessors; public class FeatureEnforceLocalStrength extends ToggleableFeature implements HookProtocolStrengthDecoder.IProtocolDecoderInterceptor, HookStrengthButton.IStrengthButtonInterceptor, HookLongPressStrengthHandler.IStrengthButtonInterceptor{ private AtomicInteger localStrengthA = new AtomicInteger(10); private AtomicInteger localStrengthB = new AtomicInteger(10); @Override public String getSettingName() { return "被控 | 暴力锁死基础强度"; } @Override public String getSettingDesc() { return "有效避免突然惨遭弹射起飞"; } @Override public String getConfigurationKey() { return "FeatureEnforceLocalStrength"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookProtocolStrengthDecoder.class, HookStrengthButton.class, HookLongPressStrengthHandler.class); } @Override public ClientSide getSide() { return ClientSide.CONTROLLED; } @Override public void updateFeatureStatus(boolean enabled) { } @Override public void beforeStrengthDecode(Context context) throws ReflectiveOperationException {} public void afterStrengthDecode(Context context) throws ReflectiveOperationException { Accessors.localStrengthA.set(localStrengthA.get()); Accessors.localStrengthB.set(localStrengthB.get()); } @Override public void beforeStrengthChange(Context context) throws ReflectiveOperationException {} @Override public void afterStrengthChange(Context context) throws ReflectiveOperationException { this.localStrengthA.set(Accessors.localStrengthA.get()); this.localStrengthB.set(Accessors.localStrengthB.get()); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/toggleable/FeatureEnforceRemoteMaxStrength.java ================================================ package sakura.kooi.dglabunlocker.features.toggleable; import android.content.Context; import android.util.Log; import android.widget.Toast; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookBluetoothStrengthSender; import sakura.kooi.dglabunlocker.variables.Accessors; public class FeatureEnforceRemoteMaxStrength extends ToggleableFeature implements HookBluetoothStrengthSender.IBluetoothStrengthSendInterceptor { @Override public String getSettingName() { return "被控 | 强制限制远程强度"; } @Override public String getSettingDesc() { return "下面那个功能的防御"; } @Override public String getConfigurationKey() { return "FeatureEnforceRemoteMaxStrength"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookBluetoothStrengthSender.class); } @Override public ClientSide getSide() { return ClientSide.CONTROLLED; } @Override public void updateFeatureStatus(boolean enabled) { } @Override public void interceptBeforeStrength(Context context, AtomicInteger strengthA, AtomicInteger strengthB) throws ReflectiveOperationException { int maxA = Accessors.maxStrengthA.get() + 30; int maxB = Accessors.maxStrengthB.get() + 30; boolean limited = false; if (strengthA.get() > maxA) { Log.w("DgLabUnlocker", "Enforced max strength A: " + strengthA.get() + " > " + maxA); strengthA.set(maxA); limited = true; } if (strengthB.get() > maxB) { Log.w("DgLabUnlocker", "Enforced max strength B: " + strengthB.get() + " > " + maxB); strengthB.set(maxB); limited = true; } if (limited) Toast.makeText(context, "强制限制了一次远程最大强度", Toast.LENGTH_SHORT).show(); } @Override public void interceptAfterStrength(Context context, AtomicInteger strengthA, AtomicInteger strengthB) { } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/toggleable/FeatureUnlockRemoteMax.java ================================================ package sakura.kooi.dglabunlocker.features.toggleable; import android.content.Context; import android.util.Log; import android.widget.Toast; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.business.HookRemoteSettingsDialog; import sakura.kooi.dglabunlocker.variables.InjectPoints; public class FeatureUnlockRemoteMax extends ToggleableFeature implements HookRemoteSettingsDialog.IRemoteSettingDialogUiInterceptor { @Override public String getSettingName() { return "被控 | 解锁远程强度上限"; } @Override public String getSettingDesc() { return "最高100完全不够用好吧"; } @Override public String getConfigurationKey() { return "FeatureUnlockRemoteMax"; } @Override public List>> getRequiredHooks() { return Arrays.asList(HookRemoteSettingsDialog.class); } @Override public ClientSide getSide() { return ClientSide.ALL; } @Override public void updateFeatureStatus(boolean enabled) { } @Override public void interceptUiElements(Context context, Object thisObject) throws ReflectiveOperationException { Field fieldChannelA = thisObject.getClass().getDeclaredField(InjectPoints.field_RemoteSettingDialog_strengthA); Field fieldChannelB = thisObject.getClass().getDeclaredField(InjectPoints.field_RemoteSettingDialog_strengthB); fieldChannelA.setAccessible(true); fieldChannelB.setAccessible(true); Object barChannelA = fieldChannelA.get(thisObject); Object barChannelB = fieldChannelB.get(thisObject); if (barChannelA == null || barChannelB == null) { Log.e("DgLabUnlocker", "Cannot found progress bar ui"); return; } Method setMax = barChannelA.getClass().getDeclaredMethod("setMax", int.class); setMax.setAccessible(true); setMax.invoke(barChannelA, 276); setMax.invoke(barChannelB, 276); Toast.makeText(context, "远程最大强度解锁成功", Toast.LENGTH_SHORT).show(); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/features/toggleable/FeatureWebsocketRpc.java ================================================ package sakura.kooi.dglabunlocker.features.toggleable; import java.util.AbstractMap; import java.util.Collections; import java.util.List; import lombok.SneakyThrows; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.remote.WebsocketRPC; import sakura.kooi.dglabunlocker.variables.HookRegistry; public class FeatureWebsocketRpc extends ToggleableFeature { private WebsocketRPC service = new WebsocketRPC(); @Override public String getSettingName() { return "远程 | 开放RPC服务端口"; } @Override public String getSettingDesc() { return service.isRunning ? "运行于 ws://0.0.0.0:23301" : "对外开放Websocket RPC服务端口"; } @Override public String getConfigurationKey() { return "FeatureWebsocketRpc"; } @Override public List>> getRequiredHooks() { return Collections.emptyList(); } @Override public ClientSide getSide() { return ClientSide.ALL; } @Override public void initialize() throws Exception { HookRegistry.customStatuses.put("[接口] RPC服务连接数", new AbstractMap.SimpleEntry<>( () -> service.isRunning ? String.valueOf(service.connected) : "关闭", () -> service.isRunning ? 0xffc6ff00 : 0xfff44336 )); } @SneakyThrows(InterruptedException.class) @Override public void updateFeatureStatus(boolean enabled) { if (enabled) { service.start(); } else { service.stop(); service = new WebsocketRPC(); } } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/AbstractHook.java ================================================ package sakura.kooi.dglabunlocker.hooks; import android.content.Context; import android.util.Log; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.utils.ModuleUtils; import sakura.kooi.dglabunlocker.variables.Accessors; import sakura.kooi.dglabunlocker.variables.HookRegistry; public abstract class AbstractHook { @Getter private Class handlerClass; private List handlers = new ArrayList<>(); @Getter @Setter private boolean isHooked = false; public AbstractHook(Class handlerClass) { this.handlerClass = handlerClass; } public void registerHandler(Object handler) { if (!handlerClass.isInstance(handler)) throw new IllegalArgumentException("Handler " + handler.getClass().getName() + " cannot be casted to registered to hook " + this.getClass().getName() + " ( require " + handlerClass.getName() + " )"); if (!(handler instanceof AbstractFeature)) throw new IllegalArgumentException("Handler " + handler.getClass().getName() + " is not AbstractFeature and cannot be registered"); this.handlers.add((AbstractFeature) handler); } public void applyHook(Context context, ClassLoader classLoader) { try { apply(context, classLoader); isHooked = true; } catch (Exception e) { isHooked = false; ModuleUtils.logError("DgLabUnlocker", "Could not apply " + this.getClass().getName(), e); } } public abstract String getName(); public abstract int getMinVersion(); public boolean isUnsupported() { return HookRegistry.versionCode < getMinVersion(); } protected abstract void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException; @SuppressWarnings("unchecked") // is checked protected void callHandlers(ConsumerEx dataPipe) { for (AbstractFeature handler : handlers) { if (handler.isUnsupported()) continue; if (handler instanceof ToggleableFeature && !((ToggleableFeature) handler).isEnabled()) continue; if (handler.getSide() == AbstractFeature.ClientSide.CONTROLLED && Accessors.isRemote) continue; if (handler.getSide() == AbstractFeature.ClientSide.CONTROLLER && !Accessors.isRemote) continue; try { dataPipe.accept((T) handler); } catch (Exception e) { Log.e("DgLabUnlocker", "An error occurred in " + handler.getClass().getName(), e); } } } protected interface ConsumerEx { void accept(T handler) throws Exception; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookActivityResult.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import static sakura.kooi.dglabunlocker.utils.DgLabVersion.V_1_3_2; import android.content.Context; import android.content.Intent; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; public class HookActivityResult extends AbstractHook { public HookActivityResult() { super(IActivityResultInterceptor.class); } @Override public String getName() { return "窗口消息回调"; } @Override public int getMinVersion() { return V_1_3_2; } @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { XposedHelpers.findAndHookMethod("android.app.Activity", classLoader, "onActivityResult", int.class, int.class, Intent.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { callHandlers(interceptor -> { interceptor.onActivityResult(context, (int)param.args[0], (int)param.args[1], (Intent) param.args[2]); }); } }); } public interface IActivityResultInterceptor { void onActivityResult(Context context, int requestCode, int resultCode, Intent data); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookBluetoothStrengthSender.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import android.content.Context; import android.util.Log; import java.util.concurrent.atomic.AtomicInteger; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.variables.InjectPoints; public class HookBluetoothStrengthSender extends AbstractHook { public HookBluetoothStrengthSender() { super(IBluetoothStrengthSendInterceptor.class); } @Override public String getName() { return "蓝牙强度发送"; } @Override public int getMinVersion() { return DgLabVersion.V_ANY; } public void apply(Context context, ClassLoader classLoader) { XposedHelpers.findAndHookMethod(InjectPoints.class_BluetoothService, classLoader, InjectPoints.method_BluetoothService_updateStrength, int.class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { AtomicInteger strengthA = new AtomicInteger((int) param.args[0]); AtomicInteger strengthB = new AtomicInteger((int) param.args[1]); callHandlers(handler -> { handler.interceptBeforeStrength(context, strengthA, strengthB); }); param.args[0] = strengthA.get(); param.args[1] = strengthB.get(); } @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { AtomicInteger strengthA = new AtomicInteger((int) param.args[0]); AtomicInteger strengthB = new AtomicInteger((int) param.args[1]); callHandlers(handler -> { handler.interceptAfterStrength(context, strengthA, strengthB); }); param.args[0] = strengthA.get(); param.args[1] = strengthB.get(); Log.d("DgLabUnlocker", "Bluetooth sent strength " + param.args[0] + " " + param.args[1]); } }); } public interface IBluetoothStrengthSendInterceptor { void interceptBeforeStrength(Context context, AtomicInteger strengthA, AtomicInteger strengthB) throws ReflectiveOperationException; void interceptAfterStrength(Context context, AtomicInteger strengthA, AtomicInteger strengthB) throws ReflectiveOperationException; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookCurrentActivity.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import static sakura.kooi.dglabunlocker.utils.DgLabVersion.V_ANY; import android.app.Activity; import android.content.Context; import android.content.Intent; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; public class HookCurrentActivity extends AbstractHook { private static volatile Activity _currentActivity = null; public HookCurrentActivity() { super(Object.class); } @Override public String getName() { return "当前窗口捕获"; } @Override public int getMinVersion() { return V_ANY; } @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { XposedHelpers.findAndHookMethod("android.app.Instrumentation", classLoader, "newActivity", ClassLoader.class, String.class, Intent.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { _currentActivity = (Activity) param.getResult(); } }); } public static Activity getCurrentActivity() { return _currentActivity; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookLongPressStrengthHandler.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import android.content.Context; import android.os.Message; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.variables.InjectPoints; public class HookLongPressStrengthHandler extends AbstractHook { public HookLongPressStrengthHandler() { super(HookLongPressStrengthHandler.IStrengthButtonInterceptor.class); } @Override public String getName() { return "长按强度回调"; } @Override public int getMinVersion() { return DgLabVersion.V_1_3_2; } @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { XposedHelpers.findAndHookMethod(InjectPoints.class_StrengthLongPressHandler, classLoader, "handleMessage", Message.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { Message message = (Message) param.args[0]; int what = message.what; if (what >= 10 && what <= 13) { callHandlers(handler -> { handler.beforeStrengthChange(context); }); } } @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Message message = (Message) param.args[0]; int what = message.what; if (what >= 10 && what <= 13) { callHandlers(handler -> { handler.afterStrengthChange(context); }); } } }); } public interface IStrengthButtonInterceptor { void beforeStrengthChange(Context context) throws ReflectiveOperationException; void afterStrengthChange(Context context) throws ReflectiveOperationException; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookProtocolStrengthDecoder.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import android.content.Context; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.variables.InjectPoints; public class HookProtocolStrengthDecoder extends AbstractHook { public HookProtocolStrengthDecoder() { super(IProtocolDecoderInterceptor.class); } @Override public String getName() { return "强度协议解码"; } @Override public int getMinVersion() { return DgLabVersion.V_ANY; } @Override public void apply(Context context, ClassLoader classLoader) { XposedHelpers.findAndHookMethod(InjectPoints.class_BluetoothServiceDecoder, classLoader, InjectPoints.method_BluetoothServiceDecoder_decode, byte[].class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { callHandlers(handler -> { handler.beforeStrengthDecode(context); }); } @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { callHandlers(handler -> { handler.afterStrengthDecode(context); }); } }); } public interface IProtocolDecoderInterceptor { void beforeStrengthDecode(Context context) throws ReflectiveOperationException; void afterStrengthDecode(Context context) throws ReflectiveOperationException; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookRemoteSettingsDialog.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import android.content.Context; import android.os.Bundle; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.variables.InjectPoints; public class HookRemoteSettingsDialog extends AbstractHook { public HookRemoteSettingsDialog() { super(IRemoteSettingDialogUiInterceptor.class); } @Override public String getName() { return "远程控制设置"; } @Override public int getMinVersion() { return DgLabVersion.V_ANY; } public void apply(Context context, ClassLoader classLoader) { XposedHelpers.findAndHookMethod(InjectPoints.class_RemoteSettingDialog, classLoader, "onCreate", Bundle.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Object thisObject = param.thisObject; HookRemoteSettingsDialog.this.callHandlers(interceptor -> { interceptor.interceptUiElements(context, thisObject); }); } }); } public interface IRemoteSettingDialogUiInterceptor { void interceptUiElements(Context context, Object thisObject) throws ReflectiveOperationException; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookStrengthButton.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import android.content.Context; import android.view.MotionEvent; import android.view.View; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.variables.InjectPoints; public class HookStrengthButton extends AbstractHook { public HookStrengthButton() { super(IStrengthButtonInterceptor.class); } @Override public String getName() { return "强度调整按钮"; } @Override public int getMinVersion() { return DgLabVersion.V_ANY; } public void apply(Context context, ClassLoader classLoader) { InjectPoints.class_StrengthTouchListeners.forEach(classTouchListener -> { XposedHelpers.findAndHookMethod(classTouchListener, classLoader, "onTouch", View.class, MotionEvent.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { callHandlers(handler -> { handler.beforeStrengthChange(context); }); } @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { callHandlers(handler -> { handler.afterStrengthChange(context); }); } }); }); } public interface IStrengthButtonInterceptor { void beforeStrengthChange(Context context) throws ReflectiveOperationException; void afterStrengthChange(Context context) throws ReflectiveOperationException; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookStrengthText.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import static sakura.kooi.dglabunlocker.variables.InjectPoints.*; import static sakura.kooi.dglabunlocker.variables.InjectPoints.method_HomeActivity_updateStrengthText; import android.content.Context; import android.widget.TextView; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.variables.Accessors; public class HookStrengthText extends AbstractHook { public HookStrengthText() { super(StrengthTextHandler.class); } @Override public String getName() { return "强度文字显示"; } @Override public int getMinVersion() { return DgLabVersion.V_1_3_2; } @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { XposedHelpers.findAndHookMethod(class_HomeActivity, classLoader, method_HomeActivity_updateStrengthText, int.class, int.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { callHandlers(handler -> { handler.interceptStrengthText( Accessors.textHomeActivityStrengthA.get(param.thisObject), Accessors.textHomeActivityStrengthB.get(param.thisObject) ); }); } }); } public interface StrengthTextHandler { void interceptStrengthText(TextView textA, TextView textB) throws ReflectiveOperationException; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/business/HookWaveAdapterCollector.java ================================================ package sakura.kooi.dglabunlocker.hooks.business; import static sakura.kooi.dglabunlocker.variables.InjectPoints.class_MainListCustomizAdapter; import android.content.Context; import java.util.Collection; import java.util.List; import java.util.WeakHashMap; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; public class HookWaveAdapterCollector extends AbstractHook { private static final WeakHashMap adapters = new WeakHashMap<>(); public HookWaveAdapterCollector() { super(Object.class); } @Override public String getName() { return "波形列表收集"; } @Override public int getMinVersion() { return DgLabVersion.V_1_3_2; } @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { XposedHelpers.findAndHookConstructor(class_MainListCustomizAdapter, classLoader, List.class, int.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Object adapter = param.thisObject; adapters.put(adapter, null); } }); } public static Collection getAdapters() { return adapters.keySet(); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/preload/HookDisableForceUpdate.java ================================================ package sakura.kooi.dglabunlocker.hooks.preload; import static sakura.kooi.dglabunlocker.utils.ExceptionLogger.withCatch; import android.content.Context; import android.util.Log; import java.util.Objects; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; public class HookDisableForceUpdate extends AbstractHook { public HookDisableForceUpdate() { super(Object.class); } @Override public String getName() { return "屏蔽强制更新"; } @Override public int getMinVersion() { return DgLabVersion.V_ANY; } // com.bjsm.dungeonlab.widget.UpdateAppDialog.show(String str, String str2, int isForce, String str3) // isForce -> 0 @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { withCatch("HookDisableForceUpdate findMethod", () -> { XposedHelpers.findAndHookMethod("com.bjsm.dungeonlab.widget.UpdateAppDialog", classLoader, "show", String.class, String.class, int.class, String.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { withCatch("HookDisableForceUpdate", () -> { Log.i("DgLabUnlocker", "HookDisableForceUpdate: Showing update dialog with param " + param.args[2]); StringBuilder message = new StringBuilder(); message.append("** [DGLab-Unlocker] 提示: \n"); if (Objects.equals(param.args[2], 0)) { message.append("** 屏蔽强制更新成功\n** 您现在可以取消本次更新\n\n"); param.args[2] = 1; Log.i("DgLabUnlocker", "HookDisableForceUpdate: Disabling force update flag"); } message.append("** 建议先检查模块是否适配新版本\n** 以免更新APP后模块失效\n\n"); message.append((String) param.args[0]); param.args[0] = message.toString(); }); } }); }); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/preload/HookSettingsDialog.java ================================================ package sakura.kooi.dglabunlocker.hooks.preload; import static sakura.kooi.dglabunlocker.utils.ExceptionLogger.withCatch; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.View; import java.lang.reflect.Field; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.ui.ModuleDialog; import sakura.kooi.dglabunlocker.variables.ModuleSettings; public class HookSettingsDialog { public static void apply(Context context, ClassLoader classLoader) { XposedHelpers.findAndHookMethod("com.bjsm.dungeonlab.widget.FuncSelectDialog", classLoader, "onCreate", Bundle.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { withCatch("HookBugReportDialog FuncSelectDialog", () -> { Log.i("DgLabUnlocker", "HookSettingsDialog: replacing onClickListener"); Dialog dialog = (Dialog) param.thisObject; Field btnField = dialog.getClass().getDeclaredField("safe_button"); btnField.setAccessible(true); View btn = (View) btnField.get(dialog); if (btn == null) { Log.e("DgLabUnlocker", "HookSettingsDialog: Inject failed, button is null"); return; } btn.setOnClickListener(e -> withCatch("SettingDialog open", () -> ModuleSettings.showSettingsDialog(btn.getContext()))); }); } }); XposedHelpers.findAndHookMethod("com.bjsm.dungeonlab.widget.BugDialog", classLoader, "onCreate", Bundle.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { withCatch("HookBugReportDialog BugDialog", () -> { Log.i("DgLabUnlocker", "HookSettingsDialog: replacing layout of BugDialog"); Dialog dialog = (Dialog) param.thisObject; dialog.setContentView(ModuleDialog.makeLayout(dialog.getContext())); }); } }); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/hooks/preload/HookUpdateClientSide.java ================================================ package sakura.kooi.dglabunlocker.hooks.preload; import static sakura.kooi.dglabunlocker.variables.InjectPoints.class_BluetoothService; import static sakura.kooi.dglabunlocker.variables.InjectPoints.method_BluetoothService_updateClientSide; import android.content.Context; import java.util.Objects; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.DgLabVersion; import sakura.kooi.dglabunlocker.utils.ModuleUtils; import sakura.kooi.dglabunlocker.variables.Accessors; public class HookUpdateClientSide extends AbstractHook { public HookUpdateClientSide() { super(Object.class); } @Override public String getName() { return "连接状态监听"; } @Override public int getMinVersion() { return DgLabVersion.V_ANY; } @Override protected void apply(Context context, ClassLoader classLoader) throws ReflectiveOperationException { XposedHelpers.findAndHookMethod(class_BluetoothService, classLoader, method_BluetoothService_updateClientSide, int.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { try { Accessors.isRemote = Accessors.isRemoteControlling.get() && !Objects.equals(param.args[0], 0); } catch (ReflectiveOperationException e) { ModuleUtils.logError("DgLabUnlocker", "Update isRemoteControlling failed", e); } } }); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/remote/WebsocketRPC.java ================================================ package sakura.kooi.dglabunlocker.remote; import android.util.Log; import androidx.annotation.NonNull; import org.java_websocket.WebSocket; import org.java_websocket.handshake.ClientHandshake; import org.java_websocket.server.WebSocketServer; import org.json.JSONException; import org.json.JSONObject; import java.net.InetSocketAddress; import java.util.Objects; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.features.toggleable.FeatureBypassRemoteMaxStrength; import sakura.kooi.dglabunlocker.utils.FieldAccessor; import sakura.kooi.dglabunlocker.utils.ModuleUtils; import sakura.kooi.dglabunlocker.variables.Accessors; import sakura.kooi.dglabunlocker.variables.HookRegistry; public class WebsocketRPC extends WebSocketServer { public WebsocketRPC() { super(new InetSocketAddress("0.0.0.0", 23301)); } public boolean isRunning = false; public int connected = 0; public void start() { super.start(); isRunning = true; Log.i("DgLabUnlocker", "RPC: Websocket server started"); } public void stop() throws InterruptedException { super.stop(); isRunning = false; Log.i("DgLabUnlocker", "RPC: Websocket server stopped"); } @Override public void onOpen(WebSocket conn, ClientHandshake handshake) { connected++; Log.i("DgLabUnlocker", "RPC: client connected"); } @Override public void onClose(WebSocket conn, int code, String reason, boolean remote) { connected--; Log.i("DgLabUnlocker", "RPC: client disconnected"); } @Override public void onMessage(WebSocket conn, String message) { JSONObject req; int id; try { req = new JSONObject(message); id = req.getInt("id"); } catch (JSONException e) { conn.send("{\"id\":null,\"code\":400,\"result\":\"Bad request\"}"); return; } try { Log.i("DgLabUnlocker", "RPC: received message " + message); String method = req.getString("method"); Object data = req.has("data") ? req.get("data") : null; dispatchMethods(conn, id, method, data); } catch (Exception e) { try { ModuleUtils.logError("DgLabUnlocker", "RPC: Internal error", e); conn.send(makeResponse(id, 500, "Internal error", null)); } catch (JSONException ex) { ModuleUtils.logError("DgLabUnlocker", "RPC: Failed write response", e); conn.send("{\"id\":" + id + ",\"code\":500,\"result\":\"Internal server error, see xposed log for details\"}"); } } } private void dispatchMethods(WebSocket conn, int id, String method, Object payload) throws JSONException, ReflectiveOperationException { switch (method) { case "queryStrength": { queryStrength(conn, id); break; } case "setStrength": { if (payload instanceof JSONObject) { setStrength(conn, id, (JSONObject) payload); } else { conn.send(makeResponse(id, 400, "Bad request", null)); } break; } case "addStrength": { if (payload instanceof JSONObject) { boolean channel = ((JSONObject) payload).getBoolean("channel"); int strength = ((JSONObject) payload).getInt("strength"); if (channel) { addStrength(conn, id, true, strength, Accessors.maxStrengthA, Accessors.totalStrengthA); } else { addStrength(conn, id, false, strength, Accessors.maxStrengthB, Accessors.totalStrengthB); } } else { conn.send(makeResponse(id, 400, "Bad request", null)); } break; } default: { conn.send(makeResponse(id, 400, "Unknown command", null)); } } } private void addStrength(WebSocket conn, int id, boolean channel, int strength, FieldAccessor maxStrength, FieldAccessor totalStrength) throws ReflectiveOperationException, JSONException { strength = totalStrength.get() + strength; if (Accessors.isRemote && !Objects.requireNonNull((ToggleableFeature)HookRegistry.featureInstances.get(FeatureBypassRemoteMaxStrength.class)).isEnabled()) { int max = maxStrength.get(); if (max < strength) { strength = max; } } if (strength < 0) { strength = 0; } totalStrength.set(strength); Log.i("DgLabUnlocker", "RPC: Strength " + (channel ? "A" : "B") + " set to " + strength); ModuleUtils.broadcastUiUpdate(); conn.send(makeResponse(id, 0, "ok", null)); } private void setStrength(WebSocket conn, int id, JSONObject payload) throws JSONException, ReflectiveOperationException { int strengthA = payload.getInt("strengthA"); int strengthB = payload.getInt("strengthB"); strengthA = strengthA + Accessors.remoteStrengthA.get(); strengthB = strengthB + Accessors.remoteStrengthA.get(); if (Accessors.isRemote && !Objects.requireNonNull((ToggleableFeature)HookRegistry.featureInstances.get(FeatureBypassRemoteMaxStrength.class)).isEnabled()) { int maxStrengthA = Accessors.maxStrengthA.get(); int maxStrengthB = Accessors.maxStrengthB.get(); if (maxStrengthA < strengthA) { strengthA = maxStrengthA; } if (maxStrengthB < strengthB) { strengthB = maxStrengthB; } } Accessors.totalStrengthA.set(strengthA); Accessors.totalStrengthB.set(strengthB); Log.i("DgLabUnlocker", "RPC: Strength set to " + strengthA + " | " + strengthB); ModuleUtils.broadcastUiUpdate(); conn.send(makeResponse(id, 0, "ok", null)); } private void queryStrength(WebSocket conn, int id) throws JSONException, ReflectiveOperationException { JSONObject data = new JSONObject(); data.put("totalStrengthA", Accessors.totalStrengthA.get()); data.put("totalStrengthB", Accessors.totalStrengthB.get()); data.put("baseStrengthA", Accessors.localStrengthA.get()); data.put("baseStrengthB", Accessors.localStrengthB.get()); data.put("remoteStrengthA", Accessors.remoteStrengthA.get()); data.put("remoteStrengthB", Accessors.remoteStrengthB.get()); data.put("maxStrengthA", Accessors.maxStrengthA.get()); data.put("maxStrengthB", Accessors.maxStrengthB.get()); data.put("isRemote", Accessors.isRemote); conn.send(makeResponse(id, 0, "ok", data)); } @NonNull private String makeResponse(int id, int code, String result, Object data) throws JSONException { JSONObject resp = new JSONObject(); resp.put("id", id); resp.put("code", code); resp.put("result", result); resp.put("data", data); return resp.toString(); } @Override public void onError(WebSocket conn, Exception ex) { } @Override public void onStart() { } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/ClickableFeatureDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.app.Dialog; import android.content.Context; import android.widget.LinearLayout; import androidx.annotation.NonNull; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.features.ClickableFeature; import sakura.kooi.dglabunlocker.utils.UiUtils; import sakura.kooi.dglabunlocker.variables.HookRegistry; public class ClickableFeatureDialog extends Dialog { public ClickableFeatureDialog(@NonNull Context context) { super(context); this.setContentView(UiUtils.makeDialogLayout(this, "附加功能", container -> { for (AbstractFeature feature : HookRegistry.featureInstances.values()) { if (!(feature instanceof ClickableFeature)) continue; if (feature.isUnsupported()) continue; LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); ((ClickableFeature) feature).inflateFeatureLayout(context, layout); layout.setEnabled(feature.isLoaded()); container.addView(layout); } })); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/ConfigurationDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; import android.util.Log; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.features.WithExtraConfiguration; import sakura.kooi.dglabunlocker.utils.UiUtils; import sakura.kooi.dglabunlocker.variables.HookRegistry; import sakura.kooi.dglabunlocker.variables.ModuleSettings; public class ConfigurationDialog extends Dialog { public ConfigurationDialog(@NonNull Context context) { super(context); setContentView(UiUtils.makeDialogLayout(this, "DG-Lab Unlocker 设置", ConfigurationDialog::createSettingSwitches)); } private static void createSettingSwitches(LinearLayout container) { for (AbstractFeature feature : HookRegistry.featureInstances.values()) { if (!(feature instanceof ToggleableFeature)) continue; if (feature.isUnsupported()) continue; createSettingSwitch(container, (ToggleableFeature)feature); } } @SuppressLint("UseSwitchCompatOrMaterialCode") private static void createSettingSwitch(LinearLayout container, ToggleableFeature feature) { LinearLayout layout = new LinearLayout(container.getContext()); layout.setPadding(0, UiUtils.dpToPx(layout, 6), 0, 0); if (feature instanceof WithExtraConfiguration) { View extraConfigButton = ((WithExtraConfiguration) feature).createSettingButton(container.getContext()); layout.addView(extraConfigButton); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) extraConfigButton.getLayoutParams(); layoutParams.rightMargin = UiUtils.dpToPx(layout, 6); extraConfigButton.setLayoutParams(layoutParams); } TextView textTitle = UiUtils.createTextView(container.getContext()); Switch settingSwitch = UiUtils.createSwitch(container.getContext()); TextView textDesc = UiUtils.createTextView(container.getContext(), 0xffdfd2a5); textTitle.setText(feature.getSettingName()); textTitle.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); layout.addView(textTitle); settingSwitch.setPadding(UiUtils.dpToPx(layout, 10), 0, 0, 0); settingSwitch.setChecked(feature.isEnabled()); settingSwitch.setEnabled(feature.isLoaded()); settingSwitch.setOnClickListener(e -> { boolean enabled = settingSwitch.isChecked(); try { feature.setEnabled(enabled); ModuleSettings.sharedPref.edit().putBoolean(feature.getConfigurationKey(), enabled).commit(); textDesc.setText(feature.getSettingDesc()); Log.i("DgLabUnlocker", "Config " + feature.getConfigurationKey() + " set to " + settingSwitch.isChecked()); } catch (Exception ex) { feature.setEnabled(false); settingSwitch.setChecked(!settingSwitch.isChecked()); Toast.makeText(container.getContext(), "发生异常错误", Toast.LENGTH_SHORT).show(); } }); layout.addView(settingSwitch); container.addView(layout); textDesc.setText(feature.isLoaded() ? feature.getSettingDesc() : "加载时发生错误, 功能不可用"); textDesc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 9); textDesc.setPadding(0, UiUtils.dpToPx(layout, 1), 0, UiUtils.dpToPx(layout, 4)); container.addView(textDesc); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/DevTestDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.app.Dialog; import android.content.Context; import android.widget.Toast; import androidx.annotation.NonNull; import sakura.kooi.dglabunlocker.utils.UiUtils; public class DevTestDialog extends Dialog { public DevTestDialog(@NonNull Context context) { super(context); this.setContentView(UiUtils.makeDialogLayout(this, "实验功能测试", container -> { UiUtils.createButton(container, "模拟资源加载错误", e -> { StatusDialog.resourceInjection = false; Toast.makeText(context, "成功", Toast.LENGTH_SHORT).show(); }); })); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/ExtraConfigurationDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.app.Dialog; import android.content.Context; import android.widget.TableLayout; import java.lang.reflect.Field; import java.util.LinkedHashMap; import java.util.Map; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.features.WithExtraConfiguration; import sakura.kooi.dglabunlocker.utils.UiUtils; public class ExtraConfigurationDialog extends Dialog { public ExtraConfigurationDialog(Context context, AbstractFeature feature) { super(context); this.setContentView(UiUtils.makeDialogLayout(this, feature.getName() + " 配置", container -> { LinkedHashMap configs = new LinkedHashMap<>(); for (Field field : feature.getClass().getDeclaredFields()) { if (field.isAnnotationPresent(WithExtraConfiguration.ExtraConfigurationField.class)) { WithExtraConfiguration.ExtraConfigurationField extraConfigurationField = field.getAnnotation(WithExtraConfiguration.ExtraConfigurationField.class); if (extraConfigurationField == null || extraConfigurationField.key() == null) throw new IllegalArgumentException("Illegal extra config with null key in feature " + feature.getName()); field.setAccessible(true); if (field.getType() == int.class || (field.getType() == String.class || field.getType() == boolean.class)) { configs.put(extraConfigurationField, field); } else throw new IllegalArgumentException("Illegal extra config " + extraConfigurationField.key() + " in feature " + feature.getName()); } } // TODO create setting input from configs TableLayout table = new TableLayout(context); container.addView(table); for (Map.Entry entry : configs.entrySet()) { var config = entry.getKey(); var field = entry.getValue(); } // TODO add confirm and cancel button // TODO register actionListener -> save data on confirm })); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/ModuleDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.app.Dialog; import android.content.Context; import android.util.TypedValue; import android.view.View; import android.view.Window; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import sakura.kooi.dglabunlocker.BuildConfig; import sakura.kooi.dglabunlocker.utils.UiUtils; import sakura.kooi.dglabunlocker.variables.HookRegistry; public class ModuleDialog extends Dialog { public ModuleDialog(@NonNull Context context) { super(context); if (StatusDialog.resourceInjection) { getWindow().setBackgroundDrawableResource(android.R.color.transparent); } else { requestWindowFeature(Window.FEATURE_NO_TITLE); } this.setContentView(makeLayout(context)); } public static LinearLayout makeLayout(@NonNull Context context) { LinearLayout container = UiUtils.makeDialogContainer(context, "DG-Lab 魔改模块"); container.addView(UiUtils.createTextView(context, "应用版本: " + (StatusDialog.currentLoadedVersion == null ? "未知" : StatusDialog.currentLoadedVersion) + " - " + HookRegistry.versionCode )); container.addView(UiUtils.createTextView(context, "模块版本: " + BuildConfig.VERSION_NAME)); if (StatusDialog.fieldsLookup) { UiUtils.createButton(container, "功能设置", e -> new ConfigurationDialog(context).show()); UiUtils.createButton(container, "附加功能", e -> new ClickableFeatureDialog(context).show()); } else { TextView textView = UiUtils.createTextView(context, "严重错误: 模块加载失败, 请检查日志"); textView.setTextColor(0xfff44336); container.addView(textView); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.topMargin = UiUtils.dpToPx(textView, 6); textView.setLayoutParams(params); } UiUtils.createButton(container, "模块运行状态", e -> new StatusDialog(context).show()); if (HookRegistry.ENABLE_DEV_FEATURE) { UiUtils.createButton(container, "实验功能测试", e -> new DevTestDialog(context).show()); } TextView textAuthor = new TextView(context); textAuthor.setText("Github @SakuraKoi/DgLabUnlocker"); textAuthor.setTextSize(TypedValue.COMPLEX_UNIT_SP, 9); textAuthor.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); container.addView(textAuthor); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textAuthor.getLayoutParams(); layoutParams.topMargin = UiUtils.dpToPx(textAuthor, 24); textAuthor.setLayoutParams(layoutParams); return container; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/StatusDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import java.util.Map; import java.util.function.Supplier; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.utils.UiUtils; import sakura.kooi.dglabunlocker.variables.HookRegistry; public class StatusDialog extends Dialog { public static String currentLoadedVersion = null; public static boolean resourceInjection = false; public static boolean fieldsLookup = false; public static boolean moduleSettingsDialogInject = false; @SuppressLint("ResourceType") public StatusDialog(@NonNull Context context) { super(context); this.setContentView(UiUtils.makeDialogLayout(this, "DG-Lab Unlocker 日志", container -> { container.addView(addCurrentVersion(context)); container.addView(addStatus(context, "[加载] 界面资源注入", false, resourceInjection)); container.addView(addStatus(context, "[加载] 模块设置界面", false, moduleSettingsDialogInject)); container.addView(addStatus(context, "[加载] 应用字段初始化", false, fieldsLookup)); for (AbstractHook hook : HookRegistry.hookInstances.values()) { container.addView(addStatus(context, "[注入] " + hook.getName(), hook.isUnsupported(), hook.isHooked())); } for (Map.Entry, Supplier>> customStatus : HookRegistry.customStatuses.entrySet()) { container.addView(addStatus(context, customStatus.getKey(), customStatus.getValue().getKey().get(), customStatus.getValue().getValue().get())); } })); } private LinearLayout addCurrentVersion(Context context) { LinearLayout layout = new LinearLayout(context); layout.setPadding(0, UiUtils.dpToPx(layout, 6), 0, 0); TextView textTitle = UiUtils.createTextView(context); textTitle.setText("[数据] 版本适配参数"); textTitle.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); layout.addView(textTitle); TextView textStatus = new TextView(context); textStatus.setText(currentLoadedVersion != null ? currentLoadedVersion : "不支持"); textStatus.setTextColor(currentLoadedVersion != null ? 0xffc6ff00 : 0xfff44336); layout.addView(textStatus); return layout; } private LinearLayout addStatus(Context context, String title, boolean isUnsupported, boolean isHooked) { return addStatus(context, title, isUnsupported ? "不支持" : isHooked ? "成功" : "错误", !isUnsupported && isHooked ? 0xffc6ff00 : 0xfff44336); } private LinearLayout addStatus(Context context, String title, String status, int color) { LinearLayout layout = new LinearLayout(context); layout.setPadding(0, UiUtils.dpToPx(layout, 6), 0, 0); TextView textTitle = UiUtils.createTextView(context); textTitle.setText(title); textTitle.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); layout.addView(textTitle); TextView textStatus = UiUtils.createTextView(context); textStatus.setPadding(UiUtils.dpToPx(layout, 10), 0, 0, 0); textStatus.setText(status); textStatus.setTextColor(color); textStatus.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); layout.addView(textStatus); return layout; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ui/WaveSelectDialog.java ================================================ package sakura.kooi.dglabunlocker.ui; import android.app.Dialog; import android.content.Context; import android.widget.LinearLayout; import android.widget.ScrollView; import androidx.annotation.NonNull; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.Consumer; import sakura.kooi.dglabunlocker.utils.UiUtils; public class WaveSelectDialog extends Dialog { public WaveSelectDialog(@NonNull Context context, String title, Map waveList, Consumer> selectedCallback) { super(context); this.setContentView(UiUtils.makeDialogLayout(this, title, container -> { ArrayList selectedWave = new ArrayList<>(); ScrollView scrollView = new ScrollView(context); LinearLayout selectContainer = new LinearLayout(context); selectContainer.setOrientation(LinearLayout.VERTICAL); scrollView.addView(selectContainer); waveList.forEach((name, wave) -> UiUtils.createCheckbox(selectContainer, " " + name, selected -> { if (selected) { selectedWave.add(wave); } else { selectedWave.remove(wave); } })); container.addView(scrollView); UiUtils.createButton(container, "确认", v -> { selectedCallback.accept(selectedWave); dismiss(); }); })); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/DgLabVersion.java ================================================ package sakura.kooi.dglabunlocker.utils; public class DgLabVersion { public static final int V_ANY = 0; public static final int V_1_2_6 = 19; public static final int V_1_3_1 = 21; public static final int V_1_3_2 = 22; public static final int V_1_3_3 = 23; } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/ExceptionLogger.java ================================================ package sakura.kooi.dglabunlocker.utils; import android.util.Log; public class ExceptionLogger { public static void withCatch(String doing, ThrowableRunnable lambda) { try { lambda.run(); } catch (Exception e) { Log.e("DgLabUnlocker", "An error occurred in " + doing, e); } } public interface ThrowableRunnable { void run() throws Exception; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/FieldAccessor.java ================================================ package sakura.kooi.dglabunlocker.utils; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; public class FieldAccessor { private MethodHandle setter; private MethodHandle getter; public FieldAccessor(MethodHandles.Lookup lookup, Class owner, boolean isStatic, String fieldName, Class type) throws NoSuchFieldException, IllegalAccessException { if (isStatic) { getter = lookup.findStaticGetter(owner, fieldName, type); setter = lookup.findStaticSetter(owner, fieldName, type); } else { getter = lookup.findGetter(owner, fieldName, type); setter = lookup.findSetter(owner, fieldName, type); } } public FieldAccessor(MethodHandles.Lookup lookup, Class owner, String fieldName) throws IllegalAccessException, NoSuchFieldException { Field field = owner.getDeclaredField(fieldName); field.setAccessible(true); getter = lookup.unreflectGetter(field); setter = lookup.unreflectSetter(field); } public FieldAccessor(MethodHandles.Lookup lookup, Field field) throws IllegalAccessException { getter = lookup.unreflectGetter(field); setter = lookup.unreflectSetter(field); } public void set(T data) throws ReflectiveOperationException { try { setter.invoke(data); } catch (Throwable throwable) { throw new ReflectiveOperationException(throwable); } } public void set(Object instance, T data) throws ReflectiveOperationException { try { setter.invoke(instance, data); } catch (Throwable throwable) { throw new ReflectiveOperationException(throwable); } } public T get() throws ReflectiveOperationException { try { return (T) getter.invoke(); } catch (Throwable throwable) { throw new ReflectiveOperationException(throwable); } } public T get(Object instance) throws ReflectiveOperationException { try { return (T) getter.invoke(instance); } catch (Throwable throwable) { throw new ReflectiveOperationException(throwable); } } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/ModuleException.java ================================================ package sakura.kooi.dglabunlocker.utils; import androidx.annotation.NonNull; public class ModuleException extends RuntimeException { public ModuleException(String s) { super(s); } @NonNull @Override public synchronized Throwable fillInStackTrace() { return this; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/ModuleUtils.java ================================================ package sakura.kooi.dglabunlocker.utils; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.util.Log; import de.robv.android.xposed.XposedBridge; import sakura.kooi.dglabunlocker.variables.Accessors; public class ModuleUtils { public static Context applicationContext; public static int getAppVersion(Context context) { int versionCode = 0; try { versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException ignored) {} return versionCode; } // 不优雅, 能用就行.jpg public static void logError(String tag, String s) { XposedBridge.log(s); Log.e(tag, s); } public static void logError(String tag, String s, Exception e) { XposedBridge.log(s); XposedBridge.log(e); Log.e(tag, s, e); } public static void broadcastUiUpdate() throws ReflectiveOperationException { Intent broadcast = new Intent(); broadcast.setAction("com.bjsm.dungeonlab.ble.abpower"); broadcast.putExtra("apower", Accessors.totalStrengthA.get()); broadcast.putExtra("bpower", Accessors.totalStrengthB.get()); applicationContext.sendBroadcast(broadcast); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/UiUtils.java ================================================ package sakura.kooi.dglabunlocker.utils; import android.app.Dialog; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.StateListDrawable; import android.util.StateSet; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.Window; import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.Space; import android.widget.Switch; import android.widget.TextView; import androidx.annotation.NonNull; import java.util.function.Consumer; import sakura.kooi.dglabunlocker.ui.StatusDialog; import sakura.kooi.dglabunlocker.variables.ResourceInject; public class UiUtils { public static int dpToPx(View view, float dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, view.getContext().getResources().getDisplayMetrics()); } @NonNull public static LinearLayout makeDialogContainer(Context context, String title) { LinearLayout container = new LinearLayout(context); container.setMinimumWidth(UiUtils.dpToPx(container, 270)); container.setPadding(dpToPx(container, 16), dpToPx(container, 16), dpToPx(container, 16), dpToPx(container, 16)); if (StatusDialog.resourceInjection) { container.setBackground(ResourceInject.dialogSettingsBackground.getConstantState().newDrawable()); } container.setOrientation(LinearLayout.VERTICAL); TextView header = createTextView(context, title); header.setGravity(Gravity.CENTER); header.setPadding(0, 0, 0, dpToPx(container, 16)); container.addView(header); return container; } public static LinearLayout makeDialogLayout(Dialog dialog, String title, Consumer layoutHandler) { if (StatusDialog.resourceInjection) { dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); } else { dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); } LinearLayout container = UiUtils.makeDialogContainer(dialog.getContext(), title); layoutHandler.accept(container); return container; } public static void createSpacing(LinearLayout container, float dp) { Space space = new Space(container.getContext()); container.addView(space); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) space.getLayoutParams(); params.height = dpToPx(space, dp); space.setLayoutParams(params); } public static TextView createButton(LinearLayout container, String title, View.OnClickListener listener) { return createButton(container, title, true, listener); } public static TextView createButton(LinearLayout container, String title, boolean withSpacing, View.OnClickListener listener) { TextView button = createButton(container.getContext(), title, listener); if (withSpacing) { container.addView(button); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button.getLayoutParams(); layoutParams.topMargin = dpToPx(button, 6); layoutParams.bottomMargin = dpToPx(button, 6); button.setLayoutParams(layoutParams); } else { container.addView(button); } return button; } public static TextView createSettingButton(Context context, View.OnClickListener listener) { TextView view = new TextView(context); view.setPadding( dpToPx(view, 8), dpToPx(view, 3), dpToPx(view, 8), dpToPx(view, 3)); if (StatusDialog.resourceInjection) { view.setBackground(ResourceInject.buttonSettingIcon.getConstantState().newDrawable()); view.setWidth(dpToPx(view, 24)); view.setHeight(dpToPx(view, 24)); } else { view.setBackgroundResource(android.R.drawable.btn_default); view.setText("设置"); } view.setGravity(Gravity.CENTER); view.setOnClickListener(listener); return view; } public static TextView createButton(Context context, String title, View.OnClickListener listener) { TextView view = new TextView(context); view.setPadding( dpToPx(view, 8), dpToPx(view, 3), dpToPx(view, 8), dpToPx(view, 3)); if (StatusDialog.resourceInjection) { view.setBackground(ResourceInject.buttonBackground.getConstantState().newDrawable()); view.setTextColor(Color.BLACK); } else { view.setBackgroundResource(android.R.drawable.btn_default); } view.setText(title); view.setGravity(Gravity.CENTER); view.setOnClickListener(listener); return view; } public static CheckBox createCheckbox(LinearLayout container, String title, Consumer listener) { CheckBox checkbox = new CheckBox(container.getContext()); checkbox.setPadding( dpToPx(checkbox, 8), dpToPx(checkbox, 3), dpToPx(checkbox, 8), dpToPx(checkbox, 3)); if (StatusDialog.resourceInjection) { checkbox.setTextColor(0xffffe99d); StateListDrawable thumbSelector = new StateListDrawable(); thumbSelector.addState(new int[]{android.R.attr.state_checked}, ResourceInject.checkOn.getConstantState().newDrawable()); thumbSelector.addState(StateSet.WILD_CARD, ResourceInject.checkOff.getConstantState().newDrawable()); checkbox.setButtonDrawable(thumbSelector); } checkbox.setText(title); checkbox.setOnCheckedChangeListener((buttonView, isChecked) -> listener.accept(isChecked)); checkbox.setChecked(false); container.addView(checkbox); return checkbox; } public static TextView createTextView(Context context, String text) { TextView textView = createTextView(context, 0xffffe99d); textView.setText(text); return textView; } public static TextView createTextView(Context context) { return createTextView(context, 0xffffe99d); } public static TextView createTextView(Context context, int color) { TextView view = new TextView(context); if (StatusDialog.resourceInjection) { view.setTextColor(color); } return view; } public static Switch createSwitch(Context context) { Switch view = new Switch(context); if (StatusDialog.resourceInjection) { StateListDrawable trackSelector = new StateListDrawable(); trackSelector.addState(new int[]{android.R.attr.state_checked}, ResourceInject.switchOpenTrack.getConstantState().newDrawable()); trackSelector.addState(StateSet.WILD_CARD, ResourceInject.switchCloseTrack.getConstantState().newDrawable()); view.setTrackDrawable(trackSelector); StateListDrawable thumbSelector = new StateListDrawable(); thumbSelector.addState(new int[]{android.R.attr.state_checked}, ResourceInject.switchOpenThumb.getConstantState().newDrawable()); thumbSelector.addState(StateSet.WILD_CARD, ResourceInject.switchCloseThumb.getConstantState().newDrawable()); view.setThumbDrawable(thumbSelector); view.setTextOff(""); view.setTextOn(""); } else { view.setTextOff("Off"); view.setTextOn("On"); } return view; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/utils/WaveUtils.java ================================================ package sakura.kooi.dglabunlocker.utils; import android.util.Log; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import sakura.kooi.dglabunlocker.variables.Accessors; public class WaveUtils { public static List getWaveList(boolean filterClassic) throws ReflectiveOperationException { return Accessors.listWaveData.get().stream().filter(wave -> { if (filterClassic) { try { return Accessors.waveIsClassic.get(wave) == 1; } catch (ReflectiveOperationException e) { Log.e("DgLabUnlocker", "An error occurred while checking wave is classic", e); return false; } } else return true; }).collect(Collectors.toList()); } public static Map getWaveListWithName(boolean filterClassic) throws ReflectiveOperationException { return getWaveList(filterClassic).stream().collect(Collectors.toMap(wave -> { try { return Accessors.waveName.get(wave); } catch (ReflectiveOperationException e) { Log.e("DgLabUnlocker", "An error occurred while getting wave name", e); return null; } }, wave -> wave, (o1, o2) -> o1, LinkedHashMap::new)); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/variables/Accessors.java ================================================ package sakura.kooi.dglabunlocker.variables; import android.widget.TextView; import java.lang.invoke.MethodHandle; import java.util.List; import sakura.kooi.dglabunlocker.utils.FieldAccessor; public class Accessors { public static boolean isRemote; public static FieldAccessor localStrengthA; public static FieldAccessor totalStrengthA; public static FieldAccessor maxStrengthA; public static FieldAccessor remoteStrengthA; public static FieldAccessor localStrengthB; public static FieldAccessor totalStrengthB; public static FieldAccessor maxStrengthB; public static FieldAccessor remoteStrengthB; public static FieldAccessor textHomeActivityStrengthA; public static FieldAccessor textHomeActivityStrengthB; public static FieldAccessor isRemoteControlling; public static FieldAccessor> listWaveData; public static Class classWaveClassicBean; public static FieldAccessor waveIsClassic; public static FieldAccessor waveName; public static MethodHandle funcSaveWave; public static MethodHandle funcAdapterSetList; } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/variables/HookRegistry.java ================================================ package sakura.kooi.dglabunlocker.variables; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Supplier; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.features.clickable.FeatureExportWave; import sakura.kooi.dglabunlocker.features.clickable.FeatureIgnoreBatteryOptimization; import sakura.kooi.dglabunlocker.features.clickable.FeatureImportWave; import sakura.kooi.dglabunlocker.features.toggleable.FeatureBypassRemoteMaxStrength; import sakura.kooi.dglabunlocker.features.toggleable.FeatureEnforceLocalStrength; import sakura.kooi.dglabunlocker.features.toggleable.FeatureEnforceRemoteMaxStrength; import sakura.kooi.dglabunlocker.features.toggleable.FeatureUnlockRemoteMax; import sakura.kooi.dglabunlocker.features.toggleable.FeatureWebsocketRpc; import sakura.kooi.dglabunlocker.hooks.AbstractHook; import sakura.kooi.dglabunlocker.hooks.preload.HookDisableForceUpdate; import sakura.kooi.dglabunlocker.hooks.preload.HookUpdateClientSide; public class HookRegistry { // 调试用的实验性功能菜单开关 public static final boolean ENABLE_DEV_FEATURE = false; public static final List> features = List.of( FeatureUnlockRemoteMax.class, FeatureEnforceLocalStrength.class, FeatureEnforceRemoteMaxStrength.class, FeatureBypassRemoteMaxStrength.class, FeatureWebsocketRpc.class, FeatureIgnoreBatteryOptimization.class, FeatureExportWave.class, FeatureImportWave.class ); public static final List>> preloadHooks = List.of( HookDisableForceUpdate.class, HookUpdateClientSide.class ); public static final Map, AbstractFeature> featureInstances = Collections.synchronizedMap(new LinkedHashMap<>()); public static final Map>, AbstractHook> hookInstances = Collections.synchronizedMap(new LinkedHashMap<>()); public static final Map, Supplier>> customStatuses = Collections.synchronizedMap(new LinkedHashMap<>()); public static int versionCode; } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/variables/InjectPoints.java ================================================ package sakura.kooi.dglabunlocker.variables; import java.util.List; public class InjectPoints { public static String class_BluetoothServiceDecoder; public static String method_BluetoothServiceDecoder_decode; public static String class_BluetoothService; public static String method_BluetoothService_updateStrength; public static String method_BluetoothService_updateClientSide; public static List class_StrengthTouchListeners; public static String class_RemoteSettingDialog; public static String field_RemoteSettingDialog_strengthA; public static String field_RemoteSettingDialog_strengthB; public static String class_StrengthLongPressHandler; public static String class_HomeActivity; public static String method_HomeActivity_updateStrengthText; public static String field_HomeActivity_strengthTextA; public static String field_HomeActivity_strengthTextB; public static String class_MainListCustomizAdapter; } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/variables/ModuleSettings.java ================================================ package sakura.kooi.dglabunlocker.variables; import android.content.Context; import android.content.SharedPreferences; import java.lang.reflect.Field; import sakura.kooi.dglabunlocker.features.AbstractFeature; import sakura.kooi.dglabunlocker.features.ToggleableFeature; import sakura.kooi.dglabunlocker.features.WithExtraConfiguration; import sakura.kooi.dglabunlocker.ui.ModuleDialog; public class ModuleSettings { public static SharedPreferences sharedPref; public static void loadConfiguration(Context context) { sharedPref = context.getSharedPreferences("dglabunlocker", Context.MODE_PRIVATE); for (AbstractFeature feature : HookRegistry.featureInstances.values()) { if (feature instanceof ToggleableFeature) { ToggleableFeature toggleableFeature = (ToggleableFeature) feature; toggleableFeature.setEnabled(sharedPref.getBoolean(toggleableFeature.getConfigurationKey(), false)); } if (feature instanceof WithExtraConfiguration) { for (Field field : feature.getClass().getDeclaredFields()) { if (field.isAnnotationPresent(WithExtraConfiguration.ExtraConfigurationField.class)) { WithExtraConfiguration.ExtraConfigurationField extraConfigurationField = field.getAnnotation(WithExtraConfiguration.ExtraConfigurationField.class); if (extraConfigurationField == null || extraConfigurationField.key() == null) throw new IllegalArgumentException("Illegal extra config with null key in feature " + feature.getName()); field.setAccessible(true); try { if (field.getType() == int.class) { field.set(feature, sharedPref.getInt(extraConfigurationField.key(), field.getInt(feature))); } else if (field.getType() == String.class) { field.set(feature, sharedPref.getString(extraConfigurationField.key(), (String) field.get(feature))); } else if (field.getType() == boolean.class) { field.set(feature, sharedPref.getBoolean(extraConfigurationField.key(), field.getBoolean(feature))); } else throw new IllegalArgumentException("Illegal extra config " + extraConfigurationField.key() + " in feature " + feature.getName()); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } } } public static void showSettingsDialog(Context context) { new ModuleDialog(context).show(); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/variables/ResourceInject.java ================================================ package sakura.kooi.dglabunlocker.variables; import android.annotation.SuppressLint; import android.content.res.Resources; import android.content.res.XModuleResources; import android.graphics.drawable.Drawable; import android.util.Log; import de.robv.android.xposed.callbacks.XC_InitPackageResources; import sakura.kooi.dglabunlocker.R; import sakura.kooi.dglabunlocker.ui.StatusDialog; import sakura.kooi.dglabunlocker.utils.ModuleUtils; public class ResourceInject { public static String modulePath; public static Drawable dialogSettingsBackground; public static Drawable switchCloseThumb; public static Drawable switchOpenThumb; public static Drawable switchCloseTrack; public static Drawable switchOpenTrack; public static Drawable buttonBackground; public static Drawable buttonSettingIcon; public static Drawable checkOn; public static Drawable checkOff; @SuppressWarnings("deprecation") @SuppressLint("UseCompatLoadingForDrawables") public static void doResourceInject(XC_InitPackageResources.InitPackageResourcesParam resparam) { Log.i("DgLabUnlocker", "Resource Loading: found target app " + resparam.packageName); XModuleResources modRes = XModuleResources.createInstance(modulePath, resparam.res); try { ResourceInject.dialogSettingsBackground = modRes.getDrawable(R.drawable.settings_bg); ResourceInject.switchCloseThumb = modRes.getDrawable(R.drawable.switch_close_thumb); ResourceInject.switchOpenThumb = modRes.getDrawable(R.drawable.switch_open_thumb); ResourceInject.switchCloseTrack = modRes.getDrawable(R.drawable.switch_close_track); ResourceInject.switchOpenTrack = modRes.getDrawable(R.drawable.switch_open_track); ResourceInject.buttonBackground = modRes.getDrawable(R.drawable.button_yellow); ResourceInject.checkOn = modRes.getDrawable(R.drawable.check_on); ResourceInject.checkOff = modRes.getDrawable(R.drawable.check_off); ResourceInject.buttonSettingIcon = modRes.getDrawable(R.drawable.icon_settings); StatusDialog.resourceInjection = true; } catch (Resources.NotFoundException e) { ModuleUtils.logError("DgLabUnlocker", "resources cannot be found from XModuleResources, still try inject...", e); } resparam.res.setReplacement("com.bjsm.dungeonlab", "string", "anquanxuzhi2", "模块设置"); resparam.res.setReplacement("com.bjsm.dungeonlab", "string", "question_feedback", "DG-Lab Unlocker 设置"); resparam.res.setReplacement("com.bjsm.dungeonlab", "string", "email_con", "模块设置替换失败, 请检查Logcat日志"); } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ver/AbstractVersionedCompatibilityProvider.java ================================================ package sakura.kooi.dglabunlocker.ver; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import java.util.HashMap; import sakura.kooi.dglabunlocker.utils.FieldAccessor; import sakura.kooi.dglabunlocker.utils.ModuleUtils; public abstract class AbstractVersionedCompatibilityProvider { private HashMap> classCache = new HashMap<>(); private MethodHandles.Lookup lookup; private ClassLoader classLoader; protected abstract void initializeAccessors() throws ReflectiveOperationException; protected abstract void initializeNames(); public void initializeAccessors(ClassLoader classLoader) throws ReflectiveOperationException { this.lookup = MethodHandles.lookup(); this.classLoader = classLoader; initializeNames(); initializeAccessors(); } protected Class lookupClass(String className) { return classCache.computeIfAbsent(className, className1 -> { try { return Class.forName(className1, true, classLoader); } catch (ClassNotFoundException e) { ModuleUtils.logError("DgLabUnlocker", "Failed to find class " + className1, e); return null; } }); } protected FieldAccessor lookupField(String className, String fieldName) throws ReflectiveOperationException { Class clazz = lookupClass(className); if (clazz != null) { return new FieldAccessor<>(lookup, clazz, fieldName); } return null; } protected MethodHandle lookupMethod(String className, String methodName, Class... parameterTypes) throws ReflectiveOperationException { Class clazz = lookupClass(className); if (clazz != null) { Method method = clazz.getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); return lookup.unreflect(method); } return null; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ver/Version126.java ================================================ package sakura.kooi.dglabunlocker.ver; import static sakura.kooi.dglabunlocker.variables.InjectPoints.*; import java.util.Arrays; import sakura.kooi.dglabunlocker.variables.Accessors; public class Version126 extends AbstractVersionedCompatibilityProvider { @Override protected void initializeAccessors() throws ReflectiveOperationException { String classGlobalVariables = "com.bjsm.dungeonlab.global.b"; // method_BluetoothServiceDecoder_decode Accessors.totalStrengthA = lookupField(classGlobalVariables, "V"); Accessors.totalStrengthB = lookupField(classGlobalVariables, "W"); Accessors.remoteStrengthA = lookupField(classGlobalVariables, "X"); Accessors.remoteStrengthB = lookupField(classGlobalVariables, "Y"); Accessors.remoteStrengthB = lookupField(classGlobalVariables, "Y"); Accessors.isRemoteControlling = lookupField(classGlobalVariables, "aZ"); // HomeActivity LDC "控制方连接成功" Accessors.localStrengthA = lookupField(classGlobalVariables, "ab"); // getRealStrengthA Accessors.localStrengthB = lookupField(classGlobalVariables, "ac"); // getRealStrengthB Accessors.maxStrengthA = lookupField(classGlobalVariables, "Z"); // getStrengthRangeMax Accessors.maxStrengthB = lookupField(classGlobalVariables, "aa"); // getStrengthRangeMax } @Override protected void initializeNames() { class_BluetoothServiceDecoder = "com.bjsm.dungeonlab.service.BlueToothService$18"; method_BluetoothServiceDecoder_decode = "a"; class_BluetoothService = "com.bjsm.dungeonlab.service.BlueToothService"; method_BluetoothService_updateStrength = "a"; method_BluetoothService_updateClientSide = "b"; class_StrengthTouchListeners = Arrays.asList( "com.bjsm.dungeonlab.ui.activity.HomeActivity$15", "com.bjsm.dungeonlab.ui.activity.HomeActivity$16", "com.bjsm.dungeonlab.ui.activity.HomeActivity$17", "com.bjsm.dungeonlab.ui.activity.HomeActivity$18" ); class_RemoteSettingDialog = "com.bjsm.dungeonlab.widget.RemoteSettingDialog"; field_RemoteSettingDialog_strengthA = "a_channel_strength_range"; field_RemoteSettingDialog_strengthB = "b_channel_strength_range"; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ver/Version131.java ================================================ package sakura.kooi.dglabunlocker.ver; import static sakura.kooi.dglabunlocker.variables.InjectPoints.*; import java.util.Arrays; import sakura.kooi.dglabunlocker.variables.Accessors; public class Version131 extends AbstractVersionedCompatibilityProvider { @Override protected void initializeAccessors() throws ReflectiveOperationException { String classGlobalVariables = "com.bjsm.dungeonlab.global.b"; Accessors.totalStrengthA = lookupField(classGlobalVariables, "as"); Accessors.totalStrengthB = lookupField(classGlobalVariables, "at"); Accessors.remoteStrengthA = lookupField(classGlobalVariables, "aw"); Accessors.remoteStrengthB = lookupField(classGlobalVariables, "ax"); Accessors.isRemoteControlling = lookupField(classGlobalVariables, "by"); Accessors.localStrengthA = lookupField(classGlobalVariables, "ay"); // getRealStrengthA Accessors.localStrengthB = lookupField(classGlobalVariables, "az"); // getRealStrengthB Accessors.maxStrengthA = lookupField(classGlobalVariables, "aw"); // getStrengthRangeMax Accessors.maxStrengthB = lookupField(classGlobalVariables, "ax"); // getStrengthRangeMax } @Override protected void initializeNames() { class_BluetoothServiceDecoder = "com.bjsm.dungeonlab.service.BlueToothService$18"; method_BluetoothServiceDecoder_decode = "a"; class_BluetoothService = "com.bjsm.dungeonlab.service.BlueToothService"; method_BluetoothService_updateStrength = "b"; method_BluetoothService_updateClientSide = "b"; class_StrengthTouchListeners = Arrays.asList( "com.bjsm.dungeonlab.ui.activity.HomeActivity$15", "com.bjsm.dungeonlab.ui.activity.HomeActivity$16", "com.bjsm.dungeonlab.ui.activity.HomeActivity$17", "com.bjsm.dungeonlab.ui.activity.HomeActivity$18" ); class_RemoteSettingDialog = "com.bjsm.dungeonlab.widget.RemoteSettingDialog"; field_RemoteSettingDialog_strengthA = "a_channel_strength_range"; field_RemoteSettingDialog_strengthB = "b_channel_strength_range"; } } ================================================ FILE: app/src/main/java/sakura/kooi/dglabunlocker/ver/Version132.java ================================================ package sakura.kooi.dglabunlocker.ver; import static sakura.kooi.dglabunlocker.variables.InjectPoints.*; import java.util.Arrays; import java.util.Collection; import sakura.kooi.dglabunlocker.variables.Accessors; public class Version132 extends AbstractVersionedCompatibilityProvider { @Override protected void initializeAccessors() throws ReflectiveOperationException { String classGlobalVariables = "com.bjsm.dungeonlab.global.b"; // method_BluetoothServiceDecoder_decode Accessors.totalStrengthA = lookupField(classGlobalVariables, "as"); Accessors.totalStrengthB = lookupField(classGlobalVariables, "at"); Accessors.remoteStrengthA = lookupField(classGlobalVariables, "au"); Accessors.remoteStrengthB = lookupField(classGlobalVariables, "av"); Accessors.isRemoteControlling = lookupField(classGlobalVariables, "by"); // HomeActivity LDC "控制方连接成功" Accessors.localStrengthA = lookupField(classGlobalVariables, "ay"); // getRealStrengthA Accessors.localStrengthB = lookupField(classGlobalVariables, "az"); // getRealStrengthB Accessors.maxStrengthA = lookupField(classGlobalVariables, "aw"); // getStrengthRangeMax Accessors.maxStrengthB = lookupField(classGlobalVariables, "ax"); // getStrengthRangeMax // PlayFragment.class -> MainListCustomizAdapter constructor -> DataUtils.b() Accessors.listWaveData = lookupField(classGlobalVariables, "ak"); String classNameWaveBean = "com.bjsm.dungeonlab.bean.WaveClassicBean"; Accessors.classWaveClassicBean = lookupClass(classNameWaveBean); Accessors.waveIsClassic = lookupField(classNameWaveBean, "isClassic"); Accessors.waveName = lookupField(classNameWaveBean, "waveName"); Accessors.funcSaveWave = lookupMethod("com.bjsm.dungeonlab.d.d", "a", int.class, Accessors.classWaveClassicBean, int.class, String.class, int.class); // MainListCustomizAdapter -> constr -> setList(collection) -> a Accessors.funcAdapterSetList = lookupMethod("com.chad.library.adapter.base.BaseQuickAdapter", "a", Collection.class); // HomeActivity action.equals("com.bjsm.dungeonlab.ble.abpower") Accessors.textHomeActivityStrengthA = lookupField(class_HomeActivity, "y"); Accessors.textHomeActivityStrengthB = lookupField(class_HomeActivity, "G"); } @Override protected void initializeNames() { // RemoteSettingDialog class_RemoteSettingDialog = "com.bjsm.dungeonlab.widget.RemoteSettingDialog"; field_RemoteSettingDialog_strengthA = "a_channel_strength_range"; field_RemoteSettingDialog_strengthB = "b_channel_strength_range"; // BluetoothService.? implements BleNotifyCallback class_BluetoothServiceDecoder = "com.bjsm.dungeonlab.service.BlueToothService$18"; // class_BluetoothServiceDecoder LDC "notify 回调" method_BluetoothServiceDecoder_decode = "a"; // HomeActivity.? implements View.OnTouchListener && R.string.remote_strength_max class_StrengthTouchListeners = Arrays.asList( "com.bjsm.dungeonlab.ui.activity.HomeActivity$15", "com.bjsm.dungeonlab.ui.activity.HomeActivity$16", "com.bjsm.dungeonlab.ui.activity.HomeActivity$17", "com.bjsm.dungeonlab.ui.activity.HomeActivity$18" ); // BlueToothService LDC "写入强度数据成功" class_BluetoothService = "com.bjsm.dungeonlab.service.BlueToothService"; method_BluetoothService_updateStrength = "b"; // class_StrengthTouchListeners -> R.string.remote_strength_max -> if -> getter -> setter method_BluetoothService_updateClientSide = "b"; class_StrengthLongPressHandler = "com.bjsm.dungeonlab.ui.activity.HomeActivity$1"; // HomeActivity action.equals("com.bjsm.dungeonlab.ble.abpower") class_HomeActivity = "com.bjsm.dungeonlab.ui.activity.HomeActivity"; method_HomeActivity_updateStrengthText = "a"; field_HomeActivity_strengthTextA = "y"; field_HomeActivity_strengthTextB = "G"; class_MainListCustomizAdapter = "com.bjsm.dungeonlab.adapter.MainListCustomizAdapter"; } } ================================================ FILE: app/src/main/res/drawable/button_yellow.xml ================================================ ================================================ FILE: app/src/main/res/drawable/check_off.xml ================================================ ================================================ FILE: app/src/main/res/drawable/check_on.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_launcher_foreground.xml ================================================ ================================================ FILE: app/src/main/res/drawable/icon_settings.xml ================================================ ================================================ FILE: app/src/main/res/drawable/settings_bg.xml ================================================ ================================================ FILE: app/src/main/res/drawable/switch_close_thumb.xml ================================================ ================================================ FILE: app/src/main/res/drawable/switch_close_track.xml ================================================ ================================================ FILE: app/src/main/res/drawable/switch_open_thumb.xml ================================================ ================================================ FILE: app/src/main/res/drawable/switch_open_track.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/values/arrays.xml ================================================ com.bjsm.dungeonlabs ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #FFBB86FC #FF6200EE #FF3700B3 #FF03DAC5 #FF018786 #FF000000 #FFFFFFFF ================================================ FILE: app/src/main/res/values/ic_launcher_background.xml ================================================ #2A2A2A ================================================ FILE: app/src/main/res/values/strings.xml ================================================ DG-Lab Beta 魔改 ================================================ FILE: build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '7.2.0' apply false id 'com.android.library' version '7.2.0' apply false } task clean(type: Delete) { delete rootProject.buildDir } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app"s APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true ================================================ FILE: gradlew ================================================ #!/bin/sh # # Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################## # # Gradle start up script for POSIX generated by Gradle. # # Important for running: # # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is # noncompliant, but you have some other compliant shell such as ksh or # bash, then to run this script, type that shell name before the whole # command line, like: # # ksh Gradle # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # «${var#prefix}», «${var%suffix}», and «$( cmd )»; # * compound commands having a testable exit status, especially «case»; # * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # # (2) This script targets any POSIX shell, so it avoids extensions provided # by Bash, Ksh, etc; in particular arrays are avoided. # # The "traditional" practice of packing multiple parameters into a # space-separated string is a well documented source of bugs and security # problems, so this is (mostly) avoided, by progressively accumulating # options in "$@", and eventually passing that to Java. # # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; # see the in-line comments for details. # # There are tweaks for specific operating systems such as AIX, CygWin, # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. # ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link app_path=$0 # Need this for daisy-chained symlinks. while APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path [ -h "$app_path" ] do ls=$( ls -ld "$app_path" ) link=${ls#*' -> '} case $link in #( /*) app_path=$link ;; #( *) app_path=$APP_HOME$link ;; esac done APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum warn () { echo "$*" } >&2 die () { echo echo "$*" echo exit 1 } >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "$( uname )" in #( CYGWIN* ) cygwin=true ;; #( Darwin* ) darwin=true ;; #( MSYS* | MINGW* ) msys=true ;; #( NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD=$JAVA_HOME/jre/sh/java else JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi # Collect all arguments for the java command, stacking in reverse order: # * args from the command line # * the main class name # * -classpath # * -D...appname settings # * --module-path (only if needed) # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) # Now convert the arguments - kludge to limit ourselves to /bin/sh for arg do if case $arg in #( -*) false ;; # don't mess with options #( /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath [ -e "$t" ] ;; #( *) false ;; esac then arg=$( cygpath --path --ignore --mixed "$arg" ) fi # Roll the args list around exactly as many times as the number of # args, so each arg winds up back in the position where it started, but # possibly modified. # # NB: a `for` loop captures its iteration list before it begins, so # changing the positional parameters here affects neither the number of # iterations, nor the values presented in `arg`. shift # remove old arg set -- "$@" "$arg" # push replacement arg done fi # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in # double quotes to make sure that they get re-expanded; and # * put everything else in single quotes, so that it's not re-expanded. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ org.gradle.wrapper.GradleWrapperMain \ "$@" # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. # # In Bash we could simply go: # # readarray ARGS < <( xargs -n1 <<<"$var" ) && # set -- "${ARGS[@]}" "$@" # # but POSIX shell has neither arrays nor command substitution, so instead we # post-process each arg (as a line of input to sed) to backslash-escape any # character that might be a shell metacharacter, then use eval to reverse # that process (while maintaining the separation between arguments), and wrap # the whole thing up as a single "set" statement. # # This will of course break if any of these variables contains a newline or # an unmatched quote. # eval "set -- $( printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | xargs -n1 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | tr '\n' ' ' )" '"$@"' exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @rem @rem Copyright 2015 the original author or authors. @rem @rem Licensed under the Apache License, Version 2.0 (the "License"); @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem @rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Resolve any "." and ".." in APP_HOME to make it shorter. for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle ================================================ pluginManagement { repositories { gradlePluginPortal() google() mavenCentral() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url "https://api.xposed.info/" } } } rootProject.name = "DgLabUnlocker" include ':app'