{"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: CONTRIBUTORS.md\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n# Apktool Contributors\n\nThis product includes software developed by:\n\n * Connor Tumbleson (connor.tumbleson@gmail.com)\n * Ryszard Wi\u015bniewski (brut.alll@gmail.com)\n * Google (https://github.com/google/smali)\n * JesusFreke (https://github.com/JesusFreke/smali)\n * Dmitry Skiba (https://code.google.com/p/android4me/)\n * Tahseen Ur Rehman (https://code.google.com/p/radixtree/)\n * Android Open Source Project (https://source.android.com/)\n * The Apache Software Foundation (https://www.apache.org/)\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: INTERNAL.md\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n# Releasing a new version.\n\nThe steps taken for slicing an official release of Apktool.\n\n### Ensuring proper license headers\n\n_Currently broken after movement to kotlin dsl._\n\n### Tagging the release.\n\nInside `build.gradle` there are two lines.\n\n version\n suffix\n\nThe version variable should be left unchanged. If done correctly, it will already be the version\nyou are about to release. In this case `2.2.2`. The suffix variable should read `SNAPSHOT` as\nthe `2.2.2` release up until this point was `SNAPSHOT` releases (Unofficial).\n\nWe need to remove the `SNAPSHOT` portion and leave the minor version blank. An example can be\nfound [here](https://github.com/iBotPeaches/Apktool/commit/96b70d0be7513c5a1e5d3a3b9a75e4e2b076ad79).\n\nAfter we remove `SNAPSHOT` we need to make the version commit. Organization and following patterns\nis crucial here. This commit should have 1 change only - the change above. Now commit this change\nwith the commit message - `version bump (x.x.x)`.\n\nAt this point we now have the commit of the release, but we need to tag it using the following message.\n\n git tag -a vx.x.x -m \"changed version to vx.x.x\" -s\n\nFor example for the `2.2.1` release.\n\n git tag -a v2.2.1 -m \"changed version to v2.2.1\" -s\n\n### Prepare for publishing.\n\nNew to Apktool is publishing releases to Maven, so plugin authors can directly integrate. You\nneed a `gradle.properties` file in root with the structure:\n\n```\nsigning.keyId={gpgKeyId}\nsigning.password={gpgPassphrase}\nsigning.secretKeyRingFile={gpgSecretKingRingLocation}\n\nossrhUsername={sonatypeUsername}\nossrhPassword={sonatypePassword}\n```\n\nRelease with maven with `./gradlew build shadowJar release publish`.\n\n### Building the binary.\n\n> [!IMPORTANT]\n> In order to publish Maven artifacts you need JDK 11+.\n\nIn order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build\nthe new binary version. We should not have any new commits since the tagged commit.\n\n ./gradlew build shadowJar proguard release\n\nThe build should tell you what version you are building, and it should match the commits you made previously.\n\n \u279c Apktool git:(main) ./gradlew build shadowJar proguard release\n Building RELEASE (main): 2.2.2\n\n### Testing the binary.\n\nNow the release binary is built in the same location as all other builds. Run this version against\nsome of the fixed bugs in this release. This is a simple test to ensure the build had no errors.\n\nCopy the jar to any location to prep for uploading. The pattern we name the jars is\n\n apktool_x.x.x.jar\n\nOr in the case of the last release - `apktool_2.2.1.jar`\n\nOnce you have the jar in this form. Record the md5 hash & sha256 hash of it. This can be done using `md5sum`\nand `sha256sum` on unix systems.\n\nThis can be shown for the `2.2.2` release like so\n\n \u279c Desktop md5sum apktool_2.2.2.jar\n 1e6be08d3f9bb4b442bb85cf4e21f1c1 apktool_2.2.2.jar\n\n \u279c Desktop sha256sum apktool-2.2.2.jar\n 1f1f186edcc09b8677bc1037f3f812dff89077187b24c8558ca2a89186ea3251 apktool-2.2.2.jar\n\nRemember these hashes. These are the local hashes. These are our main hashes. All others (Bitbucket, Backup)\nmust match these. If they do not - they are invalid.\n\n### Lets get uploading.\n\nLets make sure we actually pushed these release changes to the repo (Both Github & Bitbucket)\n\n git push origin main\n git push origin vx.x.x\n\n git push bitbucket master\n git push bitbucket vx.x.x\n\nWe upload the binaries into 3 places.\n\n1. [Bitbucket Downloads](https://bitbucket.org/iBotPeaches/apktool/downloads)\n2. [Github Releases](https://github.com/iBotPeaches/Apktool/releases) - Since `2.2.1`.\n3. [Backup Mirror](https://connortumbleson.com/apktool/)\n4. [Sonatype (Maven)](https://oss.sonatype.org)\n\n#### Bitbucket\n\nThis one is pretty easy. Head to the URL attached to the hyperlink #1 above. There will be a \"Add Files\"\nbutton on the top right of the page. Upload the `apktool_x.x.x.jar` file.\n\nAfter it is uploaded. Immediately visit the page and download it. Check the `md5` for a match.\n\n#### GitHub\n\nThis option will not work until the tag is pushed. You can head to this [page](https://github.com/iBotPeaches/Apktool/releases/new)\nto draft a new release. The `Tag version` dropdown will have the new tag. In this case `v2.2.2`.\n\nSelect that option and make the title `Apktool vx.x.x`. There will be a description field on this release.\nHold tight, we link the release blog post in this field, but we can edit the release after the fact to add this.\n\nUpload the binary `apktool_x.x.x.jar` and submit the release.\n\n#### Backup Server\n\nAccess to this server is probably limited so this option may not be possible. SSH into the\n`connortumbleson.com` server with username `connor`. Head to `public_html/apktool` and upload\nthe `apktool_x.x.x.jar` to it.\n\nNow re-generate the md5/sha256 hashes for these files.\n\n md5sum *.jar > md5.md5sum\n sha256 *.jar > sha256.shasum\n\nCheck the `md5.md5sum` file for the hashes. The file will look something like this.\n\n 6de3e097943c553da5db2e604bced332 apktool_1.4.10.jar\n ...\n 1e6be08d3f9bb4b442bb85cf4e21f1c1 apktool_2.2.2.jar\n\nAdditionally check the `sha256.shasum` file for the hashes. This file will look almost identical to the above\nexcept for containing sha256 hashes.\n\nThe hashes match so we are good with the backup server.\n\n#### Sonatype\n\nYou'll want to log in and view the Staging repositories and confirm you see the recently made build. You'll want to:\n\n * Close it (Wait for audit report email)\n * Release it (Drop the staging repository)\n * Wait 20min - 2 hours for it to appear [here](https://mvnrepository.com/artifact/org.apktool/apktool-lib)\n\nWith those done, time to get writing the release post.\n\nWe currently blog the releases on the [Connor Tumbleson personal blog](https://connortumbleson.com/).\nThis may change and the formatting of these release posts change over time.\n\nSome recent releases for understanding the pattern can be found below.\n\n1. [2.2.1](https://connortumbleson.com/2016/10/18/apktool-v2-2-1-released/)\n2. [2.2.0](https://connortumbleson.com/2016/08/07/apktool-v2-2-0-released/)\n3. [2.0.2](https://connortumbleson.com/2015/10/12/apktool-v2-0-2-released/)\n4. [2.0.0](https://connortumbleson.com/2015/04/20/apktool-v2-0-0-released/)\n\nFor obtaining commit authors and counts. The following command does the legwork:\n\n git shortlog -s -n --all --no-merges --since=\"05 Sept 2018\"\n\nObviously replacing the date with the release date of the last version.\n\nSo write the post. I tend to always include the following:\n\n1. Image of release for featured image when reshared on socials.\n2. Quick sentence or two for SEO to describe the meat of this release.\n3. Commit count and total for this release with author names.\n4. Changelog linking to the bugs that were fixed.\n5. Download including the md5/sha256 hash.\n6. Link dump to Project Site, GitHub, Bug Tracker and XDA Thread.\n\nNow that you've written this post. We need to go post it in places and update places where\nApktool is released.\n\n### XDA Thread\n\nWe have a [thread](https://forum.xda-developers.com/showthread.php?t=1755243) on XDA Developers.\nThis thread follows the same pattern for all releases.\n\nWhen writing a response to the XDA thread we follow another pattern of release notes. These examples\ncan be found below:\n\n1. [2.2.2](https://forum.xda-developers.com/showpost.php?p=70687935&postcount=4635)\n2. [2.2.1](http://forum.xda-developers.com/showpost.php?p=69188139&postcount=4478)\n3. [2.0.0](http://forum.xda-developers.com/showpost.php?p=60255972&postcount=3063)\n\n### Apktool Website\n\nThe Apktool project website has a few locations to update:\n\n1. The homepage intro\n2. The download link in header\n3. Migrating `unreleased.mx` to a new blog post.\n\nThe easiest way to describe this is to just link to a [previous release](https://github.com/iBotPeaches/Apktool/pull/3146/files).\n\n### Update Milestones\n\nNow that we've released a version, we should hopefully have no more tickets in the release just published.\nIf there are, move those tickets to the next milestone.\n\nYou can head to [milestones](https://github.com/iBotPeaches/Apktool/milestones) to close the just\nreleased version and create another.\n\nI tend to create the next release (In this case `2.2.3`) with an ETA of 3 months in the future. This\nis just a guideline but helps me to release a new version every 3 months.\n\n### Social Spam\n\nThe final step is to send this release into the wild via some social posting. Head to the blog\nwhere the release post was and send that link to Twitter, Google and whatever else you use.\n\nRelax and watch the bug tracker.\n\n# Building aapt2 binaries.\n\nThe steps taken for building our modified aapt2 binaries for apktool.\n\n### Getting the modified `frameworks/base` repo.\nFirst step is using the [platform_frameworks_base](https://github.com/iBotPeaches/platform_frameworks_base) repo.\n\nWhile previously unorganized, the repo now follows the branch naming convention depending on the current Android version.\nSo `apktool_7.1` corresponds to the 7.1 Android release. This branch should work for all `android-7.1.x` tags for AOSP.\n\nWe didn't follow this naming convention until Android 7.1. So don't go looking for older versions. The current version\nis `apktool-9.0.0`, which corresponds to the Android 9.0 (Pie) release.\n\nThis repo has a variety of changes applied. These changes range from disabling optimizations to lessening the rules\nthat aapt regularly has. We do this because apktool's job is to not fix apks, but rather keep them as close to the\noriginal as they were.\n\n### First we need the AOSP source\n\nAs cheesy as it is, just follow this [downloading](https://source.android.com/source/downloading.html) link in order\nto get the source downloaded. This is no small download, expect to use 150-250GB.\n\nSome optimization techniques for a smaller clone:\n\n * `~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android16-release --partial-clone` - Partial clone\n * `repo sync -c` - Only current branch\n\nAfter that, you need to build AOSP via this [documentation](https://source.android.com/source/building.html) guide. Now\nwe aren't building the entire AOSP package, the initial build is to just see if you are capable of building it.\n\nWe check out a certain tag or branch. Currently, we use\n\n * aapt2 - `android-16-release`\n\n### Including our modified `frameworks/base` package.\n\nThere is probably a more automated way to do this, but for now:\n\n1. `cd frameworks/base`\n2. `git remote add origin git@github.com:iBotPeaches/platform_frameworks_base.git`\n3. `git fetch origin -v`\n4. `git checkout origin/apktool-{x}`\n\n#### Mac Patch\n\nNormally you'll be building this on a recent macOS that isn't supported. You'll want to follow these steps:\n\n1. `vim build/soong/cc/config/darwin_host.go`\n2. Find `darwinSupportedSdkVersions` array.\n3. Add number that corresponds to output of: `find /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs -iname \"*.sdk\"`\n\n### Building the aapt2 binary.\n\nThe steps below are different per flavor and operating system.\n\n#### Linux / Windows\n1. `source build/envsetup.sh`\n1. `lunch aosp_cf_x86_64_only_phone-aosp_current-eng`\n1. `m aapt2`\n1. `strip out/host/linux-x86/bin/aapt2`\n1. `strip out/host/linux-x86/bin/aapt2_64`\n1. `strip out/host/windows-x86/bin/aapt2.exe`\n1. `strip out/host/windows-x86/bin/aapt2_64.exe`\n\n#### Mac\n1. `export ANDROID_JAVA_HOME=/Path/To/Jdk`\n1. `source build/envsetup.sh`\n1. `lunch aosp_cf_x86_64_only_phone-aosp_current-eng`\n1. `m aapt2`\n1. `strip out/host/darwin-x86/bin/aapt2_64`\n\n#### Confirming aapt/aapt2 builds are static\n\nThere are some issues with some dependencies (namely `libc++`) in which they are built in the shared state. This is\nalright in the scope and context of AOSP/Android Studio, but once you leave those two behind and start using aapt on\nits own, you encounter some issues. The key is to force `libc++` to be built statically which takes some tweaks with the\nAOSP build systems as that dependency isn't standard like `libz` and others.\n\nYou can test the finalized project using tools like `ldd` (unix) and `otool -L` (mac) for testing the binaries looking\nfor shared dependencies.\n\n# Gradle Tips n Tricks\n\n ./gradlew build shadowJar proguard -x test\n\nThis skips the testing suite (which currently takes 2-4 minutes). Use this when making quick builds and save the testing\nsuite before pushing to GitHub.\n\n ./gradlew test --debug-jvm\n\nThis enables debugging on the test suite. This starts the debugger on port 5005 which you can connect with IntelliJ.\n\n ./gradlew :brut.apktool:apktool-lib:test ---tests \"*BuildAndDecodeTest\"\n\nThis runs the library project of Apktool, selecting a specific test to run. Comes in handy when writing a new test and\nonly wanting to run that one. The asterisk is used to the full path to the test can be ignored. You can additionally\nmatch this with the debugging parameter to debug a specific test. This command can be found below.\n\n ./gradlew :brut.apktool:apktool-lib:test --tests \"*BuildAndDecodeTest\" --debug-jvm\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: LICENSE.md\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n Apache License\n Version 2.0, January 2004\n https://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n Copyright 2010 Ryszard Wi\u015bniewski\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: README.md\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n### Apktool\n_This is the repository for Apktool. The website is at the [apktool.org](https://github.com/iBotPeaches/apktool.org) repository._\n\n[![CI](https://github.com/iBotPeaches/Apktool/actions/workflows/build.yml/badge.svg)](https://github.com/iBotPeaches/Apktool/actions/workflows/test.yml)\n[![Software License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/iBotPeaches/Apktool/blob/master/LICENSE.md)\n\nApktool is a tool for reverse engineering third-party, closed, binary, Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes it possible to debug smali code step-by-step. It also makes working with apps easier thanks to project-like file structure and automation of some repetitive tasks such as building apk, etc.\n\nApktool is **NOT** intended for piracy and other non-legal uses. It could be used for localizing and adding features, adding support for custom platforms, and other GOOD purposes. Just try to be fair with the authors of an app, that you use and probably like.\n\n### Branches\n- `main` - In-development Apktool 3.x branch\n- `2.x` - Maintenance branch for Apktool 2.x releases\n\n#### Support\n- [Project Page](https://apktool.org)\n- [#apktool on libera.chat](https://web.libera.chat)\n\n#### Security Vulnerabilities\n\nIf you discover a security vulnerability within Apktool, please send an e-mail to Connor Tumbleson at connor.tumbleson(at)gmail.com. All security vulnerabilities will be promptly addressed.\n\n#### Links\n- [Downloads](https://bitbucket.org/iBotPeaches/apktool/downloads)\n- [Downloads Mirror](https://connortumbleson.com/apktool)\n- [How to Build](https://apktool.org/docs/build)\n- [Documentation](https://apktool.org/wiki/the-basics/intro)\n- [Bug Reports](https://github.com/iBotPeaches/Apktool/issues)\n- [Changelog/Information](https://apktool.org/blog)\n- [XDA Post](https://forum.xda-developers.com/t/util-dec-2-2020-apktool-tool-for-reverse-engineering-apk-files.1755243/)\n- [Source (GitHub)](https://github.com/iBotPeaches/Apktool)\n- [Source (Bitbucket)](https://bitbucket.org/iBotPeaches/apktool/)\n\n\n## Sponsors\n\nSpecial thanks goes to the following sponsors:\n\n### Sourcetoad\n[Sourcetoad](https://sourcetoad.com/) is an award-winning software and app development firm committed to the co-creation of technology solutions that solve complex business problems, delight users, and help our clients achieve their goals.\n\n\n \n \n \n\n\n### Emerge Tools\n\n[Emerge Tools](https://www.emergetools.com) is a suite of revolutionary products designed to supercharge mobile apps and the teams that build them.\n\n\n \n \n \n \n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: ROADMAP.md\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n## Automatic Remapping of ResourceId\nWe currently prevent resourceIds from changing, by utilizing the `public.xml` file which makes the resources public, but\nthen prevents them to be used in some locations (`android:scheme`). The correct fix would be to record the resourceIds\nand use dexlib2 (no regular expressions) to rewrite them to the new resourceId after the `resources.arsc` is built.\n\nThis would be a lookup table of old->new resourceIds leveraging the API of dexlib2 to do the replacement. Doing this\nproperly would nullify the need to do [#191](https://github.com/iBotPeaches/Apktool/issues/191)\n\nSuggestions: [#244](https://github.com/iBotPeaches/Apktool/issues/244)\nDiscussions: [#2062](https://github.com/iBotPeaches/Apktool/issues/2062)\n\n## Implicit Qualifiers Cleanup\nCurrently we have a mismatch between reading the folders and reading the qualifiers which leads to a mismatch between\nimplicit qualifiers like version (-v4, v13, etc).\n\nThis was first spotted in bug [#1272](https://github.com/iBotPeaches/Apktool/issues/1272).\n\nThis was attempted to be fixed in [!1758](https://github.com/iBotPeaches/Apktool/pull/1758/files), but had to be\nreverted due to [this](https://github.com/iBotPeaches/Apktool/issues/1272#issuecomment-379345005).\n\nSuggestions: [#2237](https://github.com/iBotPeaches/Apktool/issues/2237)\n\n## Qualifier Plugin System\nFor some OEMs, past and present. They re-use qualifiers that AOSP ends up using. This with CTS is becoming very\nrare and pretty much a problem of the past, but now custom modifications and more \"off the cuff\" OEMs are doing\nit.\n\nApktool can't do anything because it stays true to AOSP. It would need a plugin system that controls how to\nread the qualifiers. Or even an override file.\n\nSuggestions: [#1420](https://github.com/iBotPeaches/Apktool/issues/1420), [#2474](https://github.com/iBotPeaches/Apktool/issues/2474)\n\n## Non-reference Resources\nSome applications may shove resources into the /res folder, but have no references to them. Apktool follows\nthe resource table, so these files are effectively abandoned.\n\nCrawling the filesystem for non-checked files would be slow especially having to cross check with already\nparsed files.\n\nSuggestions: [#1366](https://github.com/iBotPeaches/Apktool/issues/1366)\n\n## Android Support\nFolks have requested running Apktool on device itself. This has been a challenge due to the arch requirements\nthat would be placed on the aapt2/aapt binaries.\n\nSuggestions: [#2811](https://github.com/iBotPeaches/Apktool/issues/2811)\n\n## Split APK Support\nApplications are further getting split on qualifiers. Apktool has been built on the assumption of one apk.\n\nSuggestions: [#2283](https://github.com/iBotPeaches/Apktool/issues/2283), [#2218](https://github.com/iBotPeaches/Apktool/issues/2218), [#2880](https://github.com/iBotPeaches/Apktool/issues/2880)\n\n## Version relevant framework files\nApplications are built against a specific framework version. Apktool ships with the latest framework file at that\ntime of release. So an application built with API 33 may be recompiled with API 36 which leads to issues.\n\nApktool packing 15+ older framework files would bloat the distribution. A better solution would be to have a\ncentral repository of framework files that Apktool can download on demand, but that would require hosting\nand maintenance.\n\nSuggestions: [#3946](https://github.com/iBotPeaches/Apktool/issues/3946)\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: SECURITY.md\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n# Security Policy\n\n## Reporting a Vulnerability\n\nIf you discover a security vulnerability within Apktool, please send an e-mail to Connor Tumbleson at connor.tumbleson(at)gmail.com. \nAll security vulnerabilities will be promptly addressed.\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.apktool;\n\nimport brut.androlib.ApkBuilder;\nimport brut.androlib.ApkDecoder;\nimport brut.androlib.Config;\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.FrameworkNotFoundException;\nimport brut.androlib.exceptions.InFileNotFoundException;\nimport brut.androlib.exceptions.OutDirExistsException;\nimport brut.androlib.res.AaptManager;\nimport brut.androlib.res.Framework;\nimport brut.util.OSDetection;\nimport org.apache.commons.cli.*;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Properties;\nimport java.util.logging.*;\n\n/**\n * Main entry point of apktool.\n */\npublic class Main {\n private enum Verbosity { NORMAL, VERBOSE, QUIET }\n\n private static final Option verboseOption = Option.builder(\"v\")\n .longOpt(\"verbose\")\n .desc(\"Increase output verbosity.\")\n .get();\n\n private static final Option quietOption = Option.builder(\"q\")\n .longOpt(\"quiet\")\n .desc(\"Suppress normal output.\")\n .get();\n\n private static final Option jobsOption = Option.builder(\"j\")\n .longOpt(\"jobs\")\n .desc(\"Set the number of jobs to execute in parallel to .\")\n .hasArg()\n .argName(\"num\")\n .type(Integer.class)\n .get();\n\n private static final Option frameDirOption = Option.builder(\"p\")\n .longOpt(\"frame-path\")\n .desc(\"Use framework files located in .\")\n .hasArg()\n .argName(\"dir\")\n .get();\n\n private static final Option frameTagOption = Option.builder(\"t\")\n .longOpt(\"frame-tag\")\n .desc(\"Use framework files tagged with .\")\n .hasArg()\n .argName(\"tag\")\n .get();\n\n private static final Option libOption = Option.builder(\"l\")\n .longOpt(\"lib\")\n .desc(\"Use shared library located in .\\n\"\n + \"Can be specified multiple times.\")\n .hasArg()\n .argName(\"package:file\")\n .get();\n\n private static final Option decodeForceOption = Option.builder(\"f\")\n .longOpt(\"force\")\n .desc(\"Force delete destination directory.\")\n .get();\n\n private static final Option decodeAllSrcOption = Option.builder(\"a\")\n .longOpt(\"all-src\")\n .desc(\"Decode all sources in the apk (includes unknown dex files).\")\n .get();\n\n private static final Option decodeNoSrcOption = Option.builder(\"s\")\n .longOpt(\"no-src\")\n .desc(\"Do not decode sources.\")\n .get();\n\n private static final Option decodeNoDebugInfoOption = Option.builder()\n .longOpt(\"no-debug-info\")\n .desc(\"Do not include debug info in sources (.local, .param, .line, etc.)\")\n .get();\n\n private static final Option decodeNoResOption = Option.builder(\"r\")\n .longOpt(\"no-res\")\n .desc(\"Do not decode resources.\")\n .get();\n\n private static final Option decodeOnlyManifestOption = Option.builder()\n .longOpt(\"only-manifest\")\n .desc(\"Only decode AndroidManifest.xml without resources.\")\n .get();\n\n private static final Option decodeResResolveModeOption = Option.builder()\n .longOpt(\"res-resolve-mode\")\n .desc(\"Set the resolve mode for resources to .\\n\"\n + \"Possible values: 'default', 'greedy' or 'lazy'.\")\n .hasArg()\n .argName(\"mode\")\n .get();\n\n private static final Option decodeKeepBrokenResOption = Option.builder()\n .longOpt(\"keep-broken-res\")\n .desc(\"Use if there was an error and some resources were dropped, e.g.\\n\"\n + \"\\\"Invalid resource config detected. Dropping resources\\\", but you\\n\"\n + \"want to decode them anyway, even with errors. You will have to\\n\"\n + \"fix them manually before building.\")\n .get();\n\n private static final Option decodeIgnoreRawValuesOption = Option.builder()\n .longOpt(\"ignore-raw-values\")\n .desc(\"Ignore raw attribute values in XML resource files.\")\n .get();\n\n private static final Option decodeMatchOriginalOption = Option.builder()\n .longOpt(\"match-original\")\n .desc(\"Keep files closest to original as possible (prevents rebuild).\")\n .get();\n\n private static final Option decodeNoAssetsOption = Option.builder()\n .longOpt(\"no-assets\")\n .desc(\"Do not decode assets.\")\n .get();\n\n private static final Option decodeOutputOption = Option.builder(\"o\")\n .longOpt(\"output\")\n .desc(\"Output decoded files to . (default: apk.out)\")\n .hasArg()\n .argName(\"dir\")\n .get();\n\n private static final Option buildForceOption = Option.builder(\"f\")\n .longOpt(\"force\")\n .desc(\"Skip changes detection and build all files.\")\n .get();\n\n private static final Option buildNoApkOption = Option.builder()\n .longOpt(\"no-apk\")\n .desc(\"Disable repacking of the built files into a new apk.\")\n .get();\n\n private static final Option buildNoCrunchOption = Option.builder()\n .longOpt(\"no-crunch\")\n .desc(\"Disable crunching of resource files during the build step.\")\n .get();\n\n private static final Option buildCopyOriginalOption = Option.builder()\n .longOpt(\"copy-original\")\n .desc(\"Copy original AndroidManifest.xml and META-INF. See project page for more info.\")\n .get();\n\n private static final Option buildDebuggableOption = Option.builder()\n .longOpt(\"debuggable\")\n .desc(\"Set android:debuggable to \\\"true\\\" in AndroidManifest.xml for the built apk.\")\n .get();\n\n private static final Option buildNetSecConfOption = Option.builder()\n .longOpt(\"net-sec-conf\")\n .desc(\"Add a generic network security configuration file to the built apk.\")\n .get();\n\n private static final Option buildAaptOption = Option.builder()\n .longOpt(\"aapt\")\n .desc(\"Use aapt2 binary located in .\")\n .hasArg()\n .argName(\"file\")\n .get();\n\n private static final Option buildOutputOption = Option.builder(\"o\")\n .longOpt(\"output\")\n .desc(\"Output the built apk to . (default: dist/name.apk)\")\n .hasArg()\n .argName(\"file\")\n .get();\n\n private static final Option frameFrameDirOption = Option.builder(\"p\")\n .longOpt(\"frame-path\")\n .desc(\"Set the path for framework files to .\")\n .hasArg()\n .argName(\"dir\")\n .get();\n\n private static final Option frameFrameTagOption = Option.builder(\"t\")\n .longOpt(\"frame-tag\")\n .desc(\"Suffix framework files with .\")\n .hasArg()\n .argName(\"tag\")\n .get();\n\n private static final Option frameForceAllOption = Option.builder(\"a\")\n .longOpt(\"all\")\n .desc(\"Include all framework files regardless of tag.\")\n .get();\n\n private static final Options generalOptions = new Options();\n private static final Options decodeOptions = new Options();\n private static final Options buildOptions = new Options();\n private static final Options installFrameworkOptions = new Options();\n private static final Options cleanFrameworksOptions = new Options();\n private static final Options listFrameworksOptions = new Options();\n private static final Options publicizeResourcesOptions = new Options();\n\n private static final Props props = new Props();\n private static final Config config = new Config(props.getVersion());\n private static Options loadedOptions = null;\n private static boolean advancedMode = false;\n\n private static void loadOptions(Options options, boolean advanced) {\n loadedOptions = options;\n advancedMode = advanced;\n\n generalOptions.addOption(quietOption);\n generalOptions.addOption(verboseOption);\n\n if (options == null || options == decodeOptions) {\n decodeOptions.addOption(decodeAllSrcOption);\n decodeOptions.addOption(decodeForceOption);\n decodeOptions.addOption(decodeNoResOption);\n decodeOptions.addOption(decodeNoSrcOption);\n decodeOptions.addOption(decodeOutputOption);\n decodeOptions.addOption(frameDirOption);\n decodeOptions.addOption(frameTagOption);\n decodeOptions.addOption(jobsOption);\n decodeOptions.addOption(libOption);\n if (advanced) {\n decodeOptions.addOption(decodeIgnoreRawValuesOption);\n decodeOptions.addOption(decodeKeepBrokenResOption);\n decodeOptions.addOption(decodeMatchOriginalOption);\n decodeOptions.addOption(decodeNoAssetsOption);\n decodeOptions.addOption(decodeNoDebugInfoOption);\n decodeOptions.addOption(decodeOnlyManifestOption);\n decodeOptions.addOption(decodeResResolveModeOption);\n }\n }\n\n if (options == null || options == buildOptions) {\n buildOptions.addOption(buildForceOption);\n buildOptions.addOption(buildOutputOption);\n buildOptions.addOption(frameDirOption);\n buildOptions.addOption(jobsOption);\n buildOptions.addOption(libOption);\n if (advanced) {\n buildOptions.addOption(buildAaptOption);\n buildOptions.addOption(buildCopyOriginalOption);\n buildOptions.addOption(buildDebuggableOption);\n buildOptions.addOption(buildNetSecConfOption);\n buildOptions.addOption(buildNoApkOption);\n buildOptions.addOption(buildNoCrunchOption);\n }\n }\n\n if (options == null || options == installFrameworkOptions) {\n installFrameworkOptions.addOption(frameFrameDirOption);\n installFrameworkOptions.addOption(frameFrameTagOption);\n }\n\n if (options == null || options == cleanFrameworksOptions) {\n cleanFrameworksOptions.addOption(frameForceAllOption);\n cleanFrameworksOptions.addOption(frameFrameDirOption);\n cleanFrameworksOptions.addOption(frameFrameTagOption);\n }\n\n if (options == null || options == listFrameworksOptions) {\n listFrameworksOptions.addOption(frameForceAllOption);\n listFrameworksOptions.addOption(frameFrameDirOption);\n listFrameworksOptions.addOption(frameFrameTagOption);\n }\n }\n\n public static void main(String[] args) throws AndrolibException {\n // Headless\n System.setProperty(\"java.awt.headless\", \"true\");\n\n // Ignore stricter validation on zip files from java 11 onwards as this is a protection technique that\n // applications use to thwart disassembly tools. We have protections in place for directory traversal\n // and handling of bogus data in the zip header, so we can ignore this.\n System.setProperty(\"jdk.nio.zipfs.allowDotZipEntry\", \"true\");\n System.setProperty(\"jdk.util.zip.disableZip64ExtraFieldValidation\", \"true\");\n\n if (!OSDetection.is64Bit()) {\n System.err.println(\"Warning: Apktool no longer supports 32-bit platforms.\");\n }\n\n if (args.length == 0) {\n loadOptions(null, false);\n printUsage();\n return;\n }\n\n String cmdName = args[0];\n String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);\n\n switch (cmdName) {\n case \"d\":\n case \"decode\":\n cmdDecode(cmdArgs);\n break;\n case \"b\":\n case \"build\":\n cmdBuild(cmdArgs);\n break;\n case \"if\":\n case \"install-framework\":\n cmdInstallFramework(cmdArgs);\n break;\n case \"cf\":\n case \"clean-frameworks\":\n cmdCleanFrameworks(cmdArgs);\n break;\n case \"lf\":\n case \"list-frameworks\":\n cmdListFrameworks(cmdArgs);\n break;\n case \"pr\":\n case \"publicize-resources\":\n cmdPublicizeResources(cmdArgs);\n break;\n case \"h\":\n case \"help\":\n case \"-help\":\n case \"--help\":\n loadOptions(null, true);\n printUsage();\n break;\n case \"v\":\n case \"version\":\n case \"-version\":\n case \"--version\":\n printVersion();\n break;\n default:\n System.err.println(\"Unrecognized command: \" + cmdName);\n loadOptions(null, false);\n printUsage();\n System.exit(1);\n }\n }\n\n private static CommandLine parseOptions(Options options, String[] args) {\n loadOptions(options, true);\n\n Options combinedOptions = new Options();\n combinedOptions.addOptions(generalOptions);\n combinedOptions.addOptions(options);\n\n CommandLine cli;\n try {\n cli = new DefaultParser(false).parse(combinedOptions, args, false);\n } catch (ParseException ex) {\n System.err.println(ex.getMessage());\n printUsage();\n System.exit(1);\n return null;\n }\n\n // Check for verbose/quiet.\n Verbosity verbosity = Verbosity.NORMAL;\n if (cli.hasOption(verboseOption)) {\n config.setVerbose(true);\n verbosity = Verbosity.VERBOSE;\n }\n if (cli.hasOption(quietOption)) {\n if (cli.hasOption(verboseOption)) {\n printOptionConflict(quietOption, verboseOption);\n } else {\n verbosity = Verbosity.QUIET;\n }\n }\n setupLogging(verbosity);\n\n return cli;\n }\n\n private static void cmdDecode(String[] args) throws AndrolibException {\n CommandLine cli = parseOptions(decodeOptions, args);\n List argList = cli.getArgList();\n String apkName;\n switch (argList.size()) {\n case 0:\n System.err.println(\"Input apk file was not specified.\");\n System.exit(1);\n return;\n case 1:\n apkName = argList.get(0);\n break;\n default:\n System.err.println(\"Invalid arguments.\");\n printUsage();\n System.exit(1);\n return;\n }\n\n if (cli.hasOption(jobsOption)) {\n config.setJobs(Integer.parseInt(cli.getOptionValue(jobsOption)));\n }\n if (cli.hasOption(frameDirOption)) {\n config.setFrameworkDirectory(cli.getOptionValue(frameDirOption));\n }\n if (cli.hasOption(frameTagOption)) {\n config.setFrameworkTag(cli.getOptionValue(frameTagOption));\n }\n if (cli.hasOption(libOption)) {\n config.setLibraryFiles(cli.getOptionValues(libOption));\n }\n if (cli.hasOption(decodeForceOption)) {\n config.setForced(true);\n }\n if (cli.hasOption(decodeAllSrcOption)) {\n config.setDecodeSources(Config.DecodeSources.FULL);\n }\n if (cli.hasOption(decodeNoSrcOption)) {\n if (cli.hasOption(decodeAllSrcOption)) {\n printOptionConflict(decodeNoSrcOption, decodeAllSrcOption);\n } else {\n config.setDecodeSources(Config.DecodeSources.NONE);\n }\n }\n if (cli.hasOption(decodeNoDebugInfoOption)) {\n if (cli.hasOption(decodeNoSrcOption)) {\n printOptionConflict(decodeNoDebugInfoOption, decodeNoSrcOption);\n } else {\n config.setBaksmaliDebugMode(false);\n }\n }\n if (cli.hasOption(decodeNoResOption)) {\n config.setDecodeResources(Config.DecodeResources.NONE);\n }\n if (cli.hasOption(decodeOnlyManifestOption)) {\n if (cli.hasOption(decodeNoResOption)) {\n printOptionConflict(decodeOnlyManifestOption, decodeNoResOption);\n } else {\n config.setDecodeResources(Config.DecodeResources.ONLY_MANIFEST);\n }\n }\n if (cli.hasOption(decodeResResolveModeOption)) {\n if (cli.hasOption(decodeNoResOption)) {\n printOptionConflict(decodeResResolveModeOption, decodeNoResOption);\n } else if (cli.hasOption(decodeOnlyManifestOption)) {\n printOptionConflict(decodeResResolveModeOption, decodeOnlyManifestOption);\n } else {\n String mode = cli.getOptionValue(decodeResResolveModeOption);\n switch (mode) {\n case \"default\":\n config.setDecodeResolve(Config.DecodeResolve.DEFAULT);\n break;\n case \"greedy\":\n config.setDecodeResolve(Config.DecodeResolve.GREEDY);\n break;\n case \"lazy\":\n config.setDecodeResolve(Config.DecodeResolve.LAZY);\n break;\n default:\n System.err.println(\"Unknown resolve resources mode: \" + mode);\n System.err.println(\"Expect: 'default', 'greedy' or 'lazy'.\");\n System.exit(1);\n return;\n }\n }\n }\n if (cli.hasOption(decodeKeepBrokenResOption)) {\n if (cli.hasOption(decodeNoResOption)) {\n printOptionConflict(decodeKeepBrokenResOption, decodeNoResOption);\n } else if (cli.hasOption(decodeOnlyManifestOption)) {\n printOptionConflict(decodeKeepBrokenResOption, decodeOnlyManifestOption);\n } else {\n config.setKeepBrokenResources(true);\n }\n }\n if (cli.hasOption(decodeIgnoreRawValuesOption)) {\n if (cli.hasOption(decodeNoResOption)) {\n printOptionConflict(decodeIgnoreRawValuesOption, decodeNoResOption);\n } else {\n config.setIgnoreRawValues(true);\n }\n }\n if (cli.hasOption(decodeMatchOriginalOption)) {\n config.setAnalysisMode(true);\n }\n if (cli.hasOption(decodeNoAssetsOption)) {\n config.setDecodeAssets(Config.DecodeAssets.NONE);\n }\n\n File outDir;\n if (cli.hasOption(decodeOutputOption)) {\n outDir = new File(cli.getOptionValue(decodeOutputOption));\n } else {\n outDir = new File(apkName.endsWith(\".apk\")\n ? apkName.substring(0, apkName.length() - 4).trim()\n : apkName + \".out\");\n }\n\n try {\n new ApkDecoder(new File(apkName), config).decode(outDir);\n } catch (InFileNotFoundException | OutDirExistsException | FrameworkNotFoundException ex) {\n System.err.println(ex.getMessage());\n System.exit(1);\n }\n }\n\n private static void cmdBuild(String[] args) throws AndrolibException {\n CommandLine cli = parseOptions(buildOptions, args);\n List argList = cli.getArgList();\n String apkDirName;\n switch (argList.size()) {\n case 0:\n apkDirName = \".\"; // current directory\n break;\n case 1:\n apkDirName = argList.get(0);\n break;\n default:\n System.err.println(\"Invalid arguments.\");\n printUsage();\n System.exit(1);\n return;\n }\n\n if (cli.hasOption(jobsOption)) {\n config.setJobs(Integer.parseInt(cli.getOptionValue(jobsOption)));\n }\n if (cli.hasOption(frameDirOption)) {\n config.setFrameworkDirectory(cli.getOptionValue(frameDirOption));\n }\n if (cli.hasOption(libOption)) {\n config.setLibraryFiles(cli.getOptionValues(libOption));\n }\n if (cli.hasOption(buildForceOption)) {\n config.setForced(true);\n }\n if (cli.hasOption(buildNoApkOption)) {\n config.setNoApk(true);\n }\n if (cli.hasOption(buildNoCrunchOption)) {\n config.setNoCrunch(true);\n }\n if (cli.hasOption(buildCopyOriginalOption)) {\n config.setCopyOriginal(true);\n }\n if (cli.hasOption(buildDebuggableOption)) {\n config.setDebuggable(true);\n }\n if (cli.hasOption(buildNetSecConfOption)) {\n config.setNetSecConf(true);\n }\n if (cli.hasOption(buildAaptOption)) {\n try {\n String aaptBinary = cli.getOptionValue(buildAaptOption);\n if (AaptManager.getBinaryVersion(new File(aaptBinary)) == 1) {\n throw new AndrolibException(\"Legacy aapt is no longer supported.\");\n }\n\n config.setAaptBinary(aaptBinary);\n } catch (AndrolibException ex) {\n System.err.println(ex.getMessage());\n System.exit(1);\n return;\n }\n }\n\n File outFile = null;\n if (cli.hasOption(buildOutputOption)) {\n if (cli.hasOption(buildNoApkOption)) {\n printOptionConflict(buildOutputOption, buildNoApkOption);\n } else {\n outFile = new File(cli.getOptionValue(buildOutputOption));\n }\n }\n\n new ApkBuilder(new File(apkDirName), config).build(outFile);\n }\n\n private static void cmdInstallFramework(String[] args) throws AndrolibException {\n CommandLine cli = parseOptions(installFrameworkOptions, args);\n List argList = cli.getArgList();\n String apkName;\n switch (argList.size()) {\n case 0:\n System.err.println(\"Input apk file was not specified.\");\n System.exit(1);\n return;\n case 1:\n apkName = argList.get(0);\n break;\n default:\n System.err.println(\"Invalid arguments.\");\n printUsage();\n System.exit(1);\n return;\n }\n\n if (cli.hasOption(frameFrameDirOption)) {\n config.setFrameworkDirectory(cli.getOptionValue(frameFrameDirOption));\n }\n if (cli.hasOption(frameFrameTagOption)) {\n config.setFrameworkTag(cli.getOptionValue(frameFrameTagOption));\n }\n\n new Framework(config).install(new File(apkName));\n }\n\n private static void cmdCleanFrameworks(String[] args) throws AndrolibException {\n CommandLine cli = parseOptions(cleanFrameworksOptions, args);\n List argList = cli.getArgList();\n if (!argList.isEmpty()) {\n System.err.println(\"Invalid arguments.\");\n printUsage();\n System.exit(1);\n return;\n }\n\n if (cli.hasOption(frameFrameDirOption)) {\n config.setFrameworkDirectory(cli.getOptionValue(frameFrameDirOption));\n }\n if (cli.hasOption(frameFrameTagOption)) {\n config.setFrameworkTag(cli.getOptionValue(frameFrameTagOption));\n }\n if (cli.hasOption(frameForceAllOption)) {\n if (cli.hasOption(frameFrameTagOption)) {\n printOptionConflict(frameForceAllOption, frameFrameTagOption);\n } else {\n config.setForced(true);\n }\n }\n\n new Framework(config).cleanDirectory();\n }\n\n private static void cmdListFrameworks(String[] args) throws AndrolibException {\n CommandLine cli = parseOptions(listFrameworksOptions, args);\n List argList = cli.getArgList();\n if (!argList.isEmpty()) {\n System.err.println(\"Invalid arguments.\");\n printUsage();\n System.exit(1);\n return;\n }\n\n if (cli.hasOption(frameFrameDirOption)) {\n config.setFrameworkDirectory(cli.getOptionValue(frameFrameDirOption));\n }\n if (cli.hasOption(frameFrameTagOption)) {\n config.setFrameworkTag(cli.getOptionValue(frameFrameTagOption));\n }\n if (cli.hasOption(frameForceAllOption)) {\n if (cli.hasOption(frameFrameTagOption)) {\n printOptionConflict(frameForceAllOption, frameFrameTagOption);\n } else {\n config.setForced(true);\n }\n }\n\n for (File file : new Framework(config).listDirectory()) {\n System.out.println(file.getName());\n }\n }\n\n private static void cmdPublicizeResources(String[] args) throws AndrolibException {\n CommandLine cli = parseOptions(publicizeResourcesOptions, args);\n List argList = cli.getArgList();\n String arscName;\n switch (argList.size()) {\n case 0:\n System.err.println(\"Input arsc file was not specified.\");\n System.exit(1);\n return;\n case 1:\n arscName = argList.get(0);\n break;\n default:\n System.err.println(\"Invalid arguments.\");\n printUsage();\n System.exit(1);\n return;\n }\n\n new Framework(config).publicizeResources(new File(arscName));\n }\n\n private static void printOptionConflict(Option option, Option conflict) {\n System.err.println(\"Ignoring \" + formatOption(option) + \" (cannot be used with \" + formatOption(conflict) + \")\");\n }\n\n private static String formatOption(Option option) {\n StringBuilder sb = new StringBuilder();\n String shortName = option.getOpt();\n if (shortName != null) {\n sb.append('-').append(shortName);\n }\n String longName = option.getLongOpt();\n if (longName != null) {\n if (sb.length() > 0) {\n sb.append('/');\n }\n sb.append(\"--\").append(longName);\n }\n return sb.toString();\n }\n\n @SuppressWarnings(\"deprecation\")\n private static void printUsage() {\n PrintWriter writer = new PrintWriter(System.out);\n HelpFormatter formatter = new HelpFormatter();\n\n // Print header.\n writer.println(\"Apktool \" + props.getVersion() + \" - a tool for reengineering Android apk files\");\n writer.println(\"with smali \" + props.getSmaliVersion() + \" and baksmali \" + props.getBaksmaliVersion());\n writer.println(\"Copyright 2010 Ryszard Wi\u015bniewski \");\n writer.println(\"Copyright 2010 Connor Tumbleson \");\n if (advancedMode) {\n writer.println(\"Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0)\");\n }\n writer.println();\n\n // Print usages.\n writer.println(\"General options:\");\n printOptions(writer, formatter, generalOptions);\n writer.println();\n if (loadedOptions == null || loadedOptions == decodeOptions) {\n writer.println(\"apktool d|decode [options] \");\n printOptions(writer, formatter, decodeOptions);\n writer.println();\n }\n if (loadedOptions == null || loadedOptions == buildOptions) {\n writer.println(\"apktool b|build [options] \");\n printOptions(writer, formatter, buildOptions);\n writer.println();\n }\n if (loadedOptions == null || loadedOptions == installFrameworkOptions) {\n writer.println(\"apktool if|install-framework [options] \");\n printOptions(writer, formatter, installFrameworkOptions);\n writer.println();\n }\n if ((advancedMode && loadedOptions == null) || loadedOptions == cleanFrameworksOptions) {\n writer.println(\"apktool cf|clean-frameworks [options]\");\n printOptions(writer, formatter, cleanFrameworksOptions);\n writer.println();\n }\n if ((advancedMode && loadedOptions == null) || loadedOptions == listFrameworksOptions) {\n writer.println(\"apktool lf|list-frameworks [options]\");\n printOptions(writer, formatter, listFrameworksOptions);\n writer.println();\n }\n if ((advancedMode && loadedOptions == null) || loadedOptions == publicizeResourcesOptions) {\n writer.println(\"apktool pr|publicize-resources \");\n printOptions(writer, formatter, publicizeResourcesOptions);\n writer.println();\n }\n if (loadedOptions == null) {\n writer.println(\"apktool h|help\");\n writer.println();\n writer.println(\"apktool v|version\");\n writer.println();\n }\n\n // Print footer.\n writer.println(\"For additional info, see: https://apktool.org\");\n writer.println(\"For smali/baksmali info, see: https://github.com/google/smali\");\n\n writer.flush();\n }\n\n @SuppressWarnings(\"deprecation\")\n private static void printOptions(PrintWriter writer, HelpFormatter formatter, Options options) {\n final int width = 120;\n final int leftPadding = 1;\n final int descPadding = 3;\n\n if (!options.getOptions().isEmpty()) {\n formatter.printOptions(writer, width, options, leftPadding, descPadding);\n }\n }\n\n private static void printVersion() {\n System.out.println(props.getVersion());\n }\n\n private static void setupLogging(Verbosity verbosity) {\n LogManager.getLogManager().reset();\n Logger logger = Logger.getLogger(\"\");\n\n if (verbosity == Verbosity.QUIET) {\n logger.setLevel(Level.OFF);\n return;\n }\n\n Handler handler = new Handler() {\n @Override\n public void publish(LogRecord record) {\n if (!isLoggable(record)) {\n return;\n }\n try {\n String message = getFormatter().format(record);\n int level = record.getLevel().intValue();\n if (level >= Level.WARNING.intValue()) {\n System.err.println(message);\n } else {\n System.out.println(message);\n }\n } catch (Exception ex) {\n reportError(null, ex, ErrorManager.FORMAT_FAILURE);\n }\n }\n\n @Override\n public void flush() {\n System.out.flush();\n System.err.flush();\n }\n\n @Override\n public void close() throws SecurityException {\n flush();\n }\n };\n handler.setFormatter(new Formatter() {\n @Override\n public String format(LogRecord record) {\n String prefix;\n int level = record.getLevel().intValue();\n if (level >= Level.SEVERE.intValue()) {\n prefix = \"E\";\n } else if (level >= Level.WARNING.intValue()) {\n prefix = \"W\";\n } else if (level >= Level.INFO.intValue()) {\n prefix = \"I\";\n } else {\n prefix = \"D\";\n }\n return prefix + \": \" + record.getMessage();\n }\n });\n logger.addHandler(handler);\n logger.setLevel(verbosity == Verbosity.VERBOSE ? Level.ALL : Level.INFO);\n }\n\n private static class Props extends Properties {\n\n public Props() {\n load(this, \"/apktool.properties\");\n\n Properties smaliProps = new Properties();\n load(smaliProps, \"/smali.properties\");\n String smaliVersion = smaliProps.getProperty(\"application.version\", \"\");\n if (!smaliVersion.isEmpty()) {\n put(\"smali.version\", smaliVersion);\n }\n\n Properties baksmaliProps = new Properties();\n load(baksmaliProps, \"/baksmali.properties\");\n String baksmaliVersion = baksmaliProps.getProperty(\"application.version\", \"\");\n if (!baksmaliVersion.isEmpty()) {\n put(\"baksmali.version\", baksmaliVersion);\n }\n }\n\n public String getVersion() {\n return getProperty(\"application.version\", \"(unknown)\");\n }\n\n public String getSmaliVersion() {\n return getProperty(\"smali.version\", \"(unknown)\");\n }\n\n public String getBaksmaliVersion() {\n return getProperty(\"baksmali.version\", \"(unknown)\");\n }\n\n private void load(Properties props, String name) {\n try (InputStream in = Main.class.getResourceAsStream(name)) {\n if (in == null) {\n throw new FileNotFoundException(name);\n }\n props.load(in);\n } catch (IOException ignored) {\n System.err.println(\"Could not load resource: \" + name);\n }\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkBuilder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.meta.SdkInfo;\nimport brut.androlib.res.AaptInvoker;\nimport brut.androlib.res.AaptManager;\nimport brut.androlib.res.data.ResChunkHeader;\nimport brut.androlib.res.table.ResConfig;\nimport brut.androlib.res.xml.ResXmlUtils;\nimport brut.androlib.smali.SmaliBuilder;\nimport brut.common.BrutException;\nimport brut.common.Log;\nimport brut.directory.Directory;\nimport brut.directory.DirectoryException;\nimport brut.directory.ExtFile;\nimport brut.directory.FileDirectory;\nimport brut.directory.ZipRODirectory;\nimport brut.util.BackgroundWorker;\nimport brut.util.BinaryDataInputStream;\nimport brut.util.BrutIO;\nimport brut.util.OS;\nimport brut.util.ZipUtils;\n\nimport java.io.*;\nimport java.nio.file.Files;\nimport java.util.*;\nimport java.util.concurrent.atomic.AtomicReference;\nimport java.util.zip.ZipOutputStream;\n\npublic class ApkBuilder {\n private static final String TAG = ApkBuilder.class.getName();\n\n private final ExtFile mApkDir;\n private final Config mConfig;\n private final AtomicReference mFirstError;\n\n private ApkInfo mApkInfo;\n private SmaliBuilder mSmaliBuilder;\n private AaptInvoker mAaptInvoker;\n private BackgroundWorker mWorker;\n\n public ApkBuilder(File apkDir, Config config) {\n mApkDir = new ExtFile(apkDir);\n mConfig = config;\n mFirstError = new AtomicReference<>();\n }\n\n public void build(File outApk) throws AndrolibException {\n if (mConfig.getJobs() > 1) {\n mWorker = new BackgroundWorker(mConfig.getJobs() - 1);\n }\n try {\n mApkInfo = ApkInfo.load(mApkDir);\n String minSdkVersion = mApkInfo.getSdkInfo().getMinSdkVersion();\n mSmaliBuilder = new SmaliBuilder(minSdkVersion != null ? SdkInfo.parseSdkInt(minSdkVersion) : 0);\n mAaptInvoker = new AaptInvoker(mApkInfo, mConfig);\n\n String apkName = mApkInfo.getApkFileName();\n if (apkName == null) {\n apkName = \"out.apk\";\n }\n if (mConfig.isNoApk()) {\n outApk = null;\n } else if (outApk == null) {\n outApk = new File(mApkDir, \"dist/\" + apkName);\n }\n\n File outDir = new File(mApkDir, \"build/apk\");\n OS.mkdir(outDir);\n\n Log.i(TAG, \"Using Apktool \" + mConfig.getVersion() + \" on \" + apkName\n + (mWorker != null ? \" with \" + mConfig.getJobs() + \" threads\" : \"\"));\n\n buildSources(outDir);\n buildResources(outDir);\n\n if (mWorker != null) {\n mWorker.waitForFinish();\n if (mFirstError.get() != null) {\n throw mFirstError.get();\n }\n }\n\n copyOriginalFiles(outDir);\n if (outApk != null) {\n buildApkFile(outDir, outApk);\n }\n } finally {\n if (mWorker != null) {\n mWorker.shutdownNow();\n }\n }\n }\n\n private void buildSources(File outDir) throws AndrolibException {\n try {\n Directory in = mApkDir.getDirectory();\n\n // Copy raw dex files.\n Set dexFiles = new HashSet<>();\n for (String fileName : in.getFiles()) {\n if (fileName.endsWith(\".dex\")) {\n copySourcesRaw(outDir, fileName);\n dexFiles.add(fileName);\n }\n }\n\n // Build smali dirs.\n for (String dirName : in.getDirs().keySet()) {\n String fileName;\n if (dirName.equals(\"smali\")) {\n fileName = \"classes.dex\";\n } else if (dirName.startsWith(\"smali_\")) {\n fileName = dirName.substring(dirName.indexOf('_') + 1).replace('@', File.separatorChar) + \".dex\";\n } else {\n continue;\n }\n\n if (!dexFiles.contains(fileName)) {\n buildSourcesSmali(outDir, dirName, fileName);\n }\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copySourcesRaw(File outDir, String fileName) throws AndrolibException {\n File inFile = new File(mApkDir, fileName);\n File outFile = new File(outDir, fileName);\n\n if (!mConfig.isForced() && !isFileNewer(inFile, outFile)) {\n Log.i(TAG, fileName + \" has not changed.\");\n return;\n }\n\n Log.i(TAG, \"Copying raw \" + fileName + \"...\");\n try {\n BrutIO.copyAndClose(Files.newInputStream(inFile.toPath()), Files.newOutputStream(outFile.toPath()));\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void buildSourcesSmali(File outDir, String dirName, String fileName) throws AndrolibException {\n if (mWorker != null) {\n mWorker.submit(() -> {\n if (mFirstError.get() == null) {\n try {\n buildSourcesSmaliJob(outDir, dirName, fileName);\n } catch (AndrolibException ex) {\n mFirstError.compareAndSet(null, ex);\n }\n }\n });\n } else {\n buildSourcesSmaliJob(outDir, dirName, fileName);\n }\n }\n\n private void buildSourcesSmaliJob(File outDir, String dirName, String fileName) throws AndrolibException {\n File smaliDir = new File(mApkDir, dirName);\n File dexFile = new File(outDir, fileName);\n\n if (!mConfig.isForced() && !isFileNewer(smaliDir, dexFile)) {\n Log.i(TAG, dirName + \" has not changed.\");\n return;\n }\n\n Log.i(TAG, \"Smaling \" + dirName + \" folder into \" + fileName + \"...\");\n mSmaliBuilder.build(smaliDir, dexFile);\n }\n\n private void buildResources(File outDir) throws AndrolibException {\n File manifest = new File(mApkDir, \"AndroidManifest.xml\");\n if (!manifest.isFile()) {\n return;\n }\n\n // Check if manifest is binary XML.\n boolean isBinaryManifest;\n try (BinaryDataInputStream in = new BinaryDataInputStream(Files.newInputStream(manifest.toPath()))) {\n isBinaryManifest = ResChunkHeader.read(in).type == ResChunkHeader.RES_XML_TYPE;\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n\n // Copy raw manifest if it's binary XML.\n if (isBinaryManifest) {\n copyManifestRaw(outDir, manifest);\n }\n\n // Copy raw resources if possible.\n File arscFile = new File(mApkDir, \"resources.arsc\");\n if (arscFile.isFile()) {\n copyResourcesRaw(outDir, arscFile);\n return;\n }\n\n // We cannot build if manifest is binary XML.\n if (isBinaryManifest) {\n return;\n }\n\n // Build only manifest if no resources.\n File resDir = new File(mApkDir, \"res\");\n if (!resDir.isDirectory()) {\n buildManifestOnly(outDir, manifest);\n return;\n }\n\n // Build manifest and resources.\n buildResourcesFully(outDir, manifest, resDir);\n }\n\n private void copyManifestRaw(File outDir, File manifest) throws AndrolibException {\n if (!mConfig.isForced() && !isFileNewer(manifest, new File(outDir, \"AndroidManifest.xml\"))) {\n Log.i(TAG, \"AndroidManifest.xml has not changed.\");\n return;\n }\n\n Log.i(TAG, \"Copying raw AndroidManifest.xml...\");\n try {\n Directory in = mApkDir.getDirectory();\n\n in.copyToDir(outDir, \"AndroidManifest.xml\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copyResourcesRaw(File outDir, File arscFile) throws AndrolibException {\n if (!mConfig.isForced() && !isFileNewer(arscFile, new File(outDir, \"resources.arsc\"))) {\n Log.i(TAG, \"resources.arsc has not changed.\");\n return;\n }\n\n Log.i(TAG, \"Copying raw resources.arsc...\");\n try {\n Directory in = mApkDir.getDirectory();\n\n in.copyToDir(outDir, \"resources.arsc\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void buildManifestOnly(File outDir, File manifest) throws AndrolibException {\n if (!mConfig.isForced() && !isFileNewer(manifest, new File(outDir, \"AndroidManifest.xml\"))) {\n Log.i(TAG, \"AndroidManifest.xml has not changed.\");\n return;\n }\n\n // Back up manifest for editing.\n File manifestOrig = new File(manifest.getPath() + \".orig\");\n try {\n OS.cpfile(manifest, manifestOrig);\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n\n ResXmlUtils.fixingPublicAttrsInProviderAttributes(manifest);\n\n if (mConfig.isDebuggable()) {\n Log.i(TAG, \"Setting 'debuggable' attribute to 'true' in AndroidManifest.xml...\");\n ResXmlUtils.setApplicationDebugTagTrue(manifest);\n }\n\n File tmpFile;\n try {\n tmpFile = File.createTempFile(\"APKTOOL\", null);\n OS.rmfile(tmpFile);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n\n Log.i(TAG, \"Building AndroidManifest.xml with \" + AaptManager.getBinaryName() + \"...\");\n mAaptInvoker.invoke(tmpFile, manifest, null);\n\n try (ZipRODirectory tmpDir = new ZipRODirectory(tmpFile)) {\n tmpDir.copyToDir(outDir, \"AndroidManifest.xml\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n } finally {\n OS.rmfile(tmpFile);\n }\n\n // Restore original manifest.\n try {\n OS.mvfile(manifestOrig, manifest);\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void buildResourcesFully(File outDir, File manifest, File resDir) throws AndrolibException {\n if (!mConfig.isForced() && !isFileNewer(manifest, new File(outDir, \"AndroidManifest.xml\"))\n && !isFileNewer(resDir, new File(outDir, \"res\"))) {\n Log.i(TAG, \"AndroidManifest.xml and resources have not changed.\");\n return;\n }\n\n // Back up manifest for editing.\n File manifestOrig = new File(manifest.getPath() + \".orig\");\n try {\n OS.cpfile(manifest, manifestOrig);\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n\n ResXmlUtils.fixingPublicAttrsInProviderAttributes(manifest);\n\n if (mConfig.isDebuggable()) {\n Log.i(TAG, \"Setting 'debuggable' attribute to 'true' in AndroidManifest.xml...\");\n ResXmlUtils.setApplicationDebugTagTrue(manifest);\n }\n\n if (mConfig.isNetSecConf()) {\n Log.i(TAG, \"Adding permissive network security config in manifest...\");\n File netSecConfOrig = new File(mApkDir, \"res/xml/network_security_config.xml\");\n OS.mkdir(netSecConfOrig.getParentFile());\n ResXmlUtils.modNetworkSecurityConfig(netSecConfOrig);\n ResXmlUtils.setNetworkSecurityConfig(manifest);\n\n String targetSdkVersion = mApkInfo.getSdkInfo().getTargetSdkVersion();\n if (targetSdkVersion != null && SdkInfo.parseSdkInt(targetSdkVersion) < ResConfig.SDK_NOUGAT) {\n Log.w(TAG, \"Target SDK version is lower than 24, Network Security Configuration might be ignored!\");\n }\n }\n\n File tmpFile;\n try {\n tmpFile = File.createTempFile(\"APKTOOL\", null);\n OS.rmfile(tmpFile);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n\n Log.i(TAG, \"Building resources with \" + AaptManager.getBinaryName() + \"...\");\n mAaptInvoker.invoke(tmpFile, manifest, resDir);\n\n try (ZipRODirectory tmpDir = new ZipRODirectory(tmpFile)) {\n tmpDir.copyToDir(outDir, \"AndroidManifest.xml\", \"resources.arsc\", \"res\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n } finally {\n OS.rmfile(tmpFile);\n }\n\n // Restore original manifest.\n try {\n OS.mvfile(manifestOrig, manifest);\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copyOriginalFiles(File outDir) throws AndrolibException {\n if (!mConfig.isCopyOriginal()) {\n return;\n }\n\n File originalDir = new File(mApkDir, \"original\");\n if (!originalDir.isDirectory()) {\n return;\n }\n\n Log.i(TAG, \"Copying original files...\");\n try {\n FileDirectory in = new FileDirectory(originalDir);\n\n for (String fileName : in.getFiles(true)) {\n if (ApkInfo.ORIGINAL_FILES_PATTERN.matcher(fileName).matches()) {\n in.copyToDir(outDir, fileName);\n }\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void buildApkFile(File outDir, File outApk) throws AndrolibException {\n if (outApk.exists()) {\n OS.rmfile(outApk);\n } else {\n File parentDir = outApk.getParentFile();\n if (parentDir != null) {\n OS.mkdir(parentDir);\n }\n }\n\n // Convert to set for fast lookup.\n Set doNotCompress = new HashSet<>(mApkInfo.getDoNotCompress());\n\n Log.i(TAG, \"Building apk file...\");\n try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(outApk.toPath()))) {\n // Zip aapt output files.\n ZipUtils.zipDir(outDir, out, doNotCompress);\n\n // Zip standard raw files.\n for (String dirName : ApkInfo.RAW_DIRS) {\n File rawDir = new File(mApkDir, dirName);\n if (rawDir.isDirectory()) {\n Log.i(TAG, \"Importing \" + dirName + \"...\");\n ZipUtils.zipDir(mApkDir, dirName, out, doNotCompress);\n }\n }\n\n // Zip unknown files.\n File unknownDir = new File(mApkDir, \"unknown\");\n if (unknownDir.isDirectory()) {\n Log.i(TAG, \"Importing unknown files...\");\n ZipUtils.zipDir(unknownDir, out, doNotCompress);\n }\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n Log.i(TAG, \"Built apk into: \" + outApk.getPath());\n }\n\n private boolean isFileNewer(File file, File reference) {\n return !reference.exists() || BrutIO.recursiveModifiedTime(file) > BrutIO.recursiveModifiedTime(reference);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.InFileNotFoundException;\nimport brut.androlib.exceptions.OutDirExistsException;\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.res.ResDecoder;\nimport brut.androlib.smali.SmaliDecoder;\nimport brut.common.Log;\nimport brut.directory.Directory;\nimport brut.directory.DirectoryException;\nimport brut.directory.ExtFile;\nimport brut.util.BackgroundWorker;\nimport brut.util.OS;\nimport com.google.common.annotations.VisibleForTesting;\nimport org.apache.commons.io.FilenameUtils;\n\nimport java.io.*;\nimport java.util.*;\nimport java.util.concurrent.atomic.AtomicReference;\nimport java.util.regex.Pattern;\n\npublic class ApkDecoder {\n private static final String TAG = ApkDecoder.class.getName();\n\n private static final Pattern NO_COMPRESS_EXT_PATTERN = Pattern.compile(\n \"dex|arsc|so|jpg|jpeg|png|gif|wav|mp2|mp3|ogg|aac|mpg|mpeg|mid|midi|smf|jet|\"\n + \"rtttl|imy|xmf|mp4|m4a|m4v|3gp|3gpp|3g2|3gpp2|amr|awb|wma|wmv|webm|webp|mkv\");\n\n private final ExtFile mApkFile;\n private final Config mConfig;\n private final AtomicReference mFirstError;\n\n private ApkInfo mApkInfo;\n private SmaliDecoder mSmaliDecoder;\n private ResDecoder mResDecoder;\n private BackgroundWorker mWorker;\n\n public ApkDecoder(File apkFile, Config config) {\n mApkFile = new ExtFile(apkFile);\n mConfig = config;\n mFirstError = new AtomicReference<>();\n }\n\n public void decode(File outDir) throws AndrolibException {\n if (!mConfig.isForced() && outDir.exists()) {\n throw new OutDirExistsException(outDir.getPath());\n }\n if (!mApkFile.isFile() || !mApkFile.canRead()) {\n throw new InFileNotFoundException(mApkFile.getPath());\n }\n if (mConfig.getJobs() > 1) {\n mWorker = new BackgroundWorker(mConfig.getJobs() - 1);\n }\n try {\n mApkInfo = new ApkInfo();\n mApkInfo.setVersion(mConfig.getVersion());\n mApkInfo.setApkFile(mApkFile);\n mSmaliDecoder = new SmaliDecoder(mApkFile, mConfig.isBaksmaliDebugMode());\n mResDecoder = new ResDecoder(mApkInfo, mConfig);\n\n OS.rmdir(outDir);\n OS.mkdir(outDir);\n\n Log.i(TAG, \"Using Apktool \" + mConfig.getVersion() + \" on \" + mApkFile.getName()\n + (mWorker != null ? \" with \" + mConfig.getJobs() + \" threads\" : \"\"));\n\n decodeSources(outDir);\n decodeResources(outDir);\n decodeManifest(outDir);\n\n if (mWorker != null) {\n mWorker.waitForFinish();\n if (mFirstError.get() != null) {\n throw mFirstError.get();\n }\n }\n\n copyOriginalFiles(outDir);\n copyRawFiles(outDir);\n copyUnknownFiles(outDir);\n writeApkInfo(outDir);\n } finally {\n if (mWorker != null) {\n mWorker.shutdownNow();\n }\n try {\n mApkFile.close();\n } catch (DirectoryException ignored) {\n }\n }\n }\n\n @VisibleForTesting\n ApkInfo getApkInfo() {\n return mApkInfo;\n }\n\n private void decodeSources(File outDir) throws AndrolibException {\n if (!mApkInfo.hasSources()) {\n return;\n }\n\n try {\n Directory in = mApkFile.getDirectory();\n boolean allSrc = mConfig.isDecodeSourcesFull();\n boolean noSrc = mConfig.isDecodeSourcesNone();\n\n for (String fileName : in.getFiles(allSrc)) {\n if (allSrc ? !fileName.endsWith(\".dex\") : !ApkInfo.CLASSES_FILES_PATTERN.matcher(fileName).matches()) {\n continue;\n }\n\n if (noSrc) {\n copySourcesRaw(outDir, fileName);\n continue;\n }\n\n String dirName = \"smali\" + (!fileName.equals(\"classes.dex\")\n ? \"_\" + fileName.substring(0, fileName.lastIndexOf('.')).replace(in.separatorChar, '@') : \"\");\n\n decodeSourcesSmali(new File(outDir, dirName), fileName);\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copySourcesRaw(File outDir, String fileName) throws AndrolibException {\n Log.i(TAG, \"Copying raw \" + fileName + \"...\");\n try {\n Directory in = mApkFile.getDirectory();\n\n in.copyToDir(outDir, fileName);\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void decodeSourcesSmali(File outDir, String fileName) throws AndrolibException {\n if (mWorker != null) {\n mWorker.submit(() -> {\n if (mFirstError.get() == null) {\n try {\n decodeSourcesSmaliJob(outDir, fileName);\n } catch (AndrolibException ex) {\n mFirstError.compareAndSet(null, ex);\n }\n }\n });\n } else {\n decodeSourcesSmaliJob(outDir, fileName);\n }\n }\n\n private void decodeSourcesSmaliJob(File outDir, String fileName) throws AndrolibException {\n Log.i(TAG, \"Baksmaling \" + fileName + \"...\");\n mSmaliDecoder.decode(fileName, outDir);\n }\n\n private void decodeResources(File outDir) throws AndrolibException {\n if (!mApkInfo.hasResources()) {\n return;\n }\n\n if (mConfig.isDecodeResourcesFull()) {\n mResDecoder.decodeResources(outDir);\n } else {\n copyResourcesRaw(outDir);\n }\n }\n\n private void copyResourcesRaw(File outDir) throws AndrolibException {\n Log.i(TAG, \"Copying raw resources.arsc...\");\n try {\n Directory in = mApkFile.getDirectory();\n\n in.copyToDir(outDir, \"resources.arsc\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void decodeManifest(File outDir) throws AndrolibException {\n if (!mApkInfo.hasManifest()) {\n return;\n }\n\n if (!mConfig.isDecodeResourcesNone()) {\n mResDecoder.decodeManifest(outDir);\n } else {\n copyManifestRaw(outDir);\n }\n }\n\n private void copyManifestRaw(File outDir) throws AndrolibException {\n Log.i(TAG, \"Copying raw AndroidManifest.xml...\");\n try {\n Directory in = mApkFile.getDirectory();\n\n in.copyToDir(outDir, \"AndroidManifest.xml\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copyRawFiles(File outDir) throws AndrolibException {\n try {\n Directory in = mApkFile.getDirectory();\n Set dexFiles = mSmaliDecoder.getDexFiles();\n Map resFileMap = mResDecoder.getResFileMap();\n boolean noAssets = mConfig.isDecodeAssetsNone();\n\n for (String dirName : ApkInfo.RAW_DIRS) {\n if (!in.containsDir(dirName) || (noAssets && dirName.equals(\"assets\"))) {\n continue;\n }\n\n Log.i(TAG, \"Copying \" + dirName + \"...\");\n for (String fileName : in.getDir(dirName).getFiles(true)) {\n fileName = dirName + in.separator + fileName;\n if (!ApkInfo.ORIGINAL_FILES_PATTERN.matcher(fileName).matches()\n && !dexFiles.contains(fileName) && !resFileMap.containsKey(fileName)) {\n in.copyToDir(outDir, fileName);\n }\n }\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copyOriginalFiles(File outDir) throws AndrolibException {\n File originalDir = new File(outDir, \"original\");\n\n Log.i(TAG, \"Copying original files...\");\n try {\n Directory in = mApkFile.getDirectory();\n\n for (String fileName : in.getFiles(true)) {\n if (ApkInfo.ORIGINAL_FILES_PATTERN.matcher(fileName).matches()) {\n in.copyToDir(originalDir, fileName);\n }\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void copyUnknownFiles(File outDir) throws AndrolibException {\n File unknownDir = new File(outDir, \"unknown\");\n\n Log.i(TAG, \"Copying unknown files...\");\n try {\n Directory in = mApkFile.getDirectory();\n Set dexFiles = mSmaliDecoder.getDexFiles();\n Map resFileMap = mResDecoder.getResFileMap();\n\n for (String fileName : in.getFiles(true)) {\n if (!ApkInfo.STANDARD_FILES_PATTERN.matcher(fileName).matches() && !dexFiles.contains(fileName)\n && !resFileMap.containsKey(fileName)) {\n in.copyToDir(unknownDir, fileName);\n }\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private void writeApkInfo(File outDir) throws AndrolibException {\n // If we did not decode the manifest, store the inferred dex opcode API level.\n if (!mApkInfo.hasManifest() || mConfig.isDecodeResourcesNone()) {\n int apiLevel = mSmaliDecoder.getInferredApiLevel();\n if (apiLevel > 0) {\n mApkInfo.getSdkInfo().setMinSdkVersion(Integer.toString(apiLevel));\n }\n }\n\n // Record uncompressed files.\n try {\n Directory in = mApkFile.getDirectory();\n Map resFileMap = mResDecoder.getResFileMap();\n Set uncompressedExts = new HashSet<>();\n Set uncompressedFiles = new HashSet<>();\n\n for (String fileName : in.getFiles(true)) {\n if (in.getCompressionLevel(fileName) == 0) {\n String ext;\n if (in.getSize(fileName) > 0 && !(ext = FilenameUtils.getExtension(fileName)).isEmpty()\n && NO_COMPRESS_EXT_PATTERN.matcher(ext).matches()) {\n uncompressedExts.add(ext);\n } else {\n uncompressedFiles.add(resFileMap.getOrDefault(fileName, fileName));\n }\n }\n }\n\n // Exclude files with an already recorded extenstion.\n if (!uncompressedExts.isEmpty() && !uncompressedFiles.isEmpty()) {\n Iterator it = uncompressedFiles.iterator();\n while (it.hasNext()) {\n String fileName = it.next();\n String ext = FilenameUtils.getExtension(fileName);\n if (uncompressedExts.contains(ext)) {\n it.remove();\n }\n }\n }\n\n // Update apk info.\n List doNotCompress = mApkInfo.getDoNotCompress();\n if (!uncompressedExts.isEmpty()) {\n List uncompressedExtsList = new ArrayList<>(uncompressedExts);\n uncompressedExtsList.sort(null);\n doNotCompress.addAll(uncompressedExtsList);\n }\n if (!uncompressedFiles.isEmpty()) {\n List uncompressedFilesList = new ArrayList<>(uncompressedFiles);\n uncompressedFilesList.sort(null);\n doNotCompress.addAll(uncompressedFilesList);\n }\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n\n // Serialize apk info to file.\n mApkInfo.save(outDir);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/Config.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\npublic class Config {\n public enum DecodeSources { FULL, ONLY_MAIN_CLASSES, NONE }\n public enum DecodeResources { FULL, ONLY_MANIFEST, NONE }\n public enum DecodeResolve { DEFAULT, GREEDY, LAZY }\n public enum DecodeAssets { FULL, NONE }\n\n private final String mVersion;\n\n // Common options\n private int mJobs;\n private String mFrameworkDirectory;\n private String mFrameworkTag;\n private String[] mLibraryFiles;\n private boolean mForced;\n private boolean mVerbose;\n\n // Decode options\n private DecodeSources mDecodeSources;\n private boolean mBaksmaliDebugMode;\n private DecodeResources mDecodeResources;\n private DecodeResolve mDecodeResolve;\n private boolean mKeepBrokenResources;\n private boolean mIgnoreRawValues;\n private boolean mAnalysisMode;\n private DecodeAssets mDecodeAssets;\n\n // Build options\n private boolean mNoApk;\n private boolean mNoCrunch;\n private boolean mCopyOriginal;\n private boolean mDebuggable;\n private boolean mNetSecConf;\n private String mAaptBinary;\n\n public Config(String version) {\n mVersion = version;\n\n // Common options\n mJobs = Math.min(Runtime.getRuntime().availableProcessors(), 8);\n mFrameworkDirectory = null;\n mFrameworkTag = null;\n mLibraryFiles = null;\n mForced = false;\n mVerbose = false;\n\n // Decode options\n mDecodeSources = DecodeSources.ONLY_MAIN_CLASSES;\n mBaksmaliDebugMode = true;\n mDecodeResources = DecodeResources.FULL;\n mDecodeResolve = DecodeResolve.DEFAULT;\n mKeepBrokenResources = false;\n mIgnoreRawValues = false;\n mAnalysisMode = false;\n mDecodeAssets = DecodeAssets.FULL;\n\n // Build options\n mNoApk = false;\n mNoCrunch = false;\n mCopyOriginal = false;\n mDebuggable = false;\n mNetSecConf = false;\n mAaptBinary = null;\n }\n\n public String getVersion() {\n return mVersion;\n }\n\n // Common options\n\n public int getJobs() {\n return mJobs;\n }\n\n public void setJobs(int jobs) {\n mJobs = jobs;\n }\n\n public String getFrameworkDirectory() {\n return mFrameworkDirectory;\n }\n\n public void setFrameworkDirectory(String frameworkDirectory) {\n mFrameworkDirectory = frameworkDirectory;\n }\n\n public String getFrameworkTag() {\n return mFrameworkTag;\n }\n\n public void setFrameworkTag(String frameworkTag) {\n mFrameworkTag = frameworkTag;\n }\n\n public String[] getLibraryFiles() {\n return mLibraryFiles;\n }\n\n public void setLibraryFiles(String[] libraryFiles) {\n mLibraryFiles = libraryFiles;\n }\n\n public boolean isForced() {\n return mForced;\n }\n\n public void setForced(boolean forced) {\n mForced = forced;\n }\n\n public boolean isVerbose() {\n return mVerbose;\n }\n\n public void setVerbose(boolean verbose) {\n mVerbose = verbose;\n }\n\n // Decode options\n\n public boolean isDecodeSourcesFull() {\n return mDecodeSources == DecodeSources.FULL;\n }\n\n public boolean isDecodeSourcesNone() {\n return mDecodeSources == DecodeSources.NONE;\n }\n\n public void setDecodeSources(DecodeSources decodeSources) {\n assert decodeSources != null;\n mDecodeSources = decodeSources;\n }\n\n public boolean isBaksmaliDebugMode() {\n return mBaksmaliDebugMode;\n }\n\n public void setBaksmaliDebugMode(boolean baksmaliDebugMode) {\n mBaksmaliDebugMode = baksmaliDebugMode;\n }\n\n public boolean isDecodeResourcesFull() {\n return mDecodeResources == DecodeResources.FULL;\n }\n\n public boolean isDecodeResourcesNone() {\n return mDecodeResources == DecodeResources.NONE;\n }\n\n public void setDecodeResources(DecodeResources decodeResources) {\n assert decodeResources != null;\n mDecodeResources = decodeResources;\n }\n\n public boolean isDecodeResolveLazy() {\n return mDecodeResolve == DecodeResolve.LAZY;\n }\n\n public boolean isDecodeResolveGreedy() {\n return mDecodeResolve == DecodeResolve.GREEDY;\n }\n\n public void setDecodeResolve(DecodeResolve decodeResolve) {\n assert decodeResolve != null;\n mDecodeResolve = decodeResolve;\n }\n\n public boolean isKeepBrokenResources() {\n return mKeepBrokenResources;\n }\n\n public void setKeepBrokenResources(boolean keepBrokenResources) {\n mKeepBrokenResources = keepBrokenResources;\n }\n\n public boolean isIgnoreRawValues() {\n return mIgnoreRawValues;\n }\n\n public void setIgnoreRawValues(boolean ignoreRawValues) {\n mIgnoreRawValues = ignoreRawValues;\n }\n\n public boolean isAnalysisMode() {\n return mAnalysisMode;\n }\n\n public void setAnalysisMode(boolean analysisMode) {\n mAnalysisMode = analysisMode;\n }\n\n public boolean isDecodeAssetsFull() {\n return mDecodeAssets == DecodeAssets.FULL;\n }\n\n public boolean isDecodeAssetsNone() {\n return mDecodeAssets == DecodeAssets.NONE;\n }\n\n public void setDecodeAssets(DecodeAssets decodeAssets) {\n assert decodeAssets != null;\n mDecodeAssets = decodeAssets;\n }\n\n // Build options\n\n public boolean isNoApk() {\n return mNoApk;\n }\n\n public void setNoApk(boolean noApk) {\n mNoApk = noApk;\n }\n\n public boolean isNoCrunch() {\n return mNoCrunch;\n }\n\n public void setNoCrunch(boolean noCrunch) {\n mNoCrunch = noCrunch;\n }\n\n public boolean isCopyOriginal() {\n return mCopyOriginal;\n }\n\n public void setCopyOriginal(boolean copyOriginal) {\n mCopyOriginal = copyOriginal;\n }\n\n public boolean isDebuggable() {\n return mDebuggable;\n }\n\n public void setDebuggable(boolean debuggable) {\n mDebuggable = debuggable;\n }\n\n public boolean isNetSecConf() {\n return mNetSecConf;\n }\n\n public void setNetSecConf(boolean netSecConf) {\n mNetSecConf = netSecConf;\n }\n\n public String getAaptBinary() {\n return mAaptBinary;\n }\n\n public void setAaptBinary(String aaptBinary) {\n mAaptBinary = aaptBinary;\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/AndrolibException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\nimport brut.common.BrutException;\n\npublic class AndrolibException extends BrutException {\n\n public AndrolibException() {\n super();\n }\n\n public AndrolibException(String message) {\n super(message);\n }\n\n public AndrolibException(Throwable cause) {\n super(cause);\n }\n\n public AndrolibException(String message, Throwable cause) {\n super(message, cause);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/FrameworkNotFoundException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\npublic class FrameworkNotFoundException extends AndrolibException {\n\n public FrameworkNotFoundException(int pkgId) {\n super(\"Could not find framework resources for package ID \" + pkgId + \".\" + System.lineSeparator()\n + \"You must install proper framework files, see project website for more info.\");\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/InFileNotFoundException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\npublic class InFileNotFoundException extends AndrolibException {\n\n public InFileNotFoundException(String path) {\n super(\"Input file (\" + path + \") was not found or was not readable.\");\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/NinePatchNotFoundException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\npublic class NinePatchNotFoundException extends AndrolibException {\n\n public NinePatchNotFoundException() {\n super(\"Could not find nine patch chunk.\");\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/OutDirExistsException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\npublic class OutDirExistsException extends AndrolibException {\n\n public OutDirExistsException(String path) {\n super(\"Destination directory (\" + path + \") already exists. Use -f option if you want to overwrite it.\");\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/RawXmlEncounteredException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\npublic class RawXmlEncounteredException extends AndrolibException {\n\n public RawXmlEncounteredException(Throwable cause) {\n super(\"Could not decode XML.\", cause);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/exceptions/UndefinedResObjectException.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.exceptions;\n\npublic class UndefinedResObjectException extends AndrolibException {\n\n public UndefinedResObjectException(String message) {\n super(message);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/meta/ApkInfo.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.directory.DirectoryException;\nimport brut.directory.ExtFile;\nimport brut.yaml.*;\nimport com.google.common.annotations.VisibleForTesting;\n\nimport java.io.File;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.nio.file.Files;\nimport java.util.ArrayList;\nimport java.util.LinkedHashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.regex.Pattern;\n\npublic class ApkInfo implements YamlSerializable {\n public static final String[] RAW_DIRS = { \"assets\", \"lib\" };\n\n public static final Pattern CLASSES_FILES_PATTERN = Pattern.compile(\"classes([2-9]|[1-9][0-9]+)?\\\\.dex\");\n\n public static final Pattern ORIGINAL_FILES_PATTERN = Pattern.compile(\n \"AndroidManifest\\\\.xml|META-INF/[^/]+\\\\.(RSA|SF|MF)|stamp-cert-sha256\");\n\n public static final Pattern STANDARD_FILES_PATTERN = Pattern.compile(\n \"resources\\\\.arsc|(\" + String.join(\"|\", RAW_DIRS) + \")/.*|\"\n + CLASSES_FILES_PATTERN.pattern() + \"|\" + ORIGINAL_FILES_PATTERN.pattern());\n\n private String mVersion;\n private String mApkFileName;\n private final UsesFramework mUsesFramework;\n private final List mUsesLibrary;\n private final SdkInfo mSdkInfo;\n private final VersionInfo mVersionInfo;\n private final ResourcesInfo mResourcesInfo;\n private final Map mFeatureFlags;\n private final List mDoNotCompress;\n\n // Only set when loaded from a file (not a stream).\n private ExtFile mApkFile;\n\n public ApkInfo() {\n mVersion = null;\n mApkFileName = null;\n mUsesFramework = new UsesFramework();\n mUsesLibrary = new ArrayList<>();\n mSdkInfo = new SdkInfo();\n mVersionInfo = new VersionInfo();\n mResourcesInfo = new ResourcesInfo();\n mFeatureFlags = new LinkedHashMap<>();\n mDoNotCompress = new ArrayList<>();\n }\n\n public static ApkInfo load(File apkDir) throws AndrolibException {\n File file = new File(apkDir, \"apktool.yml\");\n try (InputStream in = Files.newInputStream(file.toPath())) {\n return load(in);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n @VisibleForTesting\n static ApkInfo load(InputStream in) {\n YamlReader reader = new YamlReader(in);\n ApkInfo apkInfo = new ApkInfo();\n reader.readRoot(apkInfo);\n return apkInfo;\n }\n\n public void save(File apkDir) throws AndrolibException {\n File file = new File(apkDir, \"apktool.yml\");\n try (YamlWriter writer = new YamlWriter(Files.newOutputStream(file.toPath()))) {\n write(writer);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n @Override\n public void readItem(YamlReader reader) {\n YamlLine line = reader.getLine();\n switch (line.getKey()) {\n case \"version\":\n mVersion = line.getValue();\n break;\n case \"apkFileName\":\n mApkFileName = line.getValue();\n break;\n case \"usesFramework\":\n mUsesFramework.clear();\n reader.readObject(mUsesFramework);\n break;\n case \"usesLibrary\":\n mUsesLibrary.clear();\n reader.readStringList(mUsesLibrary);\n break;\n case \"sdkInfo\":\n mSdkInfo.clear();\n reader.readObject(mSdkInfo);\n break;\n case \"versionInfo\":\n mVersionInfo.clear();\n reader.readObject(mVersionInfo);\n break;\n case \"resourcesInfo\":\n mResourcesInfo.clear();\n reader.readObject(mResourcesInfo);\n break;\n case \"featureFlags\":\n mFeatureFlags.clear();\n reader.readBoolMap(mFeatureFlags);\n break;\n case \"doNotCompress\":\n mDoNotCompress.clear();\n reader.readStringList(mDoNotCompress);\n break;\n }\n }\n\n @Override\n public void write(YamlWriter writer) {\n writer.writeString(\"version\", mVersion);\n writer.writeString(\"apkFileName\", mApkFileName);\n if (!mUsesFramework.isEmpty()) {\n writer.writeObject(\"usesFramework\", mUsesFramework);\n }\n if (!mUsesLibrary.isEmpty()) {\n writer.writeList(\"usesLibrary\", mUsesLibrary);\n }\n if (!mSdkInfo.isEmpty()) {\n writer.writeObject(\"sdkInfo\", mSdkInfo);\n }\n if (!mVersionInfo.isEmpty()) {\n writer.writeObject(\"versionInfo\", mVersionInfo);\n }\n if (!mResourcesInfo.isEmpty()) {\n writer.writeObject(\"resourcesInfo\", mResourcesInfo);\n }\n if (!mFeatureFlags.isEmpty()) {\n writer.writeMap(\"featureFlags\", mFeatureFlags);\n }\n if (!mDoNotCompress.isEmpty()) {\n writer.writeList(\"doNotCompress\", mDoNotCompress);\n }\n }\n\n public String getVersion() {\n return mVersion;\n }\n\n public void setVersion(String version) {\n mVersion = version;\n }\n\n public String getApkFileName() {\n return mApkFileName;\n }\n\n public void setApkFileName(String apkFileName) {\n mApkFileName = apkFileName;\n }\n\n public UsesFramework getUsesFramework() {\n return mUsesFramework;\n }\n\n public List getUsesLibrary() {\n return mUsesLibrary;\n }\n\n public SdkInfo getSdkInfo() {\n return mSdkInfo;\n }\n\n public VersionInfo getVersionInfo() {\n return mVersionInfo;\n }\n\n public ResourcesInfo getResourcesInfo() {\n return mResourcesInfo;\n }\n\n public Map getFeatureFlags() {\n return mFeatureFlags;\n }\n\n public List getDoNotCompress() {\n return mDoNotCompress;\n }\n\n public ExtFile getApkFile() {\n return mApkFile;\n }\n\n public void setApkFile(ExtFile apkFile) {\n mApkFile = apkFile;\n if (mApkFileName == null) {\n mApkFileName = apkFile.getName();\n }\n }\n\n public boolean hasSources() throws AndrolibException {\n if (mApkFile == null) {\n return false;\n }\n try {\n return mApkFile.getDirectory().containsFile(\"classes.dex\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n public boolean hasManifest() throws AndrolibException {\n if (mApkFile == null) {\n return false;\n }\n try {\n return mApkFile.getDirectory().containsFile(\"AndroidManifest.xml\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n public boolean hasResources() throws AndrolibException {\n if (mApkFile == null) {\n return false;\n }\n try {\n return mApkFile.getDirectory().containsFile(\"resources.arsc\");\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/meta/ResourcesInfo.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.yaml.*;\n\npublic class ResourcesInfo implements YamlSerializable {\n private Integer mPackageId;\n private String mPackageName;\n private Boolean mSparseEntries;\n private Boolean mCompactEntries;\n private Boolean mKeepRawValues;\n\n public ResourcesInfo() {\n clear();\n }\n\n public void clear() {\n mPackageId = null;\n mPackageName = null;\n mSparseEntries = null;\n mCompactEntries = null;\n mKeepRawValues = null;\n }\n\n public boolean isEmpty() {\n return mPackageId == null\n && mPackageName == null\n && mSparseEntries == null\n && mCompactEntries == null\n && mKeepRawValues == null;\n }\n\n @Override\n public void readItem(YamlReader reader) {\n YamlLine line = reader.getLine();\n switch (line.getKey()) {\n case \"packageId\":\n mPackageId = line.getValueInt();\n break;\n case \"packageName\":\n mPackageName = line.getValue();\n break;\n case \"sparseEntries\":\n mSparseEntries = line.getValueBool();\n break;\n case \"compactEntries\":\n mCompactEntries = line.getValueBool();\n break;\n case \"keepRawValues\":\n mKeepRawValues = line.getValueBool();\n break;\n }\n }\n\n @Override\n public void write(YamlWriter writer) {\n if (mPackageId != null) {\n writer.writeInt(\"packageId\", mPackageId);\n }\n if (mPackageName != null) {\n writer.writeString(\"packageName\", mPackageName);\n }\n if (mSparseEntries != null) {\n writer.writeBool(\"sparseEntries\", mSparseEntries);\n }\n if (mCompactEntries != null) {\n writer.writeBool(\"compactEntries\", mCompactEntries);\n }\n if (mKeepRawValues != null) {\n writer.writeBool(\"keepRawValues\", mKeepRawValues);\n }\n }\n\n public int getPackageId() {\n return mPackageId != null ? mPackageId : -1;\n }\n\n public void setPackageId(int packageId) {\n mPackageId = packageId;\n }\n\n public String getPackageName() {\n return mPackageName;\n }\n\n public void setPackageName(String packageName) {\n mPackageName = packageName;\n }\n\n public boolean isSparseEntries() {\n return mSparseEntries != null ? mSparseEntries : false;\n }\n\n public void setSparseEntries(boolean sparseEntries) {\n mSparseEntries = sparseEntries;\n }\n\n public boolean isCompactEntries() {\n return mCompactEntries != null ? mCompactEntries : false;\n }\n\n public void setCompactEntries(boolean compactEntries) {\n mCompactEntries = compactEntries;\n }\n\n public boolean isKeepRawValues() {\n return mKeepRawValues != null ? mKeepRawValues : false;\n }\n\n public void setKeepRawValues(boolean keepRawValues) {\n mKeepRawValues = keepRawValues;\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/meta/SdkInfo.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.res.table.ResConfig;\nimport brut.yaml.*;\n\npublic class SdkInfo implements YamlSerializable {\n private String mMinSdkVersion;\n private String mTargetSdkVersion;\n private String mMaxSdkVersion;\n\n public SdkInfo() {\n clear();\n }\n\n public void clear() {\n mMinSdkVersion = null;\n mTargetSdkVersion = null;\n mMaxSdkVersion = null;\n }\n\n public boolean isEmpty() {\n return mMinSdkVersion == null\n && mTargetSdkVersion == null\n && mMaxSdkVersion == null;\n }\n\n @Override\n public void readItem(YamlReader reader) {\n YamlLine line = reader.getLine();\n switch (line.getKey()) {\n case \"minSdkVersion\":\n mMinSdkVersion = line.getValue();\n break;\n case \"targetSdkVersion\":\n mTargetSdkVersion = line.getValue();\n break;\n case \"maxSdkVersion\":\n mMaxSdkVersion = line.getValue();\n break;\n }\n }\n\n @Override\n public void write(YamlWriter writer) {\n if (mMinSdkVersion != null) {\n writer.writeString(\"minSdkVersion\", mMinSdkVersion);\n }\n if (mTargetSdkVersion != null) {\n writer.writeString(\"targetSdkVersion\", mTargetSdkVersion);\n }\n if (mMaxSdkVersion != null) {\n writer.writeString(\"maxSdkVersion\", mMaxSdkVersion);\n }\n }\n\n public String getMinSdkVersion() {\n return mMinSdkVersion;\n }\n\n public void setMinSdkVersion(String minSdkVersion) {\n mMinSdkVersion = minSdkVersion;\n }\n\n public String getTargetSdkVersion() {\n return mTargetSdkVersion;\n }\n\n public String getTargetSdkVersionBounded() {\n int target = parseSdkInt(mTargetSdkVersion);\n int min = mMinSdkVersion != null ? parseSdkInt(mMinSdkVersion) : 0;\n int max = mMaxSdkVersion != null ? parseSdkInt(mMaxSdkVersion) : target;\n return Integer.toString(Math.max(min, Math.min(max, target)));\n }\n\n public void setTargetSdkVersion(String targetSdkVersion) {\n mTargetSdkVersion = targetSdkVersion;\n }\n\n public String getMaxSdkVersion() {\n return mMaxSdkVersion;\n }\n\n public void setMaxSdkVersion(String maxSdkVersion) {\n mMaxSdkVersion = maxSdkVersion;\n }\n\n public static int parseSdkInt(String sdkVersion) {\n switch (sdkVersion.toUpperCase()) {\n case \"M\":\n return ResConfig.SDK_MNC;\n case \"N\":\n return ResConfig.SDK_NOUGAT;\n case \"O\":\n return ResConfig.SDK_OREO;\n case \"P\":\n return ResConfig.SDK_P;\n case \"Q\":\n return ResConfig.SDK_Q;\n case \"R\":\n return ResConfig.SDK_R;\n case \"S\":\n return ResConfig.SDK_S;\n case \"SV2\":\n return ResConfig.SDK_S_V2;\n case \"T\":\n case \"TIRAMISU\":\n return ResConfig.SDK_TIRAMISU;\n case \"UPSIDEDOWNCAKE\":\n case \"UPSIDE_DOWN_CAKE\":\n return ResConfig.SDK_UPSIDEDOWN_CAKE;\n case \"VANILLAICECREAM\":\n case \"VANILLA_ICE_CREAM\":\n return ResConfig.SDK_VANILLA_ICE_CREAM;\n case \"BAKLAVA\":\n return ResConfig.SDK_BAKLAVA;\n case \"SDK_CUR_DEVELOPMENT\":\n return ResConfig.SDK_DEVELOPMENT;\n default:\n return Integer.parseInt(sdkVersion);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/meta/UsesFramework.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.yaml.*;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class UsesFramework implements YamlSerializable {\n private final List mIds;\n private String mTag;\n\n public UsesFramework() {\n mIds = new ArrayList<>();\n clear();\n }\n\n public void clear() {\n mIds.clear();\n mTag = null;\n }\n\n public boolean isEmpty() {\n return mIds.isEmpty()\n && mTag == null;\n }\n\n @Override\n public void readItem(YamlReader reader) {\n YamlLine line = reader.getLine();\n switch (line.getKey()) {\n case \"ids\":\n mIds.clear();\n reader.readIntList(mIds);\n break;\n case \"tag\":\n mTag = line.getValue();\n break;\n }\n }\n\n @Override\n public void write(YamlWriter writer) {\n if (!mIds.isEmpty()) {\n writer.writeList(\"ids\", mIds);\n }\n if (mTag != null) {\n writer.writeString(\"tag\", mTag);\n }\n }\n\n public List getIds() {\n return mIds;\n }\n\n public String getTag() {\n return mTag;\n }\n\n public void setTag(String tag) {\n mTag = tag;\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/meta/VersionInfo.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.yaml.*;\n\npublic class VersionInfo implements YamlSerializable {\n private Integer mVersionCode;\n private String mVersionName;\n\n public VersionInfo() {\n clear();\n }\n\n public void clear() {\n mVersionCode = null;\n mVersionName = null;\n }\n\n public boolean isEmpty() {\n return mVersionCode == null\n && mVersionName == null;\n }\n\n @Override\n public void readItem(YamlReader reader) {\n YamlLine line = reader.getLine();\n switch (line.getKey()) {\n case \"versionCode\":\n mVersionCode = line.getValueInt();\n break;\n case \"versionName\":\n mVersionName = line.getValue();\n break;\n }\n }\n\n @Override\n public void write(YamlWriter writer) {\n if (mVersionCode != null) {\n writer.writeInt(\"versionCode\", mVersionCode);\n }\n if (mVersionName != null) {\n writer.writeString(\"versionName\", mVersionName);\n }\n }\n\n public int getVersionCode() {\n return mVersionCode != null ? mVersionCode : -1;\n }\n\n public void setVersionCode(int versionCode) {\n mVersionCode = versionCode;\n }\n\n public String getVersionName() {\n return mVersionName;\n }\n\n public void setVersionName(String versionName) {\n mVersionName = versionName;\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptInvoker.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res;\n\nimport brut.androlib.Config;\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.meta.*;\nimport brut.androlib.res.Framework;\nimport brut.common.BrutException;\nimport brut.common.Log;\nimport brut.util.OS;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Map;\n\npublic class AaptInvoker {\n private static final String TAG = AaptInvoker.class.getName();\n\n private final ApkInfo mApkInfo;\n private final Config mConfig;\n\n public AaptInvoker(ApkInfo apkInfo, Config config) {\n mApkInfo = apkInfo;\n mConfig = config;\n }\n\n public void invoke(File outApk, File manifest, File resDir) throws AndrolibException {\n SdkInfo sdkInfo = mApkInfo.getSdkInfo();\n VersionInfo versionInfo = mApkInfo.getVersionInfo();\n ResourcesInfo resourcesInfo = mApkInfo.getResourcesInfo();\n\n String aaptPath = mConfig.getAaptBinary();\n if (aaptPath == null || aaptPath.isEmpty()) {\n try {\n aaptPath = AaptManager.getBinaryFile().getPath();\n } catch (AndrolibException ex) {\n aaptPath = AaptManager.getBinaryName();\n Log.w(TAG, aaptPath + \": \" + ex.getMessage() + \" (defaulting to $PATH binary)\");\n }\n }\n\n List cmd = new ArrayList<>();\n File resZip = null;\n\n if (resDir != null) {\n resZip = new File(resDir.getParent(), \"build/resources.zip\");\n OS.rmfile(resZip);\n\n // Compile the files into flat arsc files.\n cmd.add(aaptPath);\n cmd.add(\"compile\");\n\n cmd.add(\"--dir\");\n cmd.add(resDir.getPath());\n\n // Treats error that used to be valid in aapt1 as warnings in aapt2.\n cmd.add(\"--legacy\");\n\n cmd.add(\"-o\");\n cmd.add(resZip.getPath());\n\n if (mConfig.isVerbose()) {\n cmd.add(\"-v\");\n }\n\n if (mConfig.isNoCrunch()) {\n cmd.add(\"--no-crunch\");\n }\n\n try {\n OS.exec(cmd.toArray(new String[0]));\n Log.d(TAG, \"aapt2 compile command ran: \" + cmd.toString());\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n\n cmd.clear();\n }\n\n if (manifest == null) {\n return;\n }\n\n // Link resources to the final apk.\n cmd.add(aaptPath);\n cmd.add(\"link\");\n\n cmd.add(\"-o\");\n cmd.add(outApk.getPath());\n\n cmd.add(\"--manifest\");\n cmd.add(manifest.getPath());\n\n if (sdkInfo.getMinSdkVersion() != null) {\n cmd.add(\"--min-sdk-version\");\n cmd.add(sdkInfo.getMinSdkVersion());\n }\n if (sdkInfo.getTargetSdkVersion() != null) {\n cmd.add(\"--target-sdk-version\");\n cmd.add(sdkInfo.getTargetSdkVersion());\n }\n if (versionInfo.getVersionCode() >= 0) {\n cmd.add(\"--version-code\");\n cmd.add(Integer.toString(versionInfo.getVersionCode()));\n }\n if (versionInfo.getVersionName() != null) {\n cmd.add(\"--version-name\");\n cmd.add(versionInfo.getVersionName());\n }\n if (resourcesInfo.getPackageId() >= 0) {\n int pkgId = resourcesInfo.getPackageId();\n if (pkgId == 0) {\n cmd.add(\"--shared-lib\");\n } else if (pkgId > 1) {\n cmd.add(\"--package-id\");\n cmd.add(Integer.toString(pkgId));\n if (pkgId < 0x7F) {\n cmd.add(\"--allow-reserved-package-id\");\n }\n }\n }\n if (resourcesInfo.getPackageName() != null) {\n cmd.add(\"--rename-resources-package\");\n cmd.add(resourcesInfo.getPackageName());\n }\n if (resourcesInfo.isSparseEntries()) {\n cmd.add(\"--enable-sparse-encoding\");\n }\n if (resourcesInfo.isCompactEntries()) {\n cmd.add(\"--enable-compact-entries\");\n }\n if (resourcesInfo.isKeepRawValues()) {\n cmd.add(\"--keep-raw-values\");\n }\n if (!mApkInfo.getFeatureFlags().isEmpty()) {\n List featureFlags = new ArrayList<>();\n for (Map.Entry entry : mApkInfo.getFeatureFlags().entrySet()) {\n featureFlags.add(entry.getKey() + \"=\" + entry.getValue());\n }\n cmd.add(\"--feature-flags\");\n cmd.add(String.join(\",\", featureFlags));\n }\n\n // Disable automatic changes.\n cmd.add(\"--no-auto-version\");\n cmd.add(\"--no-version-vectors\");\n cmd.add(\"--no-version-transitions\");\n cmd.add(\"--no-resource-deduping\");\n cmd.add(\"--no-compile-sdk-metadata\");\n\n // #3427 - Ignore stricter parsing during aapt2.\n cmd.add(\"--warn-manifest-validation\");\n\n for (File includeFile : getIncludeFiles()) {\n cmd.add(\"-I\");\n cmd.add(includeFile.getPath());\n }\n if (mConfig.isVerbose()) {\n cmd.add(\"-v\");\n }\n if (resZip != null) {\n cmd.add(resZip.getPath());\n }\n\n try {\n OS.exec(cmd.toArray(new String[0]));\n Log.d(TAG, \"aapt2 link command ran: \" + cmd.toString());\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private List getIncludeFiles() throws AndrolibException {\n List files = new ArrayList<>();\n\n UsesFramework usesFramework = mApkInfo.getUsesFramework();\n List frameworkIds = usesFramework.getIds();\n if (!frameworkIds.isEmpty()) {\n Framework framework = new Framework(mConfig);\n String tag = usesFramework.getTag();\n for (Integer id : frameworkIds) {\n files.add(framework.getApkFile(id, tag));\n }\n }\n\n List usesLibrary = mApkInfo.getUsesLibrary();\n if (!usesLibrary.isEmpty()) {\n String[] libFiles = mConfig.getLibraryFiles();\n for (String name : usesLibrary) {\n File libFile = null;\n if (libFiles != null) {\n for (String libEntry : libFiles) {\n String[] parts = libEntry.split(\":\", 2);\n if (parts.length == 2 && name.equals(parts[0])) {\n libFile = new File(parts[1]);\n break;\n }\n }\n }\n if (libFile != null) {\n files.add(libFile);\n } else {\n Log.w(TAG, \"Shared library was not provided: \" + name);\n }\n }\n }\n\n return files;\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.common.BrutException;\nimport brut.util.Jar;\nimport brut.util.OS;\nimport brut.util.OSDetection;\n\nimport java.io.File;\n\npublic final class AaptManager {\n\n private AaptManager() {\n // Private constructor for utility class.\n }\n\n public static String getBinaryName() {\n return \"aapt2\";\n }\n\n public static File getBinaryFile() throws AndrolibException {\n String binName = getBinaryName();\n\n if (!OSDetection.is64Bit()) {\n throw new AndrolibException(binName + \" binaries are not available for 32-bit platforms.\");\n }\n\n StringBuilder binPath = new StringBuilder(\"/prebuilt/\");\n if (OSDetection.isUnix()) {\n binPath.append(\"linux\"); // ELF 64-bit LSB executable, x86-64\n } else if (OSDetection.isMacOSX()) {\n binPath.append(\"macosx\"); // fat binary x86_64 + arm64\n } else if (OSDetection.isWindows()) {\n binPath.append(\"windows\"); // x86_64\n } else {\n throw new AndrolibException(\"Could not identify platform: \" + OSDetection.returnOS());\n }\n binPath.append('/');\n binPath.append(binName);\n if (OSDetection.isWindows()) {\n binPath.append(\".exe\");\n }\n\n File binFile;\n try {\n binFile = Jar.getResourceAsFile(AaptManager.class, binPath.toString(), binName + \"_\");\n } catch (BrutException ex) {\n throw new AndrolibException(ex);\n }\n setBinaryExecutable(binFile);\n return binFile;\n }\n\n private static void setBinaryExecutable(File binFile) throws AndrolibException {\n if (!binFile.isFile() || !binFile.canRead()) {\n throw new AndrolibException(\"Could not read aapt binary: \" + binFile.getPath());\n }\n if (!binFile.setExecutable(true)) {\n throw new AndrolibException(\"Could not set aapt binary as executable: \" + binFile.getPath());\n }\n }\n\n public static int getBinaryVersion(File binFile) throws AndrolibException {\n setBinaryExecutable(binFile);\n\n String versionStr = OS.execAndReturn(new String[] { binFile.getPath(), \"version\" });\n if (versionStr == null) {\n throw new AndrolibException(\"Could not execute aapt binary at location: \" + binFile.getPath());\n }\n\n return getVersionFromString(versionStr);\n }\n\n public static int getVersionFromString(String versionStr) throws AndrolibException {\n if (versionStr.startsWith(\"Android Asset Packaging Tool (aapt) 2:\")) {\n return 2;\n }\n if (versionStr.startsWith(\"Android Asset Packaging Tool (aapt) 2.\")) {\n return 2; // Prior to Android SDK 26.0.2\n }\n if (versionStr.startsWith(\"Android Asset Packaging Tool, v0.\")) {\n return 1;\n }\n throw new AndrolibException(\"Could not identify aapt binary version: \" + versionStr);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/Framework.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res;\n\nimport brut.androlib.Config;\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.FrameworkNotFoundException;\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.res.decoder.BinaryResourceParser;\nimport brut.androlib.res.table.ResTable;\nimport brut.common.Log;\nimport brut.util.BrutIO;\nimport brut.util.OS;\nimport brut.util.OSDetection;\nimport org.apache.commons.lang3.tuple.Pair;\n\nimport java.io.*;\nimport java.nio.ByteBuffer;\nimport java.nio.ByteOrder;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.util.*;\nimport java.util.zip.CRC32;\nimport java.util.zip.ZipEntry;\nimport java.util.zip.ZipFile;\nimport java.util.zip.ZipOutputStream;\n\npublic class Framework {\n private static final String TAG = Framework.class.getName();\n\n private static final File DEFAULT_DIRECTORY;\n static {\n String userHome = System.getProperty(\"user.home\");\n Path defDir;\n if (OSDetection.isMacOSX()) {\n defDir = Paths.get(userHome, \"Library\", \"apktool\", \"framework\");\n } else if (OSDetection.isWindows()) {\n defDir = Paths.get(userHome, \"AppData\", \"Local\", \"apktool\", \"framework\");\n } else {\n String xdgDataHome = System.getenv(\"XDG_DATA_HOME\");\n if (xdgDataHome != null) {\n defDir = Paths.get(xdgDataHome, \"apktool\", \"framework\");\n } else {\n defDir = Paths.get(userHome, \".local\", \"share\", \"apktool\", \"framework\");\n }\n }\n DEFAULT_DIRECTORY = defDir.toFile();\n }\n\n private final Config mConfig;\n private File mDirectory;\n\n public Framework(Config config) {\n mConfig = config;\n }\n\n public void install(File apkFile) throws AndrolibException {\n try (ZipFile zip = new ZipFile(apkFile)) {\n ZipEntry entry = zip.getEntry(\"resources.arsc\");\n if (entry == null) {\n throw new AndrolibException(\"Could not find resources.arsc in file: \" + apkFile);\n }\n\n byte[] data = BrutIO.readAndClose(zip.getInputStream(entry));\n ResTable table = parseAndPublicizeResources(data);\n int pkgId = table.listPackageGroups().iterator().next().getId();\n File outFile = new File(getDirectory(), pkgId + getApkSuffix());\n\n try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(outFile.toPath()))) {\n out.setMethod(ZipOutputStream.STORED);\n CRC32 crc = new CRC32();\n crc.update(data);\n entry = new ZipEntry(\"resources.arsc\");\n entry.setSize(data.length);\n entry.setMethod(ZipEntry.STORED);\n entry.setCrc(crc.getValue());\n out.putNextEntry(entry);\n out.write(data);\n out.closeEntry();\n\n // Write fake AndroidManifest.xml file to support original aapt.\n entry = zip.getEntry(\"AndroidManifest.xml\");\n if (entry != null) {\n byte[] manifest = BrutIO.readAndClose(zip.getInputStream(entry));\n CRC32 manifestCrc = new CRC32();\n manifestCrc.update(manifest);\n entry.setSize(manifest.length);\n entry.setCompressedSize(-1);\n entry.setCrc(manifestCrc.getValue());\n out.putNextEntry(entry);\n out.write(manifest);\n out.closeEntry();\n }\n }\n\n Log.i(TAG, \"Framework installed to: \" + outFile);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n }\n\n private ResTable parseAndPublicizeResources(byte[] data) throws AndrolibException {\n ResTable table = new ResTable(new ApkInfo(), mConfig);\n BinaryResourceParser parser = new BinaryResourceParser(table, true, true);\n parser.enableCollectFlagsOffsets();\n parser.parse(new ByteArrayInputStream(data));\n\n if (table.getPackageGroupCount() == 0) {\n throw new AndrolibException(\"No packages in resources.arsc in file.\");\n }\n\n // Publicize all entry specs.\n ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);\n for (Pair pair : parser.getEntrySpecFlagsOffsets()) {\n int position = pair.getKey().intValue();\n int count = pair.getValue();\n for (int i = 0; i < count; i++, position += 4) {\n int flags = buffer.getInt(position);\n buffer.putInt(position, flags | 0x40000000); // ResTable_typeSpec::SPEC_PUBLIC\n }\n }\n\n return table;\n }\n\n public File getDirectory() throws AndrolibException {\n if (mDirectory == null) {\n String path = mConfig.getFrameworkDirectory();\n File dir = (path != null && !path.isEmpty()) ? new File(path) : DEFAULT_DIRECTORY;\n\n if (dir.exists() && !dir.isDirectory()) {\n throw new AndrolibException(\"Framework path is not a directory: \" + dir);\n }\n\n File parent = dir.getParentFile();\n if (parent != null && parent.exists() && !parent.isDirectory()) {\n throw new AndrolibException(\"Framework path's parent is not a directory: \" + parent);\n }\n\n if (!dir.exists() && !dir.mkdirs()) {\n throw new AndrolibException(\"Could not create framework directory: \" + dir);\n }\n\n mDirectory = dir;\n }\n\n return mDirectory;\n }\n\n public File getApkFile(int id) throws AndrolibException {\n return getApkFile(id, mConfig.getFrameworkTag());\n }\n\n public File getApkFile(int id, String tag) throws AndrolibException {\n File dir = getDirectory();\n File apkFile = new File(dir, id + getApkSuffix(tag));\n if (apkFile.exists()) {\n return apkFile;\n }\n\n // Fall back to the untagged framework.\n apkFile = new File(dir, id + getApkSuffix(null));\n if (apkFile.exists()) {\n return apkFile;\n }\n\n // If the default framework is requested but is missing, extract the built-in one.\n if (id == 1) {\n try {\n BrutIO.copyAndClose(getAndroidFrameworkAsStream(), Files.newOutputStream(apkFile.toPath()));\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n return apkFile;\n }\n\n throw new FrameworkNotFoundException(id);\n }\n\n private String getApkSuffix() {\n return getApkSuffix(mConfig.getFrameworkTag());\n }\n\n private static String getApkSuffix(String tag) {\n return ((tag != null && !tag.isEmpty()) ? \"-\" + tag : \"\") + \".apk\";\n }\n\n private InputStream getAndroidFrameworkAsStream() {\n return getClass().getResourceAsStream(\"/prebuilt/android-framework.jar\");\n }\n\n public void cleanDirectory() throws AndrolibException {\n for (File apkFile : listDirectory()) {\n Log.i(TAG, \"Removing framework file: \" + apkFile.getName());\n OS.rmfile(apkFile);\n }\n }\n\n public List listDirectory() throws AndrolibException {\n boolean ignoreTag = mConfig.isForced();\n String suffix = ignoreTag ? getApkSuffix(null) : getApkSuffix();\n List apkFiles = new ArrayList<>();\n\n for (File file : getDirectory().listFiles()) {\n if (file.isFile() && isValidApkName(file.getName(), suffix, ignoreTag)) {\n apkFiles.add(file);\n }\n }\n\n return apkFiles;\n }\n\n private static boolean isValidApkName(String fileName, String suffix, boolean ignoreTag) {\n if (!fileName.endsWith(suffix)) {\n return false;\n }\n if (ignoreTag) {\n return true;\n }\n\n int len = fileName.length() - suffix.length();\n if (len == 0) {\n return false;\n }\n for (int i = 0; i < len; i++) {\n char ch = fileName.charAt(i);\n if (ch < '0' || ch > '9') {\n return false;\n }\n }\n return true;\n }\n\n public void publicizeResources(File arscFile) throws AndrolibException {\n try {\n byte[] data = Files.readAllBytes(arscFile.toPath());\n parseAndPublicizeResources(data);\n Files.write(arscFile.toPath(), data);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/ResDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res;\n\nimport brut.androlib.Config;\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.meta.ResourcesInfo;\nimport brut.androlib.meta.SdkInfo;\nimport brut.androlib.meta.UsesFramework;\nimport brut.androlib.meta.VersionInfo;\nimport brut.androlib.res.decoder.*;\nimport brut.androlib.res.table.*;\nimport brut.androlib.res.table.value.ResBag;\nimport brut.androlib.res.table.value.ResFileReference;\nimport brut.androlib.res.xml.ResXmlUtils;\nimport brut.androlib.res.xml.ResXmlSerializer;\nimport brut.androlib.res.xml.ValuesXmlSerializable;\nimport brut.common.Log;\nimport brut.directory.Directory;\nimport brut.directory.DirectoryException;\nimport brut.directory.FileDirectory;\nimport com.google.common.collect.Lists;\nimport org.apache.commons.lang3.tuple.Pair;\n\nimport java.io.*;\nimport java.util.*;\n\npublic class ResDecoder {\n private static final String TAG = ResDecoder.class.getName();\n\n private final ApkInfo mApkInfo;\n private final Config mConfig;\n private final ResTable mTable;\n private final Map mResFileMap;\n\n public ResDecoder(ApkInfo apkInfo, Config config) {\n mApkInfo = apkInfo;\n mConfig = config;\n mTable = new ResTable(apkInfo, config);\n mResFileMap = new HashMap<>();\n }\n\n public ResTable getTable() {\n return mTable;\n }\n\n public Map getResFileMap() {\n return mResFileMap;\n }\n\n public void decodeResources(File apkDir) throws AndrolibException {\n if (!mApkInfo.hasResources()) {\n return;\n }\n\n mTable.load();\n\n Map decoders = new HashMap<>();\n decoders.put(ResFileDecoder.Type.UNKNOWN, new ResRawStreamDecoder());\n decoders.put(ResFileDecoder.Type.PNG_9PATCH, new ResNinePatchStreamDecoder());\n\n BinaryXmlResourceParser parser = new BinaryXmlResourceParser(\n mTable, mConfig.isIgnoreRawValues(), mConfig.isDecodeResolveLazy());\n ResXmlSerializer serial = new ResXmlSerializer(true);\n decoders.put(ResFileDecoder.Type.BINARY_XML, new ResXmlPullStreamDecoder(parser, serial));\n\n ResFileDecoder fileDecoder = new ResFileDecoder(decoders);\n Directory inDir, outDir;\n\n try {\n inDir = mApkInfo.getApkFile().getDirectory();\n outDir = new FileDirectory(apkDir);\n } catch (DirectoryException ex) {\n throw new AndrolibException(ex);\n }\n\n ResPackage pkg = mTable.getMainPackage();\n\n Log.i(TAG, \"Decoding value resources...\");\n for (ResEntry entry : Lists.newArrayList(pkg.getGroup().listEntries())) {\n if (entry.getValue() instanceof ResBag) {\n ((ResBag) entry.getValue()).resolveKeys();\n }\n }\n\n Log.i(TAG, \"Decoding file resources...\");\n for (ResEntry entry : Lists.newArrayList(pkg.getGroup().listEntries())) {\n if (entry.getValue() instanceof ResFileReference) {\n fileDecoder.decode(entry, inDir, outDir, mResFileMap);\n }\n }\n\n // Disable auto-escaping in generated XMLs.\n serial = new ResXmlSerializer(false);\n\n Log.i(TAG, \"Generating values XMLs...\");\n generateValuesXmls(pkg, outDir, serial);\n generatePublicXml(pkg, outDir, serial);\n generateStagingXmls(pkg, outDir, serial);\n generateOverlayableXml(pkg, outDir, serial);\n\n AndrolibException ex = parser.getFirstError();\n if (ex != null) {\n throw ex;\n }\n }\n\n private void generateValuesXmls(ResPackage pkg, Directory outDir, ResXmlSerializer serial)\n throws AndrolibException {\n // Group entries by type name + qualifiers, ignoring alias duplicates in sub-packages.\n Map, List> entriesMap = new HashMap<>();\n for (ResEntry entry : pkg.getGroup().listEntries()) {\n if (entry.getValue() instanceof ValuesXmlSerializable && !pkg.isAlias(entry.getResId())) {\n ResType type = entry.getType();\n Pair key = Pair.of(type.getName(), type.getConfig().toQualifiers());\n entriesMap.computeIfAbsent(key, t -> new ArrayList<>()).add(entry);\n }\n }\n\n // Generate a values XML per type name + qualifiers.\n for (Map.Entry, List> mapEntry : entriesMap.entrySet()) {\n Pair key = mapEntry.getKey();\n String typeName = key.getLeft();\n String qualifiers = key.getRight();\n\n List entries = mapEntry.getValue();\n entries.sort(Comparator.comparing(ResEntry::getResId));\n\n String outFileName = \"res/values\" + qualifiers + \"/\"\n + (typeName.endsWith(\"s\") ? typeName : typeName + \"s\") + \".xml\";\n try (OutputStream out = outDir.getFileOutput(outFileName)) {\n serial.setOutput(out, null);\n serial.startDocument(null, null);\n serial.startTag(null, \"resources\");\n\n for (ResEntry entry : entries) {\n // We already verified the value, cast directly.\n ((ValuesXmlSerializable) entry.getValue()).serializeToValuesXml(serial, entry);\n }\n\n serial.endTag(null, \"resources\");\n serial.endDocument();\n serial.flush();\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(\"Could not generate: \" + outFileName, ex);\n }\n }\n }\n\n private void generatePublicXml(ResPackage pkg, Directory outDir, ResXmlSerializer serial)\n throws AndrolibException {\n List specs = Lists.newArrayList(pkg.listEntrySpecs());\n specs.sort(Comparator.comparing(ResEntrySpec::getResId));\n\n String outFileName = \"res/values/public.xml\";\n try (OutputStream out = outDir.getFileOutput(outFileName)) {\n serial.setOutput(out, null);\n serial.startDocument(null, null);\n serial.startTag(null, \"resources\");\n\n for (ResEntrySpec spec : specs) {\n serial.startTag(null, \"public\");\n serial.attribute(null, \"type\", spec.getTypeSpec().getName());\n serial.attribute(null, \"name\", spec.getName());\n serial.attribute(null, \"id\", spec.getResId().toString());\n serial.endTag(null, \"public\");\n }\n\n serial.endTag(null, \"resources\");\n serial.endDocument();\n serial.flush();\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(\"Could not generate: \" + outFileName, ex);\n }\n }\n\n private void generateStagingXmls(ResPackage pkg, Directory outDir, ResXmlSerializer serial)\n throws AndrolibException {\n if (pkg.getGroup().getPackageCount() <= 1) {\n return;\n }\n\n // Collect and sort all entry specs defined in sub-packages.\n List subPkgs = Lists.newArrayList(pkg.getGroup().listSubPackages());\n List subSpecs = new ArrayList<>();\n for (ResPackage subPkg : subPkgs) {\n subSpecs.addAll(subPkg.listEntrySpecs());\n }\n subSpecs.sort(Comparator.comparing(ResEntrySpec::getResId));\n\n // Separate the entry specs into groups by type.\n Map> stagingGroups = new LinkedHashMap<>();\n Map> finalGroups = new LinkedHashMap<>();\n Map> prevMap = null;\n List currList = null;\n ResId prevId = null;\n for (ResEntrySpec spec : subSpecs) {\n ResId currId = spec.getResId();\n Map> currMap = pkg.isAlias(currId) ? finalGroups : stagingGroups;\n\n if (prevId == null || currId.typeId() != prevId.typeId() || currMap != prevMap) {\n currList = new ArrayList<>();\n currMap.put(spec.getTypeSpec(), currList);\n prevMap = currMap;\n }\n\n currList.add(spec);\n prevId = currId;\n }\n\n // Generate values XML for the staging groups.\n if (!stagingGroups.isEmpty()) {\n String outFileName = \"res/values/public-staging.xml\";\n try (OutputStream out = outDir.getFileOutput(outFileName)) {\n serial.setOutput(out, null);\n serial.startDocument(null, null);\n serial.startTag(null, \"resources\");\n\n for (Map.Entry> mapEntry : stagingGroups.entrySet()) {\n ResTypeSpec typeSpec = mapEntry.getKey();\n ResId firstId = ResId.of(typeSpec.getPackage().getId(), typeSpec.getId(), 0);\n\n serial.startTag(null, \"staging-public-group\");\n serial.attribute(null, \"type\", mapEntry.getKey().getName());\n serial.attribute(null, \"first-id\", firstId.toString());\n\n int lastEntryId = 0;\n for (ResEntrySpec spec : mapEntry.getValue()) {\n int entryId = spec.getId();\n while (lastEntryId++ < entryId) {\n serial.startTag(null, \"public\");\n serial.attribute(null, \"name\", \"removed_\");\n serial.endTag(null, \"public\");\n }\n\n serial.startTag(null, \"public\");\n serial.attribute(null, \"name\", spec.getName());\n serial.endTag(null, \"public\");\n }\n\n serial.endTag(null, \"staging-public-group\");\n }\n\n serial.endTag(null, \"resources\");\n serial.endDocument();\n serial.flush();\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(\"Could not generate: \" + outFileName, ex);\n }\n }\n\n // Generate values XML for the finalized groups.\n if (!finalGroups.isEmpty()) {\n String outFileName = \"res/values/public-final.xml\";\n try (OutputStream out = outDir.getFileOutput(outFileName)) {\n serial.setOutput(out, null);\n serial.startDocument(null, null);\n serial.startTag(null, \"resources\");\n\n for (Map.Entry> mapEntry : finalGroups.entrySet()) {\n ResTypeSpec typeSpec = mapEntry.getKey();\n ResId firstId = ResId.of(typeSpec.getPackage().getId(), typeSpec.getId(), 0);\n\n serial.startTag(null, \"staging-public-group-final\");\n serial.attribute(null, \"type\", mapEntry.getKey().getName());\n serial.attribute(null, \"first-id\", firstId.toString());\n\n int lastEntryId = 0;\n for (ResEntrySpec spec : mapEntry.getValue()) {\n int entryId = spec.getId();\n while (lastEntryId++ < entryId) {\n serial.startTag(null, \"public\");\n serial.attribute(null, \"name\", \"removed_\");\n serial.endTag(null, \"public\");\n }\n\n serial.startTag(null, \"public\");\n serial.attribute(null, \"name\", spec.getName());\n serial.endTag(null, \"public\");\n }\n\n serial.endTag(null, \"staging-public-group-final\");\n }\n\n serial.endTag(null, \"resources\");\n serial.endDocument();\n serial.flush();\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(\"Could not generate: \" + outFileName, ex);\n }\n }\n }\n\n private void generateOverlayableXml(ResPackage pkg, Directory outDir, ResXmlSerializer serial)\n throws AndrolibException {\n if (pkg.getOverlayableCount() == 0) {\n return;\n }\n\n List overlayables = Lists.newArrayList(pkg.listOverlayables());\n overlayables.sort(Comparator.comparing(ResOverlayable::getName));\n\n String outFileName = \"res/values/overlayable.xml\";\n try (OutputStream out = outDir.getFileOutput(outFileName)) {\n serial.setOutput(out, null);\n serial.startDocument(null, null);\n serial.startTag(null, \"resources\");\n\n for (ResOverlayable overlayable : overlayables) {\n overlayable.serializeToXml(serial);\n }\n\n serial.endTag(null, \"resources\");\n serial.endDocument();\n serial.flush();\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(\"Could not generate: \" + outFileName, ex);\n }\n }\n\n public void decodeManifest(File apkDir) throws AndrolibException {\n if (!mApkInfo.hasManifest()) {\n return;\n }\n\n BinaryXmlResourceParser parser = new BinaryXmlResourceParser(\n mTable, mConfig.isIgnoreRawValues(), mConfig.isDecodeResolveLazy());\n ResXmlSerializer serial = new ResXmlSerializer(true);\n ManifestPullEventHandler handler = new ManifestPullEventHandler(mApkInfo, !mConfig.isAnalysisMode());\n ResXmlPullStreamDecoder decoder = new ResXmlPullStreamDecoder(parser, serial, handler);\n\n ResPackage pkg = mTable.getMainPackage();\n\n Directory inDir, outDir;\n try {\n inDir = mApkInfo.getApkFile().getDirectory();\n outDir = new FileDirectory(apkDir);\n\n Log.i(TAG, \"Decoding AndroidManifest.xml with \" + (pkg != null ? \"resources\" : \"only framework resources\")\n + \"...\");\n\n try (\n InputStream in = inDir.getFileInput(\"AndroidManifest.xml\");\n OutputStream out = outDir.getFileOutput(\"AndroidManifest.xml\")\n ) {\n decoder.decode(in, out);\n }\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(ex);\n }\n\n // Update apk info.\n ResourcesInfo resourcesInfo = mApkInfo.getResourcesInfo();\n\n // Flag the app if it preserved raw attribute values.\n if (parser.hasRawValues() && !mConfig.isIgnoreRawValues()) {\n resourcesInfo.setKeepRawValues(true);\n }\n\n if (pkg != null) {\n resourcesInfo.setPackageId(pkg.getId());\n\n // We temporarily filled packageName in ResourcesInfo with the package from AndroidManifest.xml.\n // Check if actual resources package differs from the manifest package and update packageName,\n // otherwise clear packageName.\n String manifestPackage = resourcesInfo.getPackageName();\n String resourcesPackage = pkg.getName();\n if (resourcesPackage != null && !resourcesPackage.equals(manifestPackage)) {\n resourcesInfo.setPackageName(resourcesPackage);\n } else {\n // Renaming not needed: resources package is null or identical.\n resourcesInfo.setPackageName(null);\n }\n\n // Resolve sdkInfo from resources.\n SdkInfo sdkInfo = mApkInfo.getSdkInfo();\n if (!sdkInfo.isEmpty()) {\n String minSdkVersion = sdkInfo.getMinSdkVersion();\n if (minSdkVersion != null) {\n String refValue = ResXmlUtils.pullValueFromIntegers(apkDir, minSdkVersion);\n if (refValue != null) {\n sdkInfo.setMinSdkVersion(refValue);\n }\n }\n String targetSdkVersion = sdkInfo.getTargetSdkVersion();\n if (targetSdkVersion != null) {\n String refValue = ResXmlUtils.pullValueFromIntegers(apkDir, targetSdkVersion);\n if (refValue != null) {\n sdkInfo.setTargetSdkVersion(refValue);\n }\n }\n String maxSdkVersion = sdkInfo.getMaxSdkVersion();\n if (maxSdkVersion != null) {\n String refValue = ResXmlUtils.pullValueFromIntegers(apkDir, maxSdkVersion);\n if (refValue != null) {\n sdkInfo.setMaxSdkVersion(refValue);\n }\n }\n }\n\n // Resolve versionInfo from resources.\n VersionInfo versionInfo = mApkInfo.getVersionInfo();\n if (!versionInfo.isEmpty()) {\n String versionName = versionInfo.getVersionName();\n if (versionName != null) {\n String refValue = ResXmlUtils.pullValueFromStrings(apkDir, versionName);\n if (refValue != null) {\n versionInfo.setVersionName(refValue);\n }\n }\n }\n\n // Record framework package IDs used by the resource table.\n List framePackageIds = Lists.newArrayList(mTable.getFramePackageIds());\n if (!framePackageIds.isEmpty()) {\n UsesFramework usesFramework = mApkInfo.getUsesFramework();\n List frameworkIds = usesFramework.getIds();\n framePackageIds.sort(null);\n for (int id : framePackageIds) {\n frameworkIds.add(id);\n }\n usesFramework.setTag(mConfig.getFrameworkTag());\n }\n\n // Record library package names used by the resource table.\n List libPackageIds = Lists.newArrayList(mTable.getLibPackageIds());\n if (!libPackageIds.isEmpty()) {\n List usesLibrary = mApkInfo.getUsesLibrary();\n libPackageIds.sort(null);\n for (int id : libPackageIds) {\n usesLibrary.add(mTable.getDynamicRefPackageName(id));\n }\n }\n } else {\n // Renaming not possible: manifest decoded without resources.\n resourcesInfo.setPackageName(null);\n }\n\n File manifest = new File(apkDir, \"AndroidManifest.xml\");\n\n if (!mConfig.isAnalysisMode()) {\n // Remove versionCode and versionName, it will be passed to aapt as a parameter via apktool.yml.\n ResXmlUtils.removeManifestVersions(manifest);\n }\n\n // Record feature flags.\n String[] flags = ResXmlUtils.pullManifestFeatureFlags(manifest);\n if (flags != null) {\n Map featureFlags = mApkInfo.getFeatureFlags();\n for (String flag : flags) {\n boolean value;\n if (flag.startsWith(\"!\")) {\n flag = flag.substring(1);\n value = false;\n } else {\n value = true;\n }\n featureFlags.put(flag, value);\n }\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/LayoutBounds.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.data;\n\nimport brut.util.BinaryDataInputStream;\n\nimport java.io.IOException;\n\npublic final class LayoutBounds {\n public static final int MAGIC = 0x6E704C62; // npLb\n public static final int COLOR_TICK = 0xFFFF0000; // solid red\n\n public final int left, top, right, bottom;\n\n public LayoutBounds(int left, int top, int right, int bottom) {\n this.left = left;\n this.top = top;\n this.right = right;\n this.bottom = bottom;\n }\n\n public static LayoutBounds read(BinaryDataInputStream in) throws IOException {\n int left = Integer.reverseBytes(in.readInt());\n int top = Integer.reverseBytes(in.readInt());\n int right = Integer.reverseBytes(in.readInt());\n int bottom = Integer.reverseBytes(in.readInt());\n\n return new LayoutBounds(left, top, right, bottom);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/NinePatchData.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.data;\n\nimport brut.util.BinaryDataInputStream;\n\nimport java.io.IOException;\n\npublic final class NinePatchData {\n public static final int MAGIC = 0x6E705463; // npTc\n public static final int COLOR_TICK = 0xFF000000; // solid black\n\n public final int[] xDivs, yDivs;\n public final int paddingLeft, paddingRight, paddingTop, paddingBottom;\n\n public NinePatchData(int[] xDivs, int[] yDivs, int paddingLeft, int paddingRight, int paddingTop,\n int paddingBottom) {\n this.xDivs = xDivs;\n this.yDivs = yDivs;\n this.paddingLeft = paddingLeft;\n this.paddingRight = paddingRight;\n this.paddingTop = paddingTop;\n this.paddingBottom = paddingBottom;\n }\n\n public static NinePatchData read(BinaryDataInputStream in) throws IOException {\n in.skipByte(); // wasDeserialized\n int numXDivs = in.readUnsignedByte();\n int numYDivs = in.readUnsignedByte();\n in.skipByte(); // numColors\n in.skipInt(); // xDivsOffset\n in.skipInt(); // yDivsOffset\n int paddingLeft = in.readInt();\n int paddingRight = in.readInt();\n int paddingTop = in.readInt();\n int paddingBottom = in.readInt();\n in.skipInt(); // colorsOffset\n int[] xDivs = in.readIntArray(numXDivs);\n int[] yDivs = in.readIntArray(numYDivs);\n\n return new NinePatchData(xDivs, yDivs, paddingLeft, paddingRight, paddingTop, paddingBottom);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResChunkHeader.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.data;\n\nimport brut.util.BinaryDataInputStream;\n\nimport java.io.IOException;\n\npublic final class ResChunkHeader {\n public static final int SIZE = 8;\n\n public static final int RES_NULL_TYPE = 0x0000;\n public static final int RES_STRING_POOL_TYPE = 0x0001;\n public static final int RES_TABLE_TYPE = 0x0002;\n public static final int RES_XML_TYPE = 0x0003;\n\n // Chunk types in RES_XML_TYPE\n public static final int RES_XML_FIRST_CHUNK_TYPE = 0x0100;\n public static final int RES_XML_START_NAMESPACE_TYPE = 0x0100;\n public static final int RES_XML_END_NAMESPACE_TYPE = 0x0101;\n public static final int RES_XML_START_ELEMENT_TYPE = 0x0102;\n public static final int RES_XML_END_ELEMENT_TYPE = 0x0103;\n public static final int RES_XML_CDATA_TYPE = 0x0104;\n public static final int RES_XML_LAST_CHUNK_TYPE = 0x017F;\n public static final int RES_XML_RESOURCE_MAP_TYPE = 0x0180;\n\n // Chunk types in RES_TABLE_TYPE\n public static final int RES_TABLE_PACKAGE_TYPE = 0x0200;\n public static final int RES_TABLE_TYPE_TYPE = 0x0201;\n public static final int RES_TABLE_TYPE_SPEC_TYPE = 0x0202;\n public static final int RES_TABLE_LIBRARY_TYPE = 0x0203;\n public static final int RES_TABLE_OVERLAYABLE_TYPE = 0x0204;\n public static final int RES_TABLE_OVERLAYABLE_POLICY_TYPE = 0x0205;\n public static final int RES_TABLE_STAGED_ALIAS_TYPE = 0x0206;\n\n public final int type;\n public final int headerSize;\n public final int size;\n\n public ResChunkHeader(int type, int headerSize, int size) {\n this.type = type;\n this.headerSize = headerSize;\n this.size = size;\n }\n\n public static ResChunkHeader read(BinaryDataInputStream in) throws IOException {\n // ResChunk_header\n int type = in.readUnsignedShort();\n int headerSize = in.readUnsignedShort();\n int size = in.readInt();\n\n return new ResChunkHeader(type, headerSize, size);\n }\n\n public static String nameOf(int type) {\n switch (type) {\n case RES_NULL_TYPE:\n return \"RES_NULL_TYPE\";\n case RES_STRING_POOL_TYPE:\n return \"RES_STRING_POOL_TYPE\";\n case RES_TABLE_TYPE:\n return \"RES_TABLE_TYPE\";\n case RES_XML_TYPE:\n return \"RES_XML_TYPE\";\n case RES_XML_START_NAMESPACE_TYPE:\n return \"RES_XML_START_NAMESPACE_TYPE\";\n case RES_XML_END_NAMESPACE_TYPE:\n return \"RES_XML_END_NAMESPACE_TYPE\";\n case RES_XML_START_ELEMENT_TYPE:\n return \"RES_XML_START_ELEMENT_TYPE\";\n case RES_XML_END_ELEMENT_TYPE:\n return \"RES_XML_END_ELEMENT_TYPE\";\n case RES_XML_CDATA_TYPE:\n return \"RES_XML_CDATA_TYPE\";\n case RES_XML_RESOURCE_MAP_TYPE:\n return \"RES_XML_RESOURCE_MAP_TYPE\";\n case RES_TABLE_PACKAGE_TYPE:\n return \"RES_TABLE_PACKAGE_TYPE\";\n case RES_TABLE_TYPE_TYPE:\n return \"RES_TABLE_TYPE_TYPE\";\n case RES_TABLE_TYPE_SPEC_TYPE:\n return \"RES_TABLE_TYPE_SPEC_TYPE\";\n case RES_TABLE_LIBRARY_TYPE:\n return \"RES_TABLE_LIBRARY_TYPE\";\n case RES_TABLE_OVERLAYABLE_TYPE:\n return \"RES_TABLE_OVERLAYABLE_TYPE\";\n case RES_TABLE_OVERLAYABLE_POLICY_TYPE:\n return \"RES_TABLE_OVERLAYABLE_POLICY_TYPE\";\n case RES_TABLE_STAGED_ALIAS_TYPE:\n return \"RES_TABLE_STAGED_ALIAS_TYPE\";\n default:\n return String.format(\"0x%04x\", type);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResStringPool.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.data;\n\nimport brut.androlib.res.decoder.ResChunkPullParser;\nimport brut.common.Log;\nimport brut.util.BinaryDataInputStream;\nimport com.google.common.annotations.VisibleForTesting;\n\nimport java.io.IOException;\nimport java.nio.ByteBuffer;\nimport java.nio.charset.CharacterCodingException;\nimport java.nio.charset.Charset;\nimport java.nio.charset.CharsetDecoder;\nimport java.nio.charset.StandardCharsets;\nimport java.util.Arrays;\n\npublic class ResStringPool {\n private static final String TAG = ResStringPool.class.getName();\n\n private static final CharsetDecoder UTF16LE_DECODER = StandardCharsets.UTF_16LE.newDecoder();\n private static final CharsetDecoder UTF8_DECODER = StandardCharsets.UTF_8.newDecoder();\n private static final CharsetDecoder CESU8_DECODER = Charset.forName(\"CESU8\").newDecoder();\n\n private static final int UTF8_FLAG = 0x00000100;\n private static final int HEADER_SIZE = 28;\n\n private final int[] mStringOffsets;\n private final byte[] mStrings;\n private final int[] mStyleOffsets;\n private final int[] mStyles;\n private final boolean mIsUtf8;\n\n private ResStringPool(int[] stringOffsets, byte[] strings, int[] styleOffsets, int[] styles, boolean isUtf8) {\n mStringOffsets = stringOffsets;\n mStrings = strings;\n mStyleOffsets = styleOffsets;\n mStyles = styles;\n mIsUtf8 = isUtf8;\n }\n\n @VisibleForTesting\n ResStringPool(byte[] strings, boolean isUtf8) {\n this(new int[0], strings, new int[0], new int[0], isUtf8);\n }\n\n public static ResStringPool parse(ResChunkPullParser parser) throws IOException {\n BinaryDataInputStream in = parser.stream();\n // ResStringPool_header\n int stringCount = in.readInt();\n int styleCount = in.readInt();\n int flags = in.readInt();\n int stringsOffset = in.readInt();\n int stylesOffset = in.readInt();\n\n // For some apps they pack the chunk header with more unused data at end.\n int skipped = parser.skipHeader();\n if (skipped > 0) {\n Log.d(TAG, \"Skipped unknown %s bytes at end of %s chunk header.\", skipped, parser.chunkName());\n }\n\n int[] stringOffsets = readIntArraySafe(in, stringCount, parser.chunkStart() + stringsOffset);\n int[] styleOffsets = readIntArraySafe(in, styleCount, parser.chunkStart() + stylesOffset);\n\n // If we have both strings and even just a lying style offset - let's calculate the size of the strings without\n // accidentally parsing all the styles.\n int size = parser.chunkSize() - stringsOffset;\n if (styleCount > 0) {\n size = stylesOffset - stringsOffset;\n }\n\n byte[] strings = in.readBytes(size);\n\n // #3236 - Some apps give a styles offset, but have 0 styles. Make this check more robust.\n int[] styles;\n if (stylesOffset > 0 && styleCount > 0) {\n size = parser.chunkSize() - stylesOffset;\n styles = in.readIntArray(size / 4);\n } else {\n styles = new int[0];\n }\n\n // In case we aren't 4 byte aligned we need to skip the padding bytes.\n in.skipBytes(size % 4);\n\n boolean isUtf8 = (flags & UTF8_FLAG) != 0;\n\n return new ResStringPool(stringOffsets, strings, styleOffsets, styles, isUtf8);\n }\n\n private static int[] readIntArraySafe(BinaryDataInputStream in, int len, long maxPosition) throws IOException {\n int[] arr = new int[len];\n for (int i = 0; i < len; i++) {\n // #3236 - Some apps have more strings than can fit into the block. This function takes an expected max\n // position and if we are past it, we return early during processing.\n if (in.position() >= maxPosition) {\n Log.d(TAG, \"Bad string block: string entry is at %s, past end at %s\", in.position(), maxPosition);\n return arr;\n }\n\n arr[i] = in.readInt();\n }\n return arr;\n }\n\n public CharSequence getText(int index) {\n String string = getString(index);\n if (string == null) {\n return null;\n }\n\n // Return the raw string if it has no styles.\n int[] style = getStyle(index);\n if (style == null) {\n return string;\n }\n\n // Convert the styles to spans.\n int len = string.length();\n StyledString.Span[] spans = new StyledString.Span[style.length / 3];\n int spansCount = 0;\n\n for (int i = 0; i < style.length; i += 3) {\n String tag = getString(style[i]);\n int firstChar = style[i + 1];\n int lastChar = style[i + 2];\n\n // Ignore the style if it's not in range.\n if (firstChar < 0 || firstChar > len || lastChar > len) {\n continue;\n }\n\n spans[spansCount++] = new StyledString.Span(tag, firstChar, lastChar);\n }\n\n if (spansCount < spans.length) {\n spans = Arrays.copyOf(spans, spansCount);\n }\n\n return new StyledString(string, spans);\n }\n\n public String getString(int index) {\n if (index < 0 || index >= mStringOffsets.length || mStrings.length == 0) {\n return null;\n }\n\n int offset = mStringOffsets[index];\n int[] val;\n if (mIsUtf8) {\n val = getUtf8(mStrings, offset);\n offset = val[0];\n } else {\n val = getUtf16(mStrings, offset);\n offset += val[0];\n }\n\n int length = val[1];\n return decodeString(offset, length);\n }\n\n @VisibleForTesting\n String decodeString(int offset, int length) {\n try {\n ByteBuffer buffer = ByteBuffer.wrap(mStrings, offset, length);\n return (mIsUtf8 ? UTF8_DECODER : UTF16LE_DECODER).decode(buffer).toString();\n } catch (CharacterCodingException ignored) {\n if (!mIsUtf8) {\n Log.w(TAG, \"Failed to decode a string at offset %s of length %s\", offset, length);\n return null;\n }\n } catch (IndexOutOfBoundsException ignored) {\n if (!mIsUtf8) {\n Log.w(TAG, \"String extends outside of pool at %s of length %s\", offset, length);\n return null;\n }\n }\n\n // In some cases, Android uses 3-byte UTF-8 sequences instead of 4-bytes.\n // If decoding failed, we try to use CESU-8 decoder, which is closer to what Android actually uses.\n try {\n ByteBuffer buffer = ByteBuffer.wrap(mStrings, offset, length);\n return CESU8_DECODER.decode(buffer).toString();\n } catch (CharacterCodingException ignored) {\n Log.w(TAG, \"Failed to decode a string with CESU-8 decoder.\");\n return null;\n }\n }\n\n public int findString(String string) {\n if (string == null || mStringOffsets.length == 0 || mStrings.length == 0) {\n return -1;\n }\n\n int len = string.length();\n for (int i = 0; i < mStringOffsets.length; i++) {\n int offset = mStringOffsets[i];\n int length = getShort(mStrings, offset);\n if (length != len) {\n continue;\n }\n\n int j = 0;\n for (; j < length; j++) {\n offset += 2;\n if (string.charAt(j) != getShort(mStrings, offset)) {\n break;\n }\n }\n if (j == length) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Returns style information as an array of int triplets:\n * 1. Index of tag name ('b','i', etc.).\n * 2. Index of tag start in the string.\n * 3. Index of tag end in the string.\n */\n private int[] getStyle(int index) {\n if (index < 0 || index >= mStyleOffsets.length || mStyles.length == 0) {\n return null;\n }\n\n // Make sure not to count a partial triplet.\n int offset = mStyleOffsets[index] / 4;\n int count = 0;\n for (int i = offset; i + 2 < mStyles.length; i += 3) {\n if (mStyles[i] < 0) {\n break;\n }\n count++;\n }\n if (count == 0) {\n return null;\n }\n\n int[] style = new int[count * 3];\n System.arraycopy(mStyles, offset, style, 0, style.length);\n return style;\n }\n\n private static int getShort(byte[] array, int offset) {\n return ((array[offset + 1] & 0xFF) << 8) | (array[offset] & 0xFF);\n }\n\n private static int[] getUtf8(byte[] array, int offset) {\n int val = array[offset];\n\n // Skip the UTF-16 length of the string.\n if ((val & 0x80) != 0) {\n offset += 2;\n } else {\n offset++;\n }\n\n // Read the UTF-8 length of the string.\n val = array[offset];\n offset++;\n int length;\n if ((val & 0x80) != 0) {\n int low = array[offset] & 0xFF;\n length = ((val & 0x7F) << 8) + low;\n offset++;\n } else {\n length = val;\n }\n\n return new int[] { offset, length };\n }\n\n private static int[] getUtf16(byte[] array, int offset) {\n int val = ((array[offset + 1] & 0xFF) << 8) | (array[offset] & 0xFF);\n\n if ((val & 0x8000) != 0) {\n int high = (array[offset + 3] & 0xFF) << 8;\n int low = array[offset + 2] & 0xFF;\n int len_value = ((val & 0x7FFF) << 16) + high + low;\n return new int[] { 4, len_value * 2 };\n }\n\n return new int[] { 2, val * 2 };\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/StyledString.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.data;\n\nimport java.util.Arrays;\nimport java.util.Objects;\n\npublic class StyledString implements CharSequence {\n private final String mValue;\n private final Span[] mSpans;\n\n public StyledString(String value, Span[] spans) {\n assert value != null && spans != null;\n mValue = value;\n mSpans = spans;\n }\n\n public String getValue() {\n return mValue;\n }\n\n public Span[] getSpans() {\n return mSpans;\n }\n\n @Override\n public int length() {\n return mValue.length();\n }\n\n @Override\n public char charAt(int index) {\n return mValue.charAt(index);\n }\n\n @Override\n public CharSequence subSequence(int start, int end) {\n return mValue.subSequence(start, end);\n }\n\n @Override\n public String toString() {\n return mValue;\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof StyledString) {\n StyledString other = (StyledString) obj;\n return mValue.equals(other.mValue)\n && Arrays.equals(mSpans, other.mSpans);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mValue, Arrays.hashCode(mSpans));\n }\n\n public static class Span {\n private final String mTag;\n private final int mFirstChar;\n private final int mLastChar;\n\n public Span(String tag, int firstChar, int lastChar) {\n assert tag != null;\n mTag = tag;\n mFirstChar = firstChar;\n mLastChar = lastChar;\n }\n\n public String getTag() {\n return mTag;\n }\n\n public int getFirstChar() {\n return mFirstChar;\n }\n\n public int getLastChar() {\n return mLastChar;\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryResourceParser.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.UndefinedResObjectException;\nimport brut.androlib.res.data.ResChunkHeader;\nimport brut.androlib.res.data.ResStringPool;\nimport brut.androlib.res.table.*;\nimport brut.androlib.res.table.value.*;\nimport brut.common.Log;\nimport brut.util.BinaryDataInputStream;\nimport com.google.common.io.BaseEncoding;\nimport org.apache.commons.lang3.tuple.Pair;\n\nimport java.io.*;\nimport java.nio.charset.StandardCharsets;\nimport java.util.*;\n\npublic class BinaryResourceParser {\n private static final String TAG = BinaryResourceParser.class.getName();\n\n private static final int NO_ENTRY = 0xFFFFFFFF;\n private static final int NO_ENTRY_OFFSET16 = 0xFFFF;\n\n // ResTable_typeSpec flags:\n // Additional flag indicating an entry is public.\n private static final int SPEC_FLAG_PUBLIC = 0x40000000;\n // Additional flag indicating the resource id for this resource may change in a future\n // build. If this flag is set, the SPEC_PUBLIC flag is also set since the resource must be\n // public to be exposed as an API to other applications.\n private static final int SPEC_FLAG_STAGED_API = 0x20000000;\n\n // ResTable_type flags:\n // If set, the entry is sparse, and encodes both the entry ID and offset into each entry,\n // and a binary search is used to find the key. Only available on platforms >= O.\n // Mark any types that use this with a v26 qualifier to prevent runtime issues on older platforms.\n private static final int TYPE_FLAG_SPARSE = 0x01;\n // If set, the offsets to the entries are encoded in 16-bit, real_offset = offset * 4u\n // An 16-bit offset of 0xffffu means a NO_ENTRY.\n private static final int TYPE_FLAG_OFFSET16 = 0x02;\n\n // ResTable_entry flags:\n // If set, this is a complex entry, holding a set of name/value mappings.\n // It is followed by an array of ResTable_map structures.\n private static final int ENTRY_FLAG_COMPLEX = 0x0001;\n // If set, this resource has been declared public, so libraries are allowed to reference it.\n private static final int ENTRY_FLAG_PUBLIC = 0x0002;\n // If set, this is a weak resource and may be overridden by strong resources of the same name/type.\n // This is only useful during linking with other resource tables.\n private static final int ENTRY_FLAG_WEAK = 0x0004;\n // If set, this is a compact entry with data type and value directly encoded in the entry.\n private static final int ENTRY_FLAG_COMPACT = 0x0008;\n // If set, this resource relies on an android feature flag.\n // This should not be encountered in most cases (#3993)\n private static final int ENTRY_FLAG_FEATUREFLAG = 0x0010;\n\n private final ResTable mTable;\n private final boolean mKeepBrokenResources;\n private final boolean mAllowDummyEntrySpecs;\n private final Set mMissingEntrySpecs;\n private final Set mInvalidConfigs;\n\n private BinaryDataInputStream mIn;\n private ResStringPool mValueStringPool;\n private int mPackageCount;\n private ResPackage mPackage;\n private int mTypeIdOffset;\n private ResStringPool mTypeStringPool;\n private ResStringPool mKeyStringPool;\n private boolean mSparseEntries;\n private boolean mCompactEntries;\n private List> mEntrySpecFlagsOffsets;\n\n public BinaryResourceParser(ResTable table, boolean keepBrokenResources, boolean allowDummyEntrySpecs) {\n mTable = table;\n mKeepBrokenResources = keepBrokenResources;\n mAllowDummyEntrySpecs = allowDummyEntrySpecs;\n mMissingEntrySpecs = new HashSet<>();\n mInvalidConfigs = new HashSet<>();\n }\n\n public boolean isSparseEntries() {\n return mSparseEntries;\n }\n\n public boolean isCompactEntries() {\n return mCompactEntries;\n }\n\n public void enableCollectFlagsOffsets() {\n mEntrySpecFlagsOffsets = new ArrayList<>();\n }\n\n public Collection> getEntrySpecFlagsOffsets() {\n return mEntrySpecFlagsOffsets;\n }\n\n public void parse(InputStream in) throws AndrolibException {\n reset();\n mIn = new BinaryDataInputStream(in);\n\n ResChunkPullParser parser = new ResChunkPullParser(mIn);\n try {\n if (!nextChunk(parser)) {\n throw new AndrolibException(\"Input file is empty.\");\n }\n if (parser.chunkType() != ResChunkHeader.RES_TABLE_TYPE) {\n throw new AndrolibException(\"Unexpected chunk: \" + parser.chunkName() + \" (expected: RES_TABLE_TYPE)\");\n }\n\n parseTable(parser);\n\n Log.d(TAG, \"End of chunks at 0x%08x\", mIn.position());\n\n // We can't use remaining() here, the length of the main stream is unknown.\n if (mIn.available() > 0) {\n Log.d(TAG, \"Ignoring trailing data at 0x%08x.\", mIn.position());\n }\n } catch (IOException ex) {\n throw new AndrolibException(\"Could not decode arsc file.\", ex);\n }\n }\n\n public void reset() {\n mIn = null;\n mMissingEntrySpecs.clear();\n mInvalidConfigs.clear();\n mValueStringPool = null;\n mPackageCount = 0;\n mPackage = null;\n mTypeIdOffset = 0;\n mTypeStringPool = null;\n mKeyStringPool = null;\n mSparseEntries = false;\n mCompactEntries = false;\n if (mEntrySpecFlagsOffsets != null) {\n mEntrySpecFlagsOffsets.clear();\n }\n }\n\n private boolean nextChunk(ResChunkPullParser parser) throws IOException {\n // Skip padding or unknown data at the end of current chunk.\n if (parser.isChunk()) {\n int skipped = parser.skipChunk();\n if (skipped > 0) {\n Log.d(TAG, \"Skipped unknown %s bytes at end of %s chunk.\", skipped, parser.chunkName());\n }\n }\n\n // Parse next chunk.\n while (parser.next()) {\n // Skip unknown or unsupported chunks.\n if (parser.chunkType() == ResChunkHeader.RES_NULL_TYPE) {\n Log.d(TAG, \"Skipping unknown chunk (%s) of %s bytes at 0x%08x.\",\n parser.chunkName(), parser.chunkSize(), parser.chunkStart());\n parser.skipChunk();\n continue;\n }\n\n // Return this chunk.\n Log.d(TAG, \"Chunk at 0x%08x: %s (%s bytes)\", parser.chunkStart(), parser.chunkName(), parser.chunkSize());\n return true;\n }\n\n // End of chunks.\n return false;\n }\n\n private void parseTable(ResChunkPullParser parser) throws AndrolibException, IOException {\n // ResTable_header\n int packageCount = mIn.readInt();\n\n skipUnreadHeader(parser);\n\n parser = new ResChunkPullParser(mIn, parser.dataSize());\n while (nextChunk(parser)) {\n switch (parser.chunkType()) {\n case ResChunkHeader.RES_STRING_POOL_TYPE:\n parseStringPool(parser);\n break;\n case ResChunkHeader.RES_TABLE_PACKAGE_TYPE:\n parsePackage(parser);\n break;\n default:\n skipUnexpectedChunk(parser);\n break;\n }\n }\n\n if (mPackageCount != packageCount) {\n Log.w(TAG, \"Unexpected package count: %s (expected: %s)\", mPackageCount, packageCount);\n }\n }\n\n private void parseStringPool(ResChunkPullParser parser) throws AndrolibException, IOException {\n ResStringPool stringPool = ResStringPool.parse(parser);\n\n if (mValueStringPool == null) {\n mValueStringPool = stringPool;\n } else if (mTypeStringPool == null) {\n mTypeStringPool = stringPool;\n } else if (mKeyStringPool == null) {\n mKeyStringPool = stringPool;\n } else {\n skipUnexpectedChunk(parser);\n }\n }\n\n private void parsePackage(ResChunkPullParser parser) throws AndrolibException, IOException {\n // ResTable_package\n int id = mIn.readInt();\n String name = mIn.readUtf16(128);\n mIn.skipInt(); // typeStrings\n mIn.skipInt(); // lastPublicType\n mIn.skipInt(); // keyStrings\n mIn.skipInt(); // lastPublicKey\n\n // TypeIdOffset was added platform_frameworks_base/@f90f2f8dc36e7243b85e0b6a7fd5a590893c827e\n // which is only in split/new apps.\n // sizeof(ResTable_package) = short + short + int + int + char[128] + int * 5 = 288\n if (parser.headerSize() >= 288) {\n mTypeIdOffset = mIn.readInt();\n\n if (mTypeIdOffset > 0) {\n Log.w(TAG, \"Please report this app here: https://github.com/iBotPeaches/Apktool/issues/1728\");\n }\n } else {\n mTypeIdOffset = 0;\n }\n\n skipUnreadHeader(parser);\n\n try {\n mPackage = mTable.getPackageGroup(id).addSubPackage();\n } catch (UndefinedResObjectException ignored) {\n mPackage = mTable.addPackageGroup(id, name).getBasePackage();\n } finally {\n mPackageCount++;\n }\n\n parser = new ResChunkPullParser(mIn, parser.dataSize());\n while (nextChunk(parser)) {\n switch (parser.chunkType()) {\n case ResChunkHeader.RES_STRING_POOL_TYPE:\n parseStringPool(parser);\n break;\n case ResChunkHeader.RES_TABLE_TYPE_SPEC_TYPE:\n parseTypeSpec(parser);\n break;\n case ResChunkHeader.RES_TABLE_TYPE_TYPE:\n parseType(parser);\n break;\n case ResChunkHeader.RES_TABLE_LIBRARY_TYPE:\n parseLibrary(parser);\n break;\n case ResChunkHeader.RES_TABLE_OVERLAYABLE_TYPE:\n parseOverlayable(parser);\n break;\n case ResChunkHeader.RES_TABLE_STAGED_ALIAS_TYPE:\n parseStagedAliases(parser);\n break;\n default:\n skipUnexpectedChunk(parser);\n break;\n }\n }\n\n // Clean up.\n injectDummyEntrySpecs();\n mInvalidConfigs.clear();\n mPackage = null;\n mTypeIdOffset = 0;\n mTypeStringPool = null;\n mKeyStringPool = null;\n }\n\n private void parseTypeSpec(ResChunkPullParser parser) throws AndrolibException, IOException {\n if (mTypeStringPool == null) {\n throw new AndrolibException(\"Missing type string pool.\");\n }\n\n // ResTable_typeSpec\n int id = mIn.readUnsignedByte();\n mIn.skipByte(); // res0\n mIn.skipShort(); // typesCount\n int entryCount = mIn.readInt();\n\n skipUnreadHeader(parser);\n\n if (mEntrySpecFlagsOffsets != null) {\n mEntrySpecFlagsOffsets.add(Pair.of(mIn.position(), entryCount));\n }\n mIn.skipBytes(entryCount * 4); // flags\n\n mPackage.addTypeSpec(id, mTypeStringPool.getString(id - 1));\n }\n\n private void parseType(ResChunkPullParser parser) throws AndrolibException, IOException {\n if (mTypeStringPool == null) {\n throw new AndrolibException(\"Missing type string pool.\");\n }\n if (mKeyStringPool == null) {\n throw new AndrolibException(\"Missing key string pool\");\n }\n\n // ResTable_type\n int id = mIn.readUnsignedByte() - mTypeIdOffset;\n int flags = mIn.readUnsignedByte();\n mIn.skipShort(); // reserved\n int entryCount = mIn.readInt();\n int entriesStart = mIn.readInt();\n ResConfig config = parseConfig();\n\n skipUnreadHeader(parser);\n\n // #3311 - Some older apps have no TYPE_SPEC chunks, but still define TYPE chunks.\n ResTypeSpec typeSpec;\n try {\n typeSpec = mPackage.getTypeSpec(id);\n } catch (UndefinedResObjectException ignored) {\n typeSpec = mPackage.addTypeSpec(id, mTypeStringPool.getString(id - 1));\n }\n\n String typeName = typeSpec.getName();\n ResType type;\n if (mInvalidConfigs.contains(config)) {\n if (mKeepBrokenResources) {\n Log.w(TAG, \"Invalid resource config detected: %s %s\", typeName, config);\n type = mPackage.addType(id, config);\n } else {\n Log.w(TAG, \"Invalid resource config detected. Dropping resources: %s %s\", typeName, config);\n type = null;\n }\n } else {\n type = mPackage.addType(id, config);\n }\n\n boolean isOffset16 = (flags & TYPE_FLAG_OFFSET16) != 0;\n boolean isSparse = (flags & TYPE_FLAG_SPARSE) != 0;\n\n if (isSparse) {\n mSparseEntries = true;\n }\n\n // #3778 - In some apps the res entries are unordered and might have to jump backwards.\n // We simply pre-sort them by offset.\n Map> entryOffsets = new TreeMap<>();\n for (int i = 0; i < entryCount; i++) {\n int index, offset;\n\n // #3372 - 16-bit offsets should be stored as real offsets (* 4u).\n if (isSparse) {\n index = mIn.readUnsignedShort();\n offset = mIn.readUnsignedShort() * 4;\n } else {\n index = i;\n\n if (isOffset16) {\n offset = mIn.readUnsignedShort();\n offset = offset == NO_ENTRY_OFFSET16 ? NO_ENTRY : offset * 4;\n } else {\n offset = mIn.readInt();\n }\n }\n\n List indexes = entryOffsets.get(offset);\n if (indexes == null) {\n indexes = new ArrayList<>();\n entryOffsets.put(offset, indexes);\n }\n indexes.add(index);\n }\n\n // Exclude NO_ENTRY indexes.\n List indexes = entryOffsets.get(NO_ENTRY);\n if (indexes != null) {\n if (type != null) {\n for (int index : indexes) {\n if (!mPackage.hasEntrySpec(id, index)) {\n mMissingEntrySpecs.add(ResId.of(mPackage.getId(), id, index));\n }\n }\n }\n\n entryOffsets.remove(NO_ENTRY);\n // Update the entry count for logging.\n entryCount -= indexes.size();\n }\n\n // Parse the remaining entries.\n for (Map.Entry> entryOffset : entryOffsets.entrySet()) {\n int offset = entryOffset.getKey();\n indexes = entryOffset.getValue();\n\n // #3428 - In some apps the res entries are padded for alignment, but in #3778 it made sense to align\n // to the start of the entries to handle all cases.\n long entryStart = parser.chunkStart() + entriesStart + offset;\n\n // As seen in some recent APKs - there are more entries reported than can fit in the chunk.\n if (entryStart >= parser.chunkEnd()) {\n Log.w(TAG, \"End of chunk hit. Skipping remaining %s entries in type: %s\", entryCount, typeName);\n break;\n }\n\n // Align the stream with the start of the entry.\n mIn.jumpTo(entryStart);\n\n Pair entry = parseEntry(typeName);\n int key = entry.getLeft();\n ResValue value = entry.getRight();\n\n // Add all entries with the parsed value, or discard them if the config was invalid.\n if (type != null) {\n for (int index : indexes) {\n ResId resId = ResId.of(mPackage.getId(), id, index);\n\n // #2824 - In some apps the res entries are duplicated with the 2nd being malformed.\n // AOSP skips this, so we will do the same.\n if (value == null) {\n if (!mPackage.hasEntrySpec(id, index)) {\n mMissingEntrySpecs.add(resId);\n }\n continue;\n }\n\n // The same entry can never be added more than once.\n if (mPackage.hasEntry(id, index, config)) {\n Log.w(TAG, \"Ignoring repeated entry: id=%s, config=%s\", resId, config);\n continue;\n }\n\n if (!mPackage.hasEntrySpec(id, index)) {\n mPackage.addEntrySpec(id, index, mKeyStringPool.getString(key));\n mMissingEntrySpecs.remove(resId);\n }\n mPackage.addEntry(id, index, config, value);\n }\n }\n\n // Update the entry count for logging.\n entryCount -= indexes.size();\n }\n }\n\n private ResConfig parseConfig() throws AndrolibException, IOException {\n long startPosition = mIn.position();\n // ResTable_config\n int size = mIn.readInt();\n if (size < 8) {\n throw new AndrolibException(\"Config size < 8\");\n }\n\n int mcc = mIn.readUnsignedShort();\n int mnc = mIn.readUnsignedShort();\n\n String language = \"\";\n String region = \"\";\n if (size >= 12) {\n language = unpackLanguageOrRegion(mIn.readBytes(2), 'a');\n region = unpackLanguageOrRegion(mIn.readBytes(2), '0');\n }\n\n int orientation = 0;\n int touchscreen = 0;\n if (size >= 14) {\n orientation = mIn.readUnsignedByte();\n touchscreen = mIn.readUnsignedByte();\n }\n\n int density = 0;\n if (size >= 16) {\n density = mIn.readUnsignedShort();\n }\n\n int keyboard = 0;\n int navigation = 0;\n int inputFlags = 0;\n int grammaticalInflection = 0;\n if (size >= 20) {\n keyboard = mIn.readUnsignedByte();\n navigation = mIn.readUnsignedByte();\n inputFlags = mIn.readUnsignedByte();\n grammaticalInflection = mIn.readUnsignedByte();\n }\n\n int screenWidth = 0;\n int screenHeight = 0;\n int sdkVersion = 0;\n int minorVersion = 0;\n if (size >= 28) {\n screenWidth = mIn.readUnsignedShort();\n screenHeight = mIn.readUnsignedShort();\n sdkVersion = mIn.readUnsignedShort();\n minorVersion = mIn.readUnsignedShort();\n }\n\n int screenLayout = 0;\n int uiMode = 0;\n int smallestScreenWidthDp = 0;\n if (size >= 32) {\n screenLayout = mIn.readUnsignedByte();\n uiMode = mIn.readUnsignedByte();\n smallestScreenWidthDp = mIn.readUnsignedShort();\n }\n\n int screenWidthDp = 0;\n int screenHeightDp = 0;\n if (size >= 36) {\n screenWidthDp = mIn.readUnsignedShort();\n screenHeightDp = mIn.readUnsignedShort();\n }\n\n String localeScript = \"\";\n String localeVariant = \"\";\n if (size >= 48) {\n localeScript = mIn.readAscii(4);\n localeVariant = mIn.readAscii(8);\n }\n\n int screenLayout2 = 0;\n int colorMode = 0;\n if (size >= 52) {\n screenLayout2 = mIn.readUnsignedByte();\n colorMode = mIn.readUnsignedByte();\n mIn.skipShort(); // screenConfigPad2\n }\n\n // Data beyond this point is non-standard.\n int bytesRead = (int) (mIn.position() - startPosition);\n byte[] unknown = readExceedingBytes(\"Config\", size, bytesRead);\n\n ResConfig config = new ResConfig(\n mcc, mnc, language, region, orientation, touchscreen, density,\n keyboard, navigation, inputFlags, grammaticalInflection, screenWidth,\n screenHeight, sdkVersion, minorVersion, screenLayout, uiMode,\n smallestScreenWidthDp, screenWidthDp, screenHeightDp, localeScript,\n localeVariant, screenLayout2, colorMode, unknown);\n\n if (config.isInvalid()) {\n mInvalidConfigs.add(config);\n }\n\n return config;\n }\n\n private String unpackLanguageOrRegion(byte[] in, char base) {\n assert in.length == 2;\n // Return empty for \"any\" locale.\n if (in[0] == 0) {\n return \"\";\n }\n\n // If high bit is set then we have a packed 3-letter code.\n if ((in[0] & 0x80) != 0) {\n in = new byte[] {\n (byte) (base + (in[1] & 0x1F)),\n (byte) (base + ((in[1] & 0xE0) >>> 5) + ((in[0] & 0x03) << 3)),\n (byte) (base + ((in[0] & 0x7C) >>> 2))\n };\n }\n\n return new String(in, StandardCharsets.US_ASCII);\n }\n\n private Pair parseEntry(String typeName) throws AndrolibException, IOException {\n // ResTable_entry\n int size = mIn.readUnsignedShort();\n int flags = mIn.readUnsignedShort();\n int key = mIn.readInt();\n\n boolean isComplex = (flags & ENTRY_FLAG_COMPLEX) != 0;\n boolean isCompact = (flags & ENTRY_FLAG_COMPACT) != 0;\n\n if (key == NO_ENTRY && !isCompact) {\n return null;\n }\n\n if (isCompact) {\n mCompactEntries = true;\n }\n\n ResValue value;\n if (isComplex && !isCompact) {\n value = parseBag(typeName);\n } else if (isCompact) {\n // In a compactly packed entry, the key index is the size & type is higher 8 bits on flags.\n // We assume a size of 8 bytes for compact entries and the key index is the data itself encoded.\n int type = (flags >>> 8) & 0xFF;\n value = parseItem(typeName, false, type, key);\n\n // If compact then the size has the key index encoded.\n key = size;\n } else {\n value = parseItem(typeName, false);\n }\n\n return Pair.of(key, value);\n }\n\n private ResValue parseBag(String typeName) throws AndrolibException, IOException {\n // ResTable_map_entry\n int parentId = mIn.readInt();\n int count = mIn.readInt();\n\n // Some apps store ID resource values generated for enum/flag items in attribute resources as empty maps.\n // Replace with a placeholder value.\n if (typeName.equals(\"id\")) {\n return ResCustom.ID;\n }\n\n ResReference parent = new ResReference(mPackage, ResId.of(parentId));\n ResBag.RawItem[] rawItems = new ResBag.RawItem[count];\n int rawItemsCount = 0;\n\n for (int i = 0; i < count; i++) {\n // ResTable_map\n int name = mIn.readInt();\n ResItem value = (ResItem) parseItem(typeName, true);\n\n // #2824 - In some apps the res entries are duplicated with the 2nd being malformed.\n // AOSP skips this, so we will do the same.\n if (value == null) {\n continue;\n }\n\n rawItems[rawItemsCount++] = new ResBag.RawItem(name, value);\n }\n\n if (rawItemsCount < rawItems.length) {\n rawItems = Arrays.copyOf(rawItems, rawItemsCount);\n }\n\n return ResBag.parse(typeName, parent, rawItems);\n }\n\n private ResValue parseItem(String typeName, boolean inBag) throws AndrolibException, IOException {\n // Res_value\n int size = mIn.readUnsignedShort();\n if (size < 8) {\n return null;\n }\n mIn.skipByte(); // res0\n int type = mIn.readUnsignedByte();\n int data = mIn.readInt();\n\n return parseItem(typeName, inBag, type, data);\n }\n\n private ResValue parseItem(String typeName, boolean inBag, int type, int data) throws AndrolibException {\n // ID resource values are either encoded as a boolean (false) or a resource reference.\n // A boolean (false) is no longer allowed in XML, replace with a placeholder value.\n // A resource reference is handled normally, unless it's @null.\n if (typeName.equals(\"id\") && (data == 0 || (type != ResValue.TYPE_REFERENCE\n && type != ResValue.TYPE_DYNAMIC_REFERENCE))) {\n return ResCustom.ID;\n }\n\n // Special handling for strings and file references.\n if (type == ResValue.TYPE_STRING) {\n if (mValueStringPool == null) {\n throw new AndrolibException(\"Missing value string pool.\");\n }\n\n CharSequence strValue = mValueStringPool.getText(data);\n\n // If a string is not allowed here, assume it's a file reference.\n // ResFileDecoder will replace it if it's an invalid file reference.\n if (strValue instanceof String && strValue.length() > 0 && !inBag && !typeName.equals(\"string\")) {\n return new ResFileReference((String) strValue);\n }\n\n return new ResString(strValue);\n }\n\n return ResItem.parse(mPackage, type, data);\n }\n\n private void parseLibrary(ResChunkPullParser parser) throws IOException {\n // ResTable_lib_header\n int count = mIn.readInt();\n\n skipUnreadHeader(parser);\n\n for (int i = 0; i < count; i++) {\n // ResTable_lib_entry\n int packageId = mIn.readInt();\n String packageName = mIn.readUtf16(128);\n\n if (packageId != 0 && !packageName.isEmpty()) {\n mTable.addDynamicRefPackage(packageId, packageName);\n }\n }\n }\n\n private void parseOverlayable(ResChunkPullParser parser) throws AndrolibException, IOException {\n // ResTable_overlayable_header\n String name = mIn.readUtf16(256);\n String actor = mIn.readUtf16(256);\n\n skipUnreadHeader(parser);\n\n // An overlayable without a name is invalid, so we skip it entirely.\n if (name.isEmpty()) {\n return;\n }\n\n // Avoid conflicts by reusing overlayables.\n ResOverlayable overlayable;\n try {\n overlayable = mPackage.getOverlayable(name);\n } catch (UndefinedResObjectException ignored) {\n overlayable = mPackage.addOverlayable(name, actor);\n }\n\n parser = new ResChunkPullParser(mIn, parser.dataSize());\n while (nextChunk(parser)) {\n if (parser.chunkType() != ResChunkHeader.RES_TABLE_OVERLAYABLE_POLICY_TYPE) {\n skipUnexpectedChunk(parser);\n continue;\n }\n\n // ResTable_overlayable_policy_header\n int flags = mIn.readInt();\n int entryCount = mIn.readInt();\n\n skipUnreadHeader(parser);\n\n ResId[] entries = new ResId[entryCount];\n int entriesCount = 0;\n\n for (int i = 0; i < entryCount; i++) {\n entries[entriesCount++] = ResId.of(mIn.readInt());\n }\n\n if (entriesCount < entries.length) {\n entries = Arrays.copyOf(entries, entriesCount);\n }\n\n overlayable.addPolicy(flags, entries);\n }\n }\n\n private void parseStagedAliases(ResChunkPullParser parser) throws AndrolibException, IOException {\n // ResTable_staged_alias_header\n int count = mIn.readInt();\n\n skipUnreadHeader(parser);\n\n for (int i = 0; i < count; i++) {\n // ResTable_staged_alias_entry\n int stagedResId = mIn.readInt();\n int finalizedResId = mIn.readInt();\n\n if (stagedResId != 0 && finalizedResId != 0) {\n mPackage.addAlias(ResId.of(stagedResId), ResId.of(finalizedResId));\n }\n }\n }\n\n private void skipUnexpectedChunk(ResChunkPullParser parser) throws IOException {\n Log.w(TAG, \"Skipping unexpected %s chunk of %s bytes at 0x%08x.\",\n parser.chunkName(), parser.chunkSize(), parser.chunkStart());\n parser.skipChunk();\n }\n\n private void skipUnreadHeader(ResChunkPullParser parser) throws IOException {\n // Some apps lie about the reported size of their chunk header. Trusting the header size is misleading,\n // so compare to what we actually read in the header vs reported and skip the rest.\n int bytesRead = (int) (mIn.position() - parser.chunkStart());\n readExceedingBytes(\"Chunk header\", parser.headerSize(), bytesRead);\n }\n\n private byte[] readExceedingBytes(String name, int size, int bytesRead) throws IOException {\n int bytesExceeding = size - bytesRead;\n if (bytesExceeding > 0) {\n byte[] buf = mIn.readBytes(bytesExceeding);\n for (int i = 0; i < buf.length; i++) {\n if (buf[i] != 0) {\n Log.w(TAG, \"%s size: %s bytes, read: %s bytes. Exceeding bytes: %s\",\n name, size, bytesRead, BaseEncoding.base16().encode(buf));\n return buf;\n }\n }\n }\n return null;\n }\n\n private void injectDummyEntrySpecs() throws AndrolibException {\n if (mAllowDummyEntrySpecs) {\n ResReference parent = new ResReference(mPackage, ResId.NULL);\n ResBag.RawItem[] rawItems = new ResBag.RawItem[0];\n\n for (ResId resId : mMissingEntrySpecs) {\n ResTypeSpec typeSpec = mPackage.getTypeSpec(resId.typeId());\n String typeName = typeSpec.getName();\n ResValue value;\n if (typeName.equals(\"id\")) {\n value = ResCustom.ID;\n } else if (typeName.equals(\"string\")) {\n value = ResString.EMPTY;\n } else if (typeSpec.isBagType()) {\n value = ResBag.parse(typeName, parent, rawItems);\n } else {\n value = ResPrimitive.NULL;\n }\n\n mPackage.addEntrySpec(resId.typeId(), resId.entryId(), ResEntrySpec.DUMMY_PREFIX + resId);\n mPackage.addEntry(resId.typeId(), resId.entryId(), value);\n }\n }\n\n mMissingEntrySpecs.clear();\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/BinaryXmlResourceParser.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.UndefinedResObjectException;\nimport brut.androlib.res.data.ResChunkHeader;\nimport brut.androlib.res.data.ResStringPool;\nimport brut.androlib.res.table.*;\nimport brut.androlib.res.table.value.*;\nimport brut.androlib.res.xml.ResXmlUtils;\nimport brut.common.Log;\nimport brut.util.BinaryDataInputStream;\nimport com.google.common.io.BaseEncoding;\nimport org.xmlpull.v1.XmlPullParser;\nimport org.xmlpull.v1.XmlPullParserException;\n\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.Reader;\n\npublic class BinaryXmlResourceParser implements XmlPullParser {\n private static final String TAG = BinaryXmlResourceParser.class.getName();\n private static final String NOT_SUPPORTED = \"Method is not supported.\";\n\n private final ResTable mTable;\n private final boolean mIgnoreRawValues;\n private final boolean mSkipUnresolved;\n private final NamespaceStack mNamespaces;\n\n private BinaryDataInputStream mIn;\n private ResChunkPullParser mParser;\n private ResStringPool mStringPool;\n private ResId[] mResourceMap;\n private boolean mHasRawValues;\n private AndrolibException mFirstError;\n\n private int mEventType;\n private int mLineNumber;\n private int mNamespaceIndex;\n private int mNameIndex;\n private int mIdIndex;\n private int mClassIndex;\n private int mStyleIndex;\n private Attribute[] mAttributes;\n\n public BinaryXmlResourceParser(ResTable table, boolean ignoreRawValues, boolean skipUnresolved) {\n mTable = table;\n mIgnoreRawValues = ignoreRawValues;\n mSkipUnresolved = skipUnresolved;\n mNamespaces = new NamespaceStack();\n resetEventInfo();\n }\n\n public boolean hasRawValues() {\n return mHasRawValues;\n }\n\n public AndrolibException getFirstError() {\n return mFirstError;\n }\n\n // XmlPullParser\n\n @Override\n public void setFeature(String name, boolean state) throws XmlPullParserException {\n throw new XmlPullParserException(NOT_SUPPORTED);\n }\n\n @Override\n public boolean getFeature(String name) {\n return false;\n }\n\n @Override\n public void setProperty(String name, Object value) throws XmlPullParserException {\n throw new XmlPullParserException(NOT_SUPPORTED);\n }\n\n @Override\n public Object getProperty(String name) {\n return null;\n }\n\n @Override\n public void setInput(Reader in) throws XmlPullParserException {\n throw new XmlPullParserException(NOT_SUPPORTED);\n }\n\n @Override\n public void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException {\n if (inputEncoding != null) {\n throw new XmlPullParserException(NOT_SUPPORTED);\n }\n\n reset();\n mIn = new BinaryDataInputStream(inputStream);\n mParser = new ResChunkPullParser(mIn);\n try {\n if (!nextChunk()) {\n throw new IOException(\"Input file is empty.\");\n }\n if (mParser.chunkType() != ResChunkHeader.RES_XML_TYPE) {\n throw new IOException(\"Unexpected chunk: \" + mParser.chunkName() + \" (expected: RES_XML_TYPE)\");\n }\n } catch (IOException ex) {\n mIn = null;\n mParser = null;\n throw new XmlPullParserException(\"Could not initialize parser.\", this, ex);\n }\n\n mParser = new ResChunkPullParser(mIn, mParser.dataSize());\n }\n\n @Override\n public String getInputEncoding() {\n return null;\n }\n\n @Override\n public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException {\n throw new XmlPullParserException(NOT_SUPPORTED);\n }\n\n @Override\n public int getNamespaceCount(int depth) {\n return mNamespaces.getCount(depth);\n }\n\n @Override\n public String getNamespacePrefix(int pos) {\n if (mStringPool == null) {\n return null;\n }\n int prefixIdx = mNamespaces.getPrefix(pos);\n return mStringPool.getString(prefixIdx);\n }\n\n @Override\n public String getNamespaceUri(int pos) {\n if (mStringPool == null) {\n return null;\n }\n int uriIdx = mNamespaces.getUri(pos);\n return mStringPool.getString(uriIdx);\n }\n\n @Override\n public String getNamespace(String prefix) {\n throw new RuntimeException(NOT_SUPPORTED);\n }\n\n @Override\n public int getDepth() {\n return mNamespaces.getDepth();\n }\n\n @Override\n public String getPositionDescription() {\n return \"XML line #\" + getLineNumber();\n }\n\n @Override\n public int getLineNumber() {\n return mLineNumber;\n }\n\n @Override\n public int getColumnNumber() {\n return -1;\n }\n\n @Override\n public boolean isWhitespace() throws XmlPullParserException {\n if (mEventType != TEXT) {\n throw new XmlPullParserException(\"Parser must be on TEXT to get text.\", this, null);\n }\n String text = getText();\n if (text == null) {\n return true;\n }\n int len = text.length();\n for (int i = 0; i < len; i++) {\n if (!Character.isWhitespace(text.charAt(i))) {\n return false;\n }\n }\n return true;\n }\n\n @Override\n public String getText() {\n if (mStringPool == null || mEventType != TEXT) {\n return null;\n }\n return mStringPool.getString(mNameIndex);\n }\n\n @Override\n public char[] getTextCharacters(int[] holderForStartAndLength) {\n String text = getText();\n if (text == null) {\n return null;\n }\n int len = text.length();\n holderForStartAndLength[0] = 0;\n holderForStartAndLength[1] = len;\n char[] chars = new char[len];\n text.getChars(0, len, chars, 0);\n return chars;\n }\n\n @Override\n public String getNamespace() {\n if (mStringPool == null || (mEventType != START_TAG && mEventType != END_TAG)) {\n return null;\n }\n return mStringPool.getString(mNamespaceIndex);\n }\n\n @Override\n public String getName() {\n if (mStringPool == null || (mEventType != START_TAG && mEventType != END_TAG)) {\n return null;\n }\n return mStringPool.getString(mNameIndex);\n }\n\n @Override\n public String getPrefix() {\n if (mStringPool == null || (mEventType != START_TAG && mEventType != END_TAG)) {\n return null;\n }\n int prefixIdx = mNamespaces.findPrefix(mNamespaceIndex);\n return mStringPool.getString(prefixIdx);\n }\n\n @Override\n public boolean isEmptyElementTag() {\n return false;\n }\n\n @Override\n public int getAttributeCount() {\n if (mEventType != START_TAG) {\n return -1;\n }\n return mAttributes != null ? mAttributes.length : 0;\n }\n\n @Override\n public String getAttributeNamespace(int index) {\n Attribute attr = getAttribute(index);\n if (attr == null) {\n return NO_NAMESPACE;\n }\n\n ResId nameId = getAttributeNameResourceId(index);\n\n // #2972 - If the namespace index is -1, the attribute is not present, but if the attribute is from system we\n // can resolve it to the default namespace. This may prove to be too aggressive as we scope the entire system\n // namespace, but it's better than not resolving it at all.\n if (attr.ns < 0) {\n if (nameId.pkgId() == ResTable.APP_PACKAGE_ID) {\n return getNonDefaultNamespaceUri(index);\n }\n if (nameId.pkgId() == ResTable.SYS_PACKAGE_ID) {\n return ResXmlUtils.ANDROID_RES_NS;\n }\n return NO_NAMESPACE;\n }\n\n // Minifiers like removing the namespace, so we will fall back to default namespace unless the package ID of\n // the resource is private. We will grab the non-standard one.\n String uri = mStringPool != null ? mStringPool.getString(attr.ns) : null;\n if (uri != null && !uri.isEmpty()) {\n return uri;\n }\n if (nameId.pkgId() == ResTable.APP_PACKAGE_ID) {\n return getNonDefaultNamespaceUri(index);\n }\n return ResXmlUtils.ANDROID_RES_NS;\n }\n\n @Override\n public String getAttributeName(int index) {\n Attribute attr = getAttribute(index);\n if (attr == null || attr.name < 0) {\n return \"\";\n }\n\n ResId nameId = getAttributeNameResourceId(index);\n\n // Android prefers the resource table value over what the string pool has.\n // This can be seen quite often in obfuscated apps where values such as:\n // \n // Are improperly decoded when trusting the string pool.\n // Leveraging the resource table allows us to get the proper value.\n // \n if (nameId != ResId.NULL) {\n try {\n return mTable.resolve(nameId).getName();\n } catch (AndrolibException ignored) {\n }\n }\n\n // Couldn't decode from resource table, fall back to string pool.\n String name = mStringPool != null ? mStringPool.getString(attr.name) : null;\n if (name == null) {\n name = \"\";\n }\n\n // In certain optimized apps, some attributes's specs are removed despite being used.\n // Inject a generic spec for the attribute, otherwise we can't rebuild.\n if (nameId != ResId.NULL) {\n try {\n ResPackage pkg = mTable.getMainPackage();\n if (pkg == null) {\n // If no main package, we load \"android\" package instead.\n pkg = mTable.resolvePackageGroup(1).getBasePackage();\n }\n\n // #2836 - Skip item if the resource cannot be resolved.\n if (mSkipUnresolved || nameId.pkgId() != pkg.getId()) {\n Log.w(TAG, \"Unresolved attr reference: ns=%s, name=%s, id=%s\",\n getAttributePrefix(index), name, nameId);\n return name;\n }\n\n if (name.isEmpty()) {\n name = ResEntrySpec.DUMMY_PREFIX + nameId;\n }\n name = pkg.addEntrySpec(nameId.typeId(), nameId.entryId(), name).getName();\n pkg.addEntry(nameId.typeId(), nameId.entryId(), ResAttribute.DEFAULT);\n } catch (AndrolibException ex) {\n if (mFirstError == null) {\n mFirstError = ex;\n }\n Log.w(TAG, \"Could not add missing attr: ns=%s, name=%s, id=%s\",\n getAttributePrefix(index), name, nameId);\n }\n }\n\n return name;\n }\n\n @Override\n public String getAttributePrefix(int index) {\n if (mStringPool == null) {\n return \"\";\n }\n Attribute attr = getAttribute(index);\n if (attr == null || attr.ns < 0) {\n return \"\";\n }\n int prefixIdx = mNamespaces.findPrefix(attr.ns);\n String prefix = mStringPool.getString(prefixIdx);\n if (prefix == null) {\n return \"\";\n }\n return prefix;\n }\n\n @Override\n public String getAttributeType(int index) {\n return \"CDATA\";\n }\n\n @Override\n public boolean isAttributeDefault(int index) {\n return false;\n }\n\n @Override\n public String getAttributeValue(int index) {\n Attribute attr = getAttribute(index);\n if (attr == null) {\n return \"\";\n }\n\n // Use the raw value if preserved (rare for modern apps).\n if (mHasRawValues && !mIgnoreRawValues) {\n String rawValue = mStringPool != null ? mStringPool.getString(attr.rawValue) : null;\n if (rawValue != null) {\n return rawValue;\n }\n }\n\n // Try to decode the typed value from the resource table.\n ResItem value = null;\n String name = null;\n String decoded = null;\n try {\n ResPackage pkg = mTable.getMainPackage();\n if (pkg == null) {\n // If no main package, we load \"android\" package instead.\n pkg = mTable.resolvePackageGroup(1).getBasePackage();\n }\n\n if (attr.valueType == ResValue.TYPE_STRING) {\n CharSequence strValue = mStringPool != null ? mStringPool.getText(attr.valueData) : null;\n value = strValue != null ? new ResString(strValue) : null;\n } else {\n value = ResItem.parse(pkg, attr.valueType, attr.valueData);\n }\n\n if (value != null) {\n ResId nameId = getAttributeNameResourceId(index);\n if (nameId != ResId.NULL) {\n // We need the attribute entry's value to format this value.\n try {\n ResEntry nameEntry = mTable.resolveEntry(nameId);\n name = nameEntry.getName();\n if (nameEntry.getValue() instanceof ResAttribute) {\n ResAttribute nameValue = (ResAttribute) nameEntry.getValue();\n\n // Add the value type to the attribute if needed.\n boolean isExplicitType;\n switch (attr.valueType) {\n case ResValue.TYPE_NULL:\n case ResValue.TYPE_REFERENCE:\n case ResValue.TYPE_DYNAMIC_REFERENCE:\n case ResValue.TYPE_ATTRIBUTE:\n case ResValue.TYPE_DYNAMIC_ATTRIBUTE:\n isExplicitType = false;\n break;\n default:\n isExplicitType = true;\n break;\n }\n if (isExplicitType && !nameValue.hasSymbolsForValue(value)) {\n nameValue.addValueType(attr.valueType);\n }\n\n decoded = nameValue.formatAsAttributeValue(value);\n } else {\n Log.w(TAG, \"Unexpected attribute name: \" + nameEntry);\n }\n } catch (UndefinedResObjectException ignored) {\n }\n } else {\n // Format the value with the default attribute.\n decoded = ResAttribute.DEFAULT.formatAsAttributeValue(value);\n }\n }\n } catch (AndrolibException ex) {\n if (mFirstError == null) {\n mFirstError = ex;\n }\n }\n\n if (decoded == null) {\n if (name == null) {\n name = mStringPool != null ? mStringPool.getString(attr.name) : null;\n }\n\n Log.w(TAG, \"Could not decode attribute value: ns=%s, name=%s, type=0x%02x, value=0x%08x\",\n getAttributePrefix(index), name, attr.valueType, attr.valueData);\n\n if (value != null) {\n // Format the value with the default attribute.\n try {\n decoded = ResAttribute.DEFAULT.formatAsAttributeValue(value);\n } catch (AndrolibException ignored) {\n }\n }\n if (decoded == null) {\n decoded = \"\";\n }\n }\n\n return decoded;\n }\n\n @Override\n public String getAttributeValue(String namespace, String name) {\n if (mEventType != START_TAG) {\n throw new IndexOutOfBoundsException(\"Parser must be on START_TAG to get attributes.\");\n }\n if (mAttributes == null || mStringPool == null || name == null) {\n return \"\";\n }\n int uriIdx = mStringPool.findString(namespace);\n int nameIdx = mStringPool.findString(name);\n for (int i = 0; i < mAttributes.length; i++) {\n Attribute attr = mAttributes[i];\n if (attr != null && uriIdx == attr.ns && nameIdx == attr.name) {\n return getAttributeValue(i);\n }\n }\n return \"\";\n }\n\n @Override\n public int getEventType() {\n return mEventType;\n }\n\n @Override\n public int next() throws XmlPullParserException, IOException {\n if (mIn == null) {\n throw new XmlPullParserException(\"Parser is not opened.\", this, null);\n }\n try {\n return doNext();\n } catch (IOException ex) {\n reset();\n throw ex;\n }\n }\n\n @Override\n public int nextToken() throws XmlPullParserException, IOException {\n return next();\n }\n\n @Override\n public void require(int type, String namespace, String name) throws XmlPullParserException {\n if (type != mEventType || (namespace != null && !namespace.equals(getNamespace()))\n || (name != null && !name.equals(getName()))) {\n throw new XmlPullParserException(TYPES[type] + \" is expected.\", this, null);\n }\n }\n\n @Override\n public String nextText() throws XmlPullParserException, IOException {\n if (mEventType != START_TAG) {\n throw new XmlPullParserException(\"Parser must be on START_TAG to read next text.\", this, null);\n }\n int eventType = next();\n if (eventType == END_TAG) {\n return \"\";\n }\n if (eventType != TEXT) {\n throw new XmlPullParserException(\"Parser must be on TEXT or END_TAG to read text.\", this, null);\n }\n String result = getText();\n eventType = next();\n if (eventType != END_TAG) {\n throw new XmlPullParserException(\"Event TEXT must be immediately followed by END_TAG.\", this, null);\n }\n return result;\n }\n\n @Override\n public int nextTag() throws XmlPullParserException, IOException {\n int eventType = next();\n if (eventType == TEXT && isWhitespace()) {\n eventType = next();\n }\n if (eventType != START_TAG && eventType != END_TAG) {\n throw new XmlPullParserException(\"Expected start or end tag.\", this, null);\n }\n return eventType;\n }\n\n // Utility methods\n\n private String getNonDefaultNamespaceUri(int pos) {\n String prefix = getNamespacePrefix(pos);\n if (prefix == null) {\n // If we are here, there is some clever obfuscation going on.\n // Our reference points to the namespace are gone. We have the namespaces that can't be touched in the\n // opening tag, though no known way to correlate them at this time, so return the res-auto namespace.\n return ResXmlUtils.ANDROID_RES_NS_AUTO;\n }\n return getNamespaceUri(pos);\n }\n\n private Attribute getAttribute(int index) {\n if (mEventType != START_TAG) {\n throw new IndexOutOfBoundsException(\"Parser must be on START_TAG to get attributes.\");\n }\n if (mAttributes == null || index < 0 || index >= mAttributes.length) {\n throw new IndexOutOfBoundsException(\n String.format(\"Attribute index out of range: index=%s, length=%s\",\n index, mAttributes != null ? mAttributes.length : 0));\n }\n return mAttributes[index];\n }\n\n private ResId getAttributeNameResourceId(int index) {\n if (mResourceMap == null) {\n return ResId.NULL;\n }\n Attribute attr = getAttribute(index);\n if (attr == null || attr.name < 0 || attr.name >= mResourceMap.length) {\n return ResId.NULL;\n }\n return mResourceMap[attr.name];\n }\n\n private void reset() {\n mIn = null;\n mParser = null;\n mStringPool = null;\n mResourceMap = null;\n resetEventInfo();\n mNamespaces.reset();\n }\n\n private void resetEventInfo() {\n mEventType = START_DOCUMENT;\n mLineNumber = -1;\n mNamespaceIndex = -1;\n mNameIndex = -1;\n mIdIndex = -1;\n mClassIndex = -1;\n mStyleIndex = -1;\n mAttributes = null;\n }\n\n private boolean nextChunk() throws IOException {\n // Skip padding or unknown data at the end of current chunk.\n if (mParser.isChunk()) {\n int skipped = mParser.skipChunk();\n if (skipped > 0) {\n Log.d(TAG, \"Skipped unknown %s bytes at end of %s chunk.\", skipped, mParser.chunkName());\n }\n }\n\n // Reset previous event data.\n int lastEventType = mEventType;\n if (lastEventType != -1) {\n resetEventInfo();\n }\n\n // Stop if all root-level namespaces were popped.\n if (lastEventType == END_TAG && mNamespaces.getDepth() == 0\n && mNamespaces.getCurrentCount() == 0) {\n return false;\n }\n\n // Parse next chunk.\n while (mParser.next()) {\n // Skip unknown or unsupported chunks.\n if (mParser.chunkType() == ResChunkHeader.RES_NULL_TYPE) {\n Log.d(TAG, \"Skipping unknown chunk (%s) of %s bytes at 0x%08x.\",\n mParser.chunkName(), mParser.chunkSize(), mParser.chunkStart());\n mParser.skipChunk();\n continue;\n }\n\n // Return this chunk.\n Log.d(TAG, \"Chunk at 0x%08x: %s (%s bytes)\",\n mParser.chunkStart(), mParser.chunkName(), mParser.chunkSize());\n return true;\n }\n\n // End of chunks.\n return false;\n }\n\n private int doNext() throws IOException {\n if (mEventType == END_DOCUMENT) {\n return END_DOCUMENT;\n }\n if (mEventType == END_TAG) {\n mNamespaces.decrementDepth();\n }\n\n while (nextChunk()) {\n switch (mParser.chunkType()) {\n case ResChunkHeader.RES_STRING_POOL_TYPE:\n mStringPool = ResStringPool.parse(mParser);\n continue;\n case ResChunkHeader.RES_XML_RESOURCE_MAP_TYPE:\n skipUnreadHeader();\n\n mResourceMap = new ResId[mParser.dataSize() / 4];\n for (int i = 0; i < mResourceMap.length; i++) {\n mResourceMap[i] = ResId.of(mIn.readInt());\n }\n continue;\n }\n\n if (mParser.chunkType() < ResChunkHeader.RES_XML_FIRST_CHUNK_TYPE\n || mParser.chunkType() > ResChunkHeader.RES_XML_LAST_CHUNK_TYPE) {\n skipUnexpectedChunk();\n continue;\n }\n\n // ResXMLTree_node\n mLineNumber = mIn.readInt();\n mIn.skipInt(); // comment\n\n switch (mParser.chunkType()) {\n case ResChunkHeader.RES_XML_START_NAMESPACE_TYPE: {\n // ResXMLTree_namespaceExt\n int prefix = mIn.readInt();\n int uri = mIn.readInt();\n\n skipUnreadHeader();\n\n mNamespaces.push(prefix, uri);\n continue;\n }\n case ResChunkHeader.RES_XML_END_NAMESPACE_TYPE:\n // ResXMLTree_namespaceExt\n mIn.skipInt(); // prefix\n mIn.skipInt(); // uri\n\n skipUnreadHeader();\n\n mNamespaces.pop();\n continue;\n case ResChunkHeader.RES_XML_START_ELEMENT_TYPE: {\n long startPosition = mIn.position();\n // ResXMLTree_attrExt\n mNamespaceIndex = mIn.readInt();\n mNameIndex = mIn.readInt();\n int attributeStart = mIn.readUnsignedShort();\n int attributeSize = mIn.readUnsignedShort();\n int attributeCount = mIn.readUnsignedShort();\n mIdIndex = mIn.readUnsignedShort();\n mClassIndex = mIn.readUnsignedShort();\n mStyleIndex = mIn.readUnsignedShort();\n\n skipUnreadHeader();\n\n // Align the stream with the start of the attributes.\n mIn.jumpTo(startPosition + attributeStart);\n\n mAttributes = new Attribute[attributeCount];\n for (int i = 0; i < attributeCount; i++) {\n Attribute attr = Attribute.read(mIn);\n\n if (attributeSize > Attribute.SIZE) {\n int skipped = mIn.skipBytes(attributeSize - Attribute.SIZE);\n Log.d(TAG, \"Skipped unknown %s bytes in attribute.\", skipped);\n }\n\n // Check if the app preserved raw attribute values.\n if (attr.valueType == ResValue.TYPE_STRING\n ? attr.valueData != attr.rawValue : attr.rawValue >= 0) {\n mHasRawValues = true;\n }\n\n mAttributes[i] = attr;\n }\n\n mNamespaces.incrementDepth();\n return mEventType = START_TAG;\n }\n case ResChunkHeader.RES_XML_END_ELEMENT_TYPE:\n // ResXMLTree_endElementExt\n mNamespaceIndex = mIn.readInt();\n mNameIndex = mIn.readInt();\n\n skipUnreadHeader();\n return mEventType = END_TAG;\n case ResChunkHeader.RES_XML_CDATA_TYPE:\n // ResXMLTree_cdataExt\n mNameIndex = mIn.readInt();\n mIn.skipInt(); // size, res0, type\n mIn.skipInt(); // data\n\n skipUnreadHeader();\n return mEventType = TEXT;\n default:\n skipUnexpectedChunk();\n continue;\n }\n }\n\n Log.d(TAG, \"End of chunks at 0x%08x\", mIn.position());\n\n if (mIn.available() > 0) {\n Log.d(TAG, \"Ignoring trailing data at 0x%08x.\", mIn.position());\n }\n\n return mEventType = END_DOCUMENT;\n }\n\n private void skipUnexpectedChunk() throws IOException {\n Log.w(TAG, \"Skipping unexpected %s chunk of %s bytes at 0x%08x.\",\n mParser.chunkName(), mParser.chunkSize(), mParser.chunkStart());\n mParser.skipChunk();\n }\n\n private void skipUnreadHeader() throws IOException {\n // Some apps lie about the reported size of their chunk header. Trusting the header size is misleading,\n // so compare to what we actually read in the header vs reported and skip the rest.\n int bytesRead = (int) (mIn.position() - mParser.chunkStart());\n readExceedingBytes(\"Chunk header\", mParser.headerSize(), bytesRead);\n }\n\n private byte[] readExceedingBytes(String name, int size, int bytesRead) throws IOException {\n int bytesExceeding = size - bytesRead;\n if (bytesExceeding > 0) {\n byte[] buf = mIn.readBytes(bytesExceeding);\n for (int i = 0; i < buf.length; i++) {\n if (buf[i] != 0) {\n Log.w(TAG, \"%s size: %s bytes, read: %s bytes. Exceeding bytes: %s\",\n name, size, bytesRead, BaseEncoding.base16().encode(buf));\n return buf;\n }\n }\n }\n return null;\n }\n\n private static final class NamespaceStack {\n private static final int INITIAL_CAPACITY = 32;\n\n private int[] mData;\n private int mDataLength;\n private int mDepth;\n\n public NamespaceStack() {\n mData = new int[INITIAL_CAPACITY];\n reset();\n }\n\n public void reset() {\n mDataLength = 0;\n mDepth = -1;\n incrementDepth();\n }\n\n public int getDepth() {\n return mDepth;\n }\n\n public void incrementDepth() {\n ensureCapacity();\n int offset = mDataLength;\n mData[offset] = 0;\n mData[offset + 1] = 0;\n mDataLength += 2;\n mDepth++;\n }\n\n private void ensureCapacity() {\n if (mData.length - mDataLength >= 2) {\n return;\n }\n int[] newData = new int[mData.length + INITIAL_CAPACITY];\n System.arraycopy(mData, 0, newData, 0, mDataLength);\n mData = newData;\n }\n\n public void decrementDepth() {\n if (mDataLength == 0) {\n return;\n }\n int offset = mDataLength - 1;\n int count = mData[offset];\n mDataLength -= (2 + count * 2);\n mDepth--;\n }\n\n public int getCount(int depth) {\n if (mDataLength == 0 || depth <= 0) {\n return 0;\n }\n if (depth > mDepth) {\n depth = mDepth;\n }\n int total = 0;\n int offset = 0;\n for (; depth > 0; --depth) {\n int count = mData[offset];\n total += count;\n offset += (2 + count * 2);\n }\n return total;\n }\n\n public int getCurrentCount() {\n if (mDataLength == 0) {\n return 0;\n }\n int offset = mDataLength - 1;\n return mData[offset];\n }\n\n public void push(int prefix, int uri) {\n ensureCapacity();\n int offset = mDataLength - 1;\n int count = mData[offset];\n mData[offset - 1 - count * 2] = count + 1;\n mData[offset] = prefix;\n mData[offset + 1] = uri;\n mData[offset + 2] = count + 1;\n mDataLength += 2;\n }\n\n public boolean pop() {\n if (mDataLength == 0) {\n return false;\n }\n int offset = mDataLength - 1;\n int count = mData[offset];\n if (count == 0) {\n return false;\n }\n count--;\n offset -= 2;\n mData[offset] = count;\n offset -= (1 + count * 2);\n mData[offset] = count;\n mDataLength -= 2;\n return true;\n }\n\n public int getPrefix(int index) {\n return get(index, true);\n }\n\n public int getUri(int index) {\n return get(index, false);\n }\n\n private int get(int index, boolean isPrefix) {\n if (mDataLength == 0 || index < 0) {\n return -1;\n }\n int offset = 0;\n for (int i = mDepth; i >= 0; i--) {\n int count = mData[offset];\n if (index >= count) {\n index -= count;\n offset += (2 + count * 2);\n continue;\n }\n offset += (1 + index * 2);\n if (!isPrefix) {\n offset++;\n }\n return mData[offset];\n }\n return -1;\n }\n\n public int findPrefix(int uri) {\n return find(uri, true);\n }\n\n public int findUri(int prefix) {\n return find(prefix, false);\n }\n\n private int find(int prefixOrUri, boolean isPrefix) {\n if (mDataLength == 0) {\n return -1;\n }\n int offset = mDataLength - 1;\n for (int i = mDepth; i >= 0; i--) {\n int count = mData[offset];\n offset -= 2;\n for (; count > 0; --count) {\n if (isPrefix) {\n if (mData[offset + 1] == prefixOrUri) {\n return mData[offset];\n }\n } else {\n if (mData[offset] == prefixOrUri) {\n return mData[offset + 1];\n }\n }\n offset -= 2;\n }\n }\n return -1;\n }\n }\n\n private static final class Attribute {\n public static final int SIZE = 20;\n\n public final int ns;\n public final int name;\n public final int rawValue;\n public final int valueType;\n public final int valueData;\n\n public Attribute(int ns, int name, int rawValue, int valueType, int valueData) {\n this.ns = ns;\n this.name = name;\n this.rawValue = rawValue;\n this.valueType = valueType;\n this.valueData = valueData;\n }\n\n public static Attribute read(BinaryDataInputStream in) throws IOException {\n // ResXMLTree_attribute\n int ns = in.readInt();\n int name = in.readInt();\n int rawValue = in.readInt();\n // Res_value\n int valueSize = in.readUnsignedShort();\n if (valueSize < 8) {\n return null;\n }\n in.skipByte(); // res0\n int valueType = in.readUnsignedByte();\n int valueData = in.readInt();\n\n return new Attribute(ns, name, rawValue, valueType, valueData);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ManifestPullEventHandler.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.meta.ResourcesInfo;\nimport brut.androlib.meta.SdkInfo;\nimport brut.androlib.meta.VersionInfo;\nimport brut.androlib.res.xml.ResXmlUtils;\nimport brut.xmlpull.XmlPullUtils;\nimport org.xmlpull.v1.XmlPullParser;\nimport org.xmlpull.v1.XmlPullParserException;\nimport org.xmlpull.v1.XmlSerializer;\n\npublic class ManifestPullEventHandler implements XmlPullUtils.EventHandler {\n private final ApkInfo mApkInfo;\n private final boolean mHideSdkInfo;\n\n public ManifestPullEventHandler(ApkInfo apkInfo, boolean hideSdkInfo) {\n mApkInfo = apkInfo;\n mHideSdkInfo = hideSdkInfo;\n }\n\n @Override\n public boolean onEvent(XmlPullParser in, XmlSerializer out) throws XmlPullParserException {\n int type = in.getEventType();\n\n if (type == XmlPullParser.START_TAG) {\n String name = in.getName();\n\n if (name.equals(\"manifest\")) {\n parseManifest(in);\n } else if (name.equals(\"uses-sdk\")) {\n parseUsesSdk(in);\n\n if (mHideSdkInfo) {\n return true;\n }\n }\n } else if (type == XmlPullParser.END_TAG) {\n String name = in.getName();\n\n if (name.equals(\"uses-sdk\")) {\n if (mHideSdkInfo) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n private void parseManifest(XmlPullParser in) {\n ResourcesInfo resourcesInfo = mApkInfo.getResourcesInfo();\n VersionInfo versionInfo = mApkInfo.getVersionInfo();\n\n for (int i = 0; i < in.getAttributeCount(); i++) {\n String ns = in.getAttributeNamespace(i);\n String name = in.getAttributeName(i);\n String value = in.getAttributeValue(i);\n\n if (value.isEmpty()) {\n continue;\n }\n if (ns.isEmpty()) {\n if (name.equals(\"package\")) {\n // This is temporary and will be compared to actual resources package later.\n resourcesInfo.setPackageName(value);\n }\n } else if (ns.equals(ResXmlUtils.ANDROID_RES_NS)) {\n switch (name) {\n case \"versionCode\":\n versionInfo.setVersionCode(Integer.parseInt(value));\n break;\n case \"versionName\":\n versionInfo.setVersionName(value);\n break;\n }\n }\n }\n }\n\n private void parseUsesSdk(XmlPullParser in) {\n SdkInfo sdkInfo = mApkInfo.getSdkInfo();\n\n for (int i = 0; i < in.getAttributeCount(); i++) {\n String ns = in.getAttributeNamespace(i);\n String name = in.getAttributeName(i);\n String value = in.getAttributeValue(i);\n\n if (value.isEmpty()) {\n continue;\n }\n if (ns.equals(ResXmlUtils.ANDROID_RES_NS)) {\n switch (name) {\n case \"minSdkVersion\":\n sdkInfo.setMinSdkVersion(value);\n break;\n case \"targetSdkVersion\":\n sdkInfo.setTargetSdkVersion(value);\n break;\n case \"maxSdkVersion\":\n sdkInfo.setMaxSdkVersion(value);\n break;\n }\n }\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.res.data.ResChunkHeader;\nimport brut.util.BinaryDataInputStream;\n\nimport java.io.EOFException;\nimport java.io.IOException;\nimport java.nio.ByteOrder;\n\npublic class ResChunkPullParser {\n private static final long OFFSET_ENDED = -1;\n\n private final BinaryDataInputStream mIn;\n private final long mOffset;\n private final int mSize;\n private long mChunkOffset;\n private ResChunkHeader mChunkHeader;\n\n public ResChunkPullParser(BinaryDataInputStream in) {\n this(in, Integer.MAX_VALUE);\n }\n\n public ResChunkPullParser(BinaryDataInputStream in, int size) {\n assert in.order() == ByteOrder.LITTLE_ENDIAN;\n mIn = in;\n mOffset = in.position();\n mSize = size;\n }\n\n public BinaryDataInputStream stream() {\n return mIn;\n }\n\n public boolean isChunk() {\n return mChunkHeader != null;\n }\n\n public long chunkStart() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkOffset;\n }\n\n public int chunkType() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkHeader.type;\n }\n\n public String chunkName() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return ResChunkHeader.nameOf(mChunkHeader.type);\n }\n\n public int chunkSize() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkHeader.size;\n }\n\n public long chunkEnd() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkOffset + mChunkHeader.size;\n }\n\n public int headerSize() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkHeader.headerSize;\n }\n\n public long headerEnd() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkOffset + mChunkHeader.headerSize;\n }\n\n public int dataSize() {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n return mChunkHeader.size - mChunkHeader.headerSize;\n }\n\n public boolean next() throws IOException {\n if (mChunkOffset == OFFSET_ENDED) {\n return false;\n }\n\n // Jump to the next chunk.\n if (mChunkHeader != null) {\n skipChunk();\n mChunkHeader = null;\n }\n\n if (mIn.position() >= mOffset + mSize) {\n // End of chunks due to size limit.\n mChunkOffset = OFFSET_ENDED;\n return false;\n }\n\n // Read the chunk header at the current position.\n try {\n mChunkOffset = mIn.position();\n ResChunkHeader chunkHeader = ResChunkHeader.read(mIn);\n\n if (chunkHeader.headerSize < ResChunkHeader.SIZE\n || chunkHeader.size < chunkHeader.headerSize) {\n throw new IOException(\n String.format(\"Invalid chunk header: type=0x%04x, headerSize=%s, size=%s\",\n chunkHeader.type, chunkHeader.headerSize, chunkHeader.size));\n }\n\n mChunkHeader = chunkHeader;\n return true;\n } catch (EOFException ignored) {\n // End of chunks due to end of stream.\n mChunkOffset = OFFSET_ENDED;\n return false;\n } catch (IOException ex) {\n throw new IOException(\"Error while reading chunk header.\", ex);\n }\n }\n\n public int skipChunk() throws IOException {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n try {\n long position = mIn.position();\n long chunkEnd = chunkEnd();\n if (position == chunkEnd) {\n return 0;\n }\n if (position > chunkEnd) {\n throw new IOException(\"Stream advanced past chunk end.\");\n }\n return mIn.skipBytes((int) (chunkEnd - position));\n } catch (EOFException ignored) {\n throw new EOFException(\"Unexpected EOF while skipping chunk.\");\n } catch (IOException ex) {\n throw new IOException(\"Error while skipping chunk.\", ex);\n }\n }\n\n public int skipHeader() throws IOException {\n if (mChunkHeader == null) {\n throw new IllegalStateException();\n }\n try {\n long position = mIn.position();\n long headerEnd = headerEnd();\n if (position == headerEnd) {\n return 0;\n }\n if (position > headerEnd) {\n throw new IOException(\"Stream advanced past chunk header end.\");\n }\n return mIn.skipBytes((int) (headerEnd - position));\n } catch (EOFException ignored) {\n throw new EOFException(\"Unexpected EOF while skipping chunk header.\");\n } catch (IOException ex) {\n throw new IOException(\"Error while skipping chunk header.\", ex);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.NinePatchNotFoundException;\nimport brut.androlib.exceptions.RawXmlEncounteredException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.value.ResFileReference;\nimport brut.androlib.res.table.value.ResPrimitive;\nimport brut.androlib.res.table.value.ResString;\nimport brut.common.Log;\nimport brut.directory.Directory;\nimport brut.directory.DirectoryException;\nimport org.apache.commons.io.FilenameUtils;\n\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.util.Map;\n\npublic class ResFileDecoder {\n private static final String TAG = ResFileDecoder.class.getName();\n\n public enum Type { UNKNOWN, BINARY_XML, PNG_9PATCH }\n\n private final Map mDecoders;\n\n public ResFileDecoder(Map decoders) {\n mDecoders = decoders;\n }\n\n public void decode(ResEntry entry, Directory inDir, Directory outDir, Map resFileMap) {\n String inFileName = ((ResFileReference) entry.getValue()).getPath();\n\n // Some apps have string values where they shouldn't be.\n // We assumed that they are file references, but if no such file then fall back to a string value.\n if (!inDir.containsFile(inFileName)) {\n entry.setValue(new ResString(inFileName));\n return;\n }\n\n // Get input file extension.\n String ext = inFileName.endsWith(\".9.png\") ? \"9.png\" : FilenameUtils.getExtension(inFileName).toLowerCase();\n\n // Use aapt2-like logic to determine which decoder to use.\n // TODO: Determine by magic bytes and fill in stripped extensions?\n Type type = Type.UNKNOWN;\n if (!ext.isEmpty() && !entry.getType().getName().equals(\"raw\")) {\n switch (ext) {\n case \"xml\":\n case \"xsd\":\n type = Type.BINARY_XML;\n break;\n case \"9.png\":\n type = Type.PNG_9PATCH;\n break;\n }\n }\n\n // Generate output file name from entry.\n String outFileName = \"res/\" + entry.getType().getName() + entry.getType().getConfig().toQualifiers()\n + \"/\" + entry.getName() + (ext.isEmpty() ? \"\" : \".\" + ext);\n\n // Map input file name to output file name.\n resFileMap.put(inFileName, outFileName);\n\n Log.d(TAG, \"Decoding file \" + inFileName + \" to \" + outFileName);\n\n try {\n if (type != Type.UNKNOWN) {\n try {\n decode(type, inDir, inFileName, outDir, outFileName);\n return;\n } catch (RawXmlEncounteredException ignored) {\n // Assume the file is a raw XML.\n Log.d(TAG, \"Could not decode binary XML file: \" + inFileName);\n } catch (NinePatchNotFoundException ignored) {\n // Assume the file is a raw PNG.\n // Some apps contain unprocessed dummy 3x3 9-patch PNGs.\n // Extract them as-is, let aapt2 process them properly later.\n Log.d(TAG, \"Could not find 9-patch chunk in file: \" + inFileName);\n }\n }\n\n decode(Type.UNKNOWN, inDir, inFileName, outDir, outFileName);\n } catch (AndrolibException ignored) {\n Log.w(TAG, \"Could not decode file, replacing by NULL value: \" + inFileName);\n entry.setValue(ResPrimitive.NULL);\n }\n }\n\n private void decode(Type type, Directory inDir, String inFileName, Directory outDir, String outFileName)\n throws AndrolibException {\n ResStreamDecoder decoder = mDecoders.get(type);\n if (decoder == null) {\n throw new AndrolibException(\"Undefined decoder for type: \" + type);\n }\n\n boolean success = false;\n try (\n InputStream in = inDir.getFileInput(inFileName);\n OutputStream out = outDir.getFileOutput(outFileName)\n ) {\n decoder.decode(in, out);\n success = true;\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(ex);\n } finally {\n if (!success) {\n outDir.removeFile(outFileName);\n }\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResNinePatchStreamDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.NinePatchNotFoundException;\nimport brut.androlib.res.data.LayoutBounds;\nimport brut.androlib.res.data.NinePatchData;\nimport brut.util.BinaryDataInputStream;\nimport org.apache.commons.io.IOUtils;\n\nimport javax.imageio.ImageIO;\nimport java.awt.image.BufferedImage;\nimport java.awt.image.Raster;\nimport java.awt.image.WritableRaster;\nimport java.io.ByteArrayInputStream;\nimport java.io.EOFException;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.nio.ByteOrder;\n\npublic class ResNinePatchStreamDecoder implements ResStreamDecoder {\n\n @Override\n public void decode(InputStream in, OutputStream out) throws AndrolibException {\n try {\n byte[] data = IOUtils.toByteArray(in);\n if (data.length == 0) {\n return;\n }\n\n BufferedImage src = ImageIO.read(new ByteArrayInputStream(data));\n int w = src.getWidth(), h = src.getHeight();\n\n BufferedImage dst = new BufferedImage(w + 2, h + 2, BufferedImage.TYPE_INT_ARGB);\n if (src.getType() == BufferedImage.TYPE_CUSTOM) {\n Raster srcRaster = src.getRaster();\n WritableRaster dstRaster = dst.getRaster();\n int[] gray = null, alpha = null;\n for (int y = 0; y < src.getHeight(); y++) {\n gray = srcRaster.getSamples(0, y, w, 1, 0, gray);\n alpha = srcRaster.getSamples(0, y, w, 1, 1, alpha);\n\n dstRaster.setSamples(1, y + 1, w, 1, 0, gray);\n dstRaster.setSamples(1, y + 1, w, 1, 1, gray);\n dstRaster.setSamples(1, y + 1, w, 1, 2, gray);\n dstRaster.setSamples(1, y + 1, w, 1, 3, alpha);\n }\n } else {\n dst.createGraphics().drawImage(src, 1, 1, w, h, null);\n }\n\n NinePatchData np = findNinePatchData(data);\n drawHLine(dst, h + 1, np.paddingLeft + 1, w - np.paddingRight);\n drawVLine(dst, w + 1, np.paddingTop + 1, h - np.paddingBottom);\n\n int[] xDivs = np.xDivs;\n if (xDivs.length == 0) {\n drawHLine(dst, 0, 1, w);\n } else {\n for (int i = 0; i < xDivs.length; i += 2) {\n drawHLine(dst, 0, xDivs[i] + 1, xDivs[i + 1]);\n }\n }\n\n int[] yDivs = np.yDivs;\n if (yDivs.length == 0) {\n drawVLine(dst, 0, 1, h);\n } else {\n for (int i = 0; i < yDivs.length; i += 2) {\n drawVLine(dst, 0, yDivs[i] + 1, yDivs[i + 1]);\n }\n }\n\n // Some images optionally use optical inset/layout bounds.\n // https://developer.android.com/about/versions/android-4.3.html#OpticalBounds\n try {\n LayoutBounds lb = findLayoutBounds(data);\n for (int i = 0; i < lb.left; i++) {\n int x = 1 + i;\n dst.setRGB(x, h + 1, LayoutBounds.COLOR_TICK);\n }\n for (int i = 0; i < lb.right; i++) {\n int x = w - i;\n dst.setRGB(x, h + 1, LayoutBounds.COLOR_TICK);\n }\n for (int i = 0; i < lb.top; i++) {\n int y = 1 + i;\n dst.setRGB(w + 1, y, LayoutBounds.COLOR_TICK);\n }\n for (int i = 0; i < lb.bottom; i++) {\n int y = h - i;\n dst.setRGB(w + 1, y, LayoutBounds.COLOR_TICK);\n }\n } catch (NinePatchNotFoundException ignored) {\n // This chunk might not exist.\n }\n\n ImageIO.write(dst, \"png\", out);\n } catch (IOException | NullPointerException ex) {\n // The file is not a valid image.\n throw new AndrolibException(ex);\n }\n }\n\n private NinePatchData findNinePatchData(byte[] data) throws NinePatchNotFoundException, IOException {\n BinaryDataInputStream in = new BinaryDataInputStream(data, ByteOrder.BIG_ENDIAN);\n findChunk(in, NinePatchData.MAGIC);\n return NinePatchData.read(in);\n }\n\n private LayoutBounds findLayoutBounds(byte[] data) throws NinePatchNotFoundException, IOException {\n BinaryDataInputStream in = new BinaryDataInputStream(data, ByteOrder.BIG_ENDIAN);\n findChunk(in, LayoutBounds.MAGIC);\n return LayoutBounds.read(in);\n }\n\n private void findChunk(BinaryDataInputStream in, int magic) throws NinePatchNotFoundException, IOException {\n in.skipBytes(8);\n for (;;) {\n int size;\n try {\n size = in.readInt();\n } catch (EOFException ignored) {\n throw new NinePatchNotFoundException();\n }\n if (in.readInt() == magic) {\n return;\n }\n in.skipBytes(size + 4);\n }\n }\n\n private void drawHLine(BufferedImage im, int y, int x1, int x2) {\n for (int x = x1; x <= x2; x++) {\n im.setRGB(x, y, NinePatchData.COLOR_TICK);\n }\n }\n\n private void drawVLine(BufferedImage im, int x, int y1, int y2) {\n for (int y = y1; y <= y2; y++) {\n im.setRGB(x, y, NinePatchData.COLOR_TICK);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResRawStreamDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport org.apache.commons.io.IOUtils;\n\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.OutputStream;\n\npublic class ResRawStreamDecoder implements ResStreamDecoder {\n\n @Override\n public void decode(InputStream in, OutputStream out) throws AndrolibException {\n try {\n IOUtils.copy(in, out);\n } catch (IOException ex) {\n throw new AndrolibException(\"Could not decode raw stream.\", ex);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResStreamDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\n\nimport java.io.InputStream;\nimport java.io.OutputStream;\n\npublic interface ResStreamDecoder {\n void decode(InputStream in, OutputStream out) throws AndrolibException;\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResXmlPullStreamDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.RawXmlEncounteredException;\nimport brut.androlib.res.xml.ResXmlSerializer;\nimport brut.xmlpull.XmlPullUtils;\nimport org.xmlpull.v1.XmlPullParserException;\n\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.OutputStream;\n\npublic class ResXmlPullStreamDecoder implements ResStreamDecoder {\n private final BinaryXmlResourceParser mParser;\n private final ResXmlSerializer mSerial;\n private final XmlPullUtils.EventHandler mHandler;\n\n public ResXmlPullStreamDecoder(BinaryXmlResourceParser parser, ResXmlSerializer serial) {\n this(parser, serial, null);\n }\n\n public ResXmlPullStreamDecoder(BinaryXmlResourceParser parser, ResXmlSerializer serial,\n XmlPullUtils.EventHandler handler) {\n mParser = parser;\n mSerial = serial;\n mHandler = handler;\n }\n\n @Override\n public void decode(InputStream in, OutputStream out) throws AndrolibException {\n try {\n mParser.setInput(in, null);\n mSerial.setOutput(out, null);\n XmlPullUtils.copy(mParser, mSerial, mHandler);\n } catch (XmlPullParserException ex) {\n throw new RawXmlEncounteredException(ex);\n } catch (IOException ex) {\n throw new AndrolibException(ex);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResConfig.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport java.util.Arrays;\nimport java.util.Locale;\n\npublic class ResConfig {\n public static final int SDK_BASE = 1;\n public static final int SDK_BASE_1_1 = 2;\n public static final int SDK_CUPCAKE = 3;\n public static final int SDK_DONUT = 4;\n public static final int SDK_ECLAIR = 5;\n public static final int SDK_ECLAIR_0_1 = 6;\n public static final int SDK_ECLAIR_MR1 = 7;\n public static final int SDK_FROYO = 8;\n public static final int SDK_GINGERBREAD = 9;\n public static final int SDK_GINGERBREAD_MR1 = 10;\n public static final int SDK_HONEYCOMB = 11;\n public static final int SDK_HONEYCOMB_MR1 = 12;\n public static final int SDK_HONEYCOMB_MR2 = 13;\n public static final int SDK_ICE_CREAM_SANDWICH = 14;\n public static final int SDK_ICE_CREAM_SANDWICH_MR1 = 15;\n public static final int SDK_JELLY_BEAN = 16;\n public static final int SDK_JELLY_BEAN_MR1 = 17;\n public static final int SDK_JELLY_BEAN_MR2 = 18;\n public static final int SDK_KITKAT = 19;\n public static final int SDK_LOLLIPOP = 21;\n public static final int SDK_LOLLIPOP_MR1 = 22;\n public static final int SDK_MNC = 23;\n public static final int SDK_NOUGAT = 24;\n public static final int SDK_NOUGAT_MR1 = 25;\n public static final int SDK_OREO = 26;\n public static final int SDK_OREO_MR1 = 27;\n public static final int SDK_P = 28;\n public static final int SDK_Q = 29;\n public static final int SDK_R = 30;\n public static final int SDK_S = 31;\n public static final int SDK_S_V2 = 32;\n public static final int SDK_TIRAMISU = 33;\n public static final int SDK_UPSIDEDOWN_CAKE = 34;\n public static final int SDK_VANILLA_ICE_CREAM = 35;\n public static final int SDK_BAKLAVA = 36;\n\n // AOSP has this as 10,000 for dev purposes.\n // platform_frameworks_base/commit/c7a1109a1fe0771d4c9b572dcf178e2779fc4f2d\n public static final int SDK_DEVELOPMENT = 10000;\n\n public static final int MNC_ZERO = 0xFFFF;\n\n public static final int ORIENTATION_ANY = 0x00;\n public static final int ORIENTATION_PORT = 0x01;\n public static final int ORIENTATION_LAND = 0x02;\n public static final int ORIENTATION_SQUARE = 0x03;\n\n public static final int TOUCHSCREEN_ANY = 0x00;\n public static final int TOUCHSCREEN_NOTOUCH = 0x01;\n public static final int TOUCHSCREEN_STYLUS = 0x02;\n public static final int TOUCHSCREEN_FINGER = 0x03;\n\n public static final int DENSITY_DEFAULT = 0;\n public static final int DENSITY_LOW = 120;\n public static final int DENSITY_MEDIUM = 160;\n public static final int DENSITY_TV = 213;\n public static final int DENSITY_HIGH = 240;\n public static final int DENSITY_XHIGH = 320;\n public static final int DENSITY_XXHIGH = 480;\n public static final int DENSITY_XXXHIGH = 640;\n public static final int DENSITY_ANY = 0xFFFE;\n public static final int DENSITY_NONE = 0xFFFF;\n\n public static final int KEYBOARD_ANY = 0x00;\n public static final int KEYBOARD_NOKEYS = 0x01;\n public static final int KEYBOARD_QWERTY = 0x02;\n public static final int KEYBOARD_12KEY = 0x03;\n\n public static final int NAVIGATION_ANY = 0x00;\n public static final int NAVIGATION_NONAV = 0x01;\n public static final int NAVIGATION_DPAD = 0x02;\n public static final int NAVIGATION_TRACKBALL = 0x03;\n public static final int NAVIGATION_WHEEL = 0x04;\n\n public static final int MASK_KEYSHIDDEN = 0x03;\n public static final int KEYSHIDDEN_ANY = 0x00;\n public static final int KEYSHIDDEN_NO = 0x01;\n public static final int KEYSHIDDEN_YES = 0x02;\n public static final int KEYSHIDDEN_SOFT = 0x03;\n\n public static final int SHIFT_NAVHIDDEN = 2;\n public static final int MASK_NAVHIDDEN = 0x03 << SHIFT_NAVHIDDEN; // 0x0C\n public static final int NAVHIDDEN_ANY = 0x00 << SHIFT_NAVHIDDEN; // 0x00\n public static final int NAVHIDDEN_NO = 0x01 << SHIFT_NAVHIDDEN; // 0x04\n public static final int NAVHIDDEN_YES = 0x02 << SHIFT_NAVHIDDEN; // 0x08\n\n public static final int MASK_GRAMMATICAL_GENDER = 0x03;\n public static final int GRAMMATICAL_GENDER_ANY = 0x00;\n public static final int GRAMMATICAL_GENDER_NEUTER = 0x01;\n public static final int GRAMMATICAL_GENDER_FEMININE = 0x02;\n public static final int GRAMMATICAL_GENDER_MASCULINE = 0x03;\n\n public static final int MASK_SCREENSIZE = 0x0F;\n public static final int SCREENSIZE_ANY = 0x00;\n public static final int SCREENSIZE_SMALL = 0x01;\n public static final int SCREENSIZE_NORMAL = 0x02;\n public static final int SCREENSIZE_LARGE = 0x03;\n public static final int SCREENSIZE_XLARGE = 0x04;\n\n public static final int SHIFT_SCREENLONG = 4;\n public static final int MASK_SCREENLONG = 0x03 << SHIFT_SCREENLONG; // 0x30\n public static final int SCREENLONG_ANY = 0x00 << SHIFT_SCREENLONG; // 0x00\n public static final int SCREENLONG_NO = 0x01 << SHIFT_SCREENLONG; // 0x10\n public static final int SCREENLONG_YES = 0x02 << SHIFT_SCREENLONG; // 0x20\n\n public static final int SHIFT_LAYOUTDIR = 6;\n public static final int MASK_LAYOUTDIR = 0x03 << SHIFT_LAYOUTDIR; // 0xC0\n public static final int LAYOUTDIR_ANY = 0x00 << SHIFT_LAYOUTDIR; // 0x00\n public static final int LAYOUTDIR_LTR = 0x01 << SHIFT_LAYOUTDIR; // 0x40\n public static final int LAYOUTDIR_RTL = 0x02 << SHIFT_LAYOUTDIR; // 0x80\n\n public static final int MASK_UI_MODE_TYPE = 0x0F;\n public static final int UI_MODE_TYPE_ANY = 0x00;\n public static final int UI_MODE_TYPE_NORMAL = 0x01;\n public static final int UI_MODE_TYPE_DESK = 0x02;\n public static final int UI_MODE_TYPE_CAR = 0x03;\n public static final int UI_MODE_TYPE_TELEVISION = 0x04;\n public static final int UI_MODE_TYPE_APPLIANCE = 0x05;\n public static final int UI_MODE_TYPE_WATCH = 0x06;\n public static final int UI_MODE_TYPE_VR_HEADSET = 0x07;\n public static final int UI_MODE_TYPE_GODZILLAUI = 0x0B; // MIUI\n public static final int UI_MODE_TYPE_SMALLUI = 0x0C; // MIUI\n public static final int UI_MODE_TYPE_MEDIUMUI = 0x0D; // MIUI\n public static final int UI_MODE_TYPE_LARGEUI = 0x0E; // MIUI\n public static final int UI_MODE_TYPE_HUGEUI = 0x0F; // MIUI\n\n public static final int SHIFT_UI_MODE_NIGHT = 4;\n public static final int MASK_UI_MODE_NIGHT = 0x03 << SHIFT_UI_MODE_NIGHT; // 0x30\n public static final int UI_MODE_NIGHT_ANY = 0x00 << SHIFT_UI_MODE_NIGHT; // 0x00\n public static final int UI_MODE_NIGHT_NO = 0x01 << SHIFT_UI_MODE_NIGHT; // 0x10\n public static final int UI_MODE_NIGHT_YES = 0x02 << SHIFT_UI_MODE_NIGHT; // 0x20\n\n public static final int MASK_SCREENROUND = 0x03;\n public static final int SCREENROUND_ANY = 0x00;\n public static final int SCREENROUND_NO = 0x01;\n public static final int SCREENROUND_YES = 0x02;\n\n public static final int MASK_COLOR_MODE_WIDECG = 0x03;\n public static final int COLOR_MODE_WIDECG_ANY = 0x00;\n public static final int COLOR_MODE_WIDECG_NO = 0x01;\n public static final int COLOR_MODE_WIDECG_YES = 0x02;\n\n public static final int SHIFT_COLOR_MODE_HDR = 2;\n public static final int MASK_COLOR_MODE_HDR = 0x03 << SHIFT_COLOR_MODE_HDR; // 0x0C\n public static final int COLOR_MODE_HDR_ANY = 0x00 << SHIFT_COLOR_MODE_HDR; // 0x00\n public static final int COLOR_MODE_HDR_NO = 0x01 << SHIFT_COLOR_MODE_HDR; // 0x04\n public static final int COLOR_MODE_HDR_YES = 0x02 << SHIFT_COLOR_MODE_HDR; // 0x08\n\n public static final ResConfig DEFAULT = new ResConfig();\n\n private final int mMcc;\n private final int mMnc;\n private final String mLanguage;\n private final String mRegion;\n private final int mOrientation;\n private final int mTouchscreen;\n private final int mDensity;\n private final int mKeyboard;\n private final int mNavigation;\n private final int mInputFlags;\n private final int mGrammaticalInflection;\n private final int mScreenWidth;\n private final int mScreenHeight;\n private final int mSdkVersion;\n private final int mMinorVersion;\n private final int mScreenLayout;\n private final int mUiMode;\n private final int mSmallestScreenWidthDp;\n private final int mScreenWidthDp;\n private final int mScreenHeightDp;\n private final String mLocaleScript;\n private final String mLocaleVariant;\n private final int mScreenLayout2;\n private final int mColorMode;\n private final byte[] mUnknown;\n\n private final String mQualifiers;\n private final boolean mIsInvalid;\n\n private ResConfig() {\n mMcc = 0;\n mMnc = 0;\n mLanguage = \"\";\n mRegion = \"\";\n mOrientation = ORIENTATION_ANY;\n mTouchscreen = TOUCHSCREEN_ANY;\n mDensity = DENSITY_DEFAULT;\n mKeyboard = KEYBOARD_ANY;\n mNavigation = NAVIGATION_ANY;\n mInputFlags = KEYSHIDDEN_ANY | NAVHIDDEN_ANY;\n mGrammaticalInflection = GRAMMATICAL_GENDER_ANY;\n mScreenWidth = 0;\n mScreenHeight = 0;\n mSdkVersion = 0;\n mMinorVersion = 0;\n mScreenLayout = SCREENSIZE_ANY | SCREENLONG_ANY;\n mUiMode = UI_MODE_TYPE_ANY | UI_MODE_NIGHT_ANY;\n mSmallestScreenWidthDp = 0;\n mScreenWidthDp = 0;\n mScreenHeightDp = 0;\n mLocaleScript = \"\";\n mLocaleVariant = \"\";\n mScreenLayout2 = 0;\n mColorMode = COLOR_MODE_WIDECG_ANY | COLOR_MODE_HDR_ANY;\n mUnknown = null;\n mQualifiers = \"\";\n mIsInvalid = false;\n }\n\n public ResConfig(int mcc, int mnc, String language, String region, int orientation, int touchscreen, int density,\n int keyboard, int navigation, int inputFlags, int grammaticalInflection, int screenWidth,\n int screenHeight, int sdkVersion, int minorVersion, int screenLayout, int uiMode,\n int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp, String localeScript,\n String localeVariant, int screenLayout2, int colorMode, byte[] unknown) {\n mMcc = mcc;\n mMnc = mnc;\n mLanguage = language;\n mRegion = region;\n mOrientation = orientation;\n mTouchscreen = touchscreen;\n mDensity = density;\n mKeyboard = keyboard;\n mNavigation = navigation;\n mInputFlags = inputFlags;\n mGrammaticalInflection = grammaticalInflection;\n mScreenWidth = screenWidth;\n mScreenHeight = screenHeight;\n mSdkVersion = sdkVersion;\n mMinorVersion = minorVersion;\n mScreenLayout = screenLayout;\n mUiMode = uiMode;\n mSmallestScreenWidthDp = smallestScreenWidthDp;\n mScreenWidthDp = screenWidthDp;\n mScreenHeightDp = screenHeightDp;\n mLocaleScript = localeScript;\n mLocaleVariant = localeVariant;\n mScreenLayout2 = screenLayout2;\n mColorMode = colorMode;\n mUnknown = unknown;\n boolean[] isInvalid = new boolean[1];\n mQualifiers = computeQualifiers(isInvalid);\n mIsInvalid = isInvalid[0];\n }\n\n private String computeQualifiers(boolean[] isInvalid) {\n StringBuilder sb = new StringBuilder();\n if (mMcc != 0) {\n sb.append(\"-mcc\").append(String.format(Locale.ROOT, \"%03d\", mMcc));\n }\n if (mMnc != 0) {\n sb.append(\"-mnc\").append(String.format(Locale.ROOT, \"%02d\", mMnc == MNC_ZERO ? 0 : mMnc));\n }\n if (!mLanguage.isEmpty()) {\n if (mLocaleScript.isEmpty() && (mRegion.isEmpty() || mRegion.length() == 2) && mLocaleVariant.isEmpty()) {\n // Legacy format.\n sb.append('-').append(mLanguage);\n if (!mRegion.isEmpty()) {\n sb.append(\"-r\").append(mRegion);\n }\n } else {\n // Modified BCP 47 format.\n sb.append(\"-b+\");\n sb.append(mLanguage);\n if (!mLocaleScript.isEmpty()) {\n sb.append('+').append(mLocaleScript);\n }\n if (!mRegion.isEmpty()) {\n sb.append('+').append(mRegion);\n }\n if (!mLocaleVariant.isEmpty()) {\n sb.append('+').append(mLocaleVariant);\n }\n }\n }\n switch (mGrammaticalInflection & MASK_GRAMMATICAL_GENDER) {\n case GRAMMATICAL_GENDER_ANY:\n break;\n case GRAMMATICAL_GENDER_NEUTER:\n sb.append(\"-neuter\");\n break;\n case GRAMMATICAL_GENDER_FEMININE:\n sb.append(\"-feminine\");\n break;\n case GRAMMATICAL_GENDER_MASCULINE:\n sb.append(\"-masculine\");\n break;\n default:\n sb.append(\"-grammaticalGender=\").append(mGrammaticalInflection & MASK_GRAMMATICAL_GENDER);\n isInvalid[0] = true;\n break;\n }\n switch (mScreenLayout & MASK_LAYOUTDIR) {\n case LAYOUTDIR_ANY:\n break;\n case LAYOUTDIR_LTR:\n sb.append(\"-ldltr\");\n break;\n case LAYOUTDIR_RTL:\n sb.append(\"-ldrtl\");\n break;\n default:\n sb.append(\"-layoutDir=\").append(mScreenLayout & MASK_LAYOUTDIR);\n isInvalid[0] = true;\n break;\n }\n if (mSmallestScreenWidthDp != 0) {\n sb.append(\"-sw\").append(mSmallestScreenWidthDp).append(\"dp\");\n }\n if (mScreenWidthDp != 0) {\n sb.append(\"-w\").append(mScreenWidthDp).append(\"dp\");\n }\n if (mScreenHeightDp != 0) {\n sb.append(\"-h\").append(mScreenHeightDp).append(\"dp\");\n }\n switch (mScreenLayout & MASK_SCREENSIZE) {\n case SCREENSIZE_ANY:\n break;\n case SCREENSIZE_SMALL:\n sb.append(\"-small\");\n break;\n case SCREENSIZE_NORMAL:\n sb.append(\"-normal\");\n break;\n case SCREENSIZE_LARGE:\n sb.append(\"-large\");\n break;\n case SCREENSIZE_XLARGE:\n sb.append(\"-xlarge\");\n break;\n default:\n sb.append(\"-screenSize=\").append(mScreenLayout & MASK_SCREENSIZE);\n isInvalid[0] = true;\n break;\n }\n switch (mScreenLayout & MASK_SCREENLONG) {\n case SCREENLONG_ANY:\n break;\n case SCREENLONG_NO:\n sb.append(\"-notlong\");\n break;\n case SCREENLONG_YES:\n sb.append(\"-long\");\n break;\n default:\n sb.append(\"-screenLong=\").append(mScreenLayout & MASK_SCREENLONG);\n isInvalid[0] = true;\n break;\n }\n switch (mScreenLayout2 & MASK_SCREENROUND) {\n case SCREENROUND_ANY:\n break;\n case SCREENROUND_NO:\n sb.append(\"-notround\");\n break;\n case SCREENROUND_YES:\n sb.append(\"-round\");\n break;\n default:\n sb.append(\"-screenRound=\").append(mScreenLayout2 & MASK_SCREENROUND);\n isInvalid[0] = true;\n break;\n }\n switch (mColorMode & MASK_COLOR_MODE_WIDECG) {\n case COLOR_MODE_WIDECG_ANY:\n break;\n case COLOR_MODE_WIDECG_NO:\n sb.append(\"-nowidecg\");\n break;\n case COLOR_MODE_WIDECG_YES:\n sb.append(\"-widecg\");\n break;\n default:\n sb.append(\"-colorModeWideCG=\").append(mColorMode & MASK_COLOR_MODE_WIDECG);\n isInvalid[0] = true;\n break;\n }\n switch (mColorMode & MASK_COLOR_MODE_HDR) {\n case COLOR_MODE_HDR_ANY:\n break;\n case COLOR_MODE_HDR_NO:\n sb.append(\"-lowdr\");\n break;\n case COLOR_MODE_HDR_YES:\n sb.append(\"-highdr\");\n break;\n default:\n sb.append(\"-colorModeHdr=\").append(mColorMode & MASK_COLOR_MODE_HDR);\n isInvalid[0] = true;\n break;\n }\n switch (mOrientation) {\n case ORIENTATION_ANY:\n break;\n case ORIENTATION_PORT:\n sb.append(\"-port\");\n break;\n case ORIENTATION_LAND:\n sb.append(\"-land\");\n break;\n case ORIENTATION_SQUARE:\n sb.append(\"-square\");\n break;\n default:\n sb.append(\"-orientation=\").append(mOrientation);\n isInvalid[0] = true;\n break;\n }\n switch (mUiMode & MASK_UI_MODE_TYPE) {\n case UI_MODE_TYPE_ANY:\n case UI_MODE_TYPE_NORMAL:\n break;\n case UI_MODE_TYPE_DESK:\n sb.append(\"-desk\");\n break;\n case UI_MODE_TYPE_CAR:\n sb.append(\"-car\");\n break;\n case UI_MODE_TYPE_TELEVISION:\n sb.append(\"-television\");\n break;\n case UI_MODE_TYPE_APPLIANCE:\n sb.append(\"-appliance\");\n break;\n case UI_MODE_TYPE_WATCH:\n sb.append(\"-watch\");\n break;\n case UI_MODE_TYPE_VR_HEADSET:\n sb.append(\"-vrheadset\");\n break;\n case UI_MODE_TYPE_GODZILLAUI:\n sb.append(\"-godzillaui\");\n break;\n case UI_MODE_TYPE_SMALLUI:\n sb.append(\"-smallui\");\n break;\n case UI_MODE_TYPE_MEDIUMUI:\n sb.append(\"-mediumui\");\n break;\n case UI_MODE_TYPE_LARGEUI:\n sb.append(\"-largeui\");\n break;\n case UI_MODE_TYPE_HUGEUI:\n sb.append(\"-hugeui\");\n break;\n default:\n sb.append(\"-uiModeType=\").append(mUiMode & MASK_UI_MODE_TYPE);\n isInvalid[0] = true;\n break;\n }\n switch (mUiMode & MASK_UI_MODE_NIGHT) {\n case UI_MODE_NIGHT_ANY:\n break;\n case UI_MODE_NIGHT_NO:\n sb.append(\"-notnight\");\n break;\n case UI_MODE_NIGHT_YES:\n sb.append(\"-night\");\n break;\n default:\n sb.append(\"-uiModeNight=\").append(mUiMode & MASK_UI_MODE_NIGHT);\n isInvalid[0] = true;\n break;\n }\n switch (mDensity) {\n case DENSITY_DEFAULT:\n break;\n case DENSITY_LOW:\n sb.append(\"-ldpi\");\n break;\n case DENSITY_MEDIUM:\n sb.append(\"-mdpi\");\n break;\n case DENSITY_TV:\n sb.append(\"-tvdpi\");\n break;\n case DENSITY_HIGH:\n sb.append(\"-hdpi\");\n break;\n case DENSITY_XHIGH:\n sb.append(\"-xhdpi\");\n break;\n case DENSITY_XXHIGH:\n sb.append(\"-xxhdpi\");\n break;\n case DENSITY_XXXHIGH:\n sb.append(\"-xxxhdpi\");\n break;\n case DENSITY_ANY:\n sb.append(\"-anydpi\");\n break;\n case DENSITY_NONE:\n sb.append(\"-nodpi\");\n break;\n default:\n sb.append('-').append(mDensity).append(\"dpi\");\n break;\n }\n switch (mTouchscreen) {\n case TOUCHSCREEN_ANY:\n break;\n case TOUCHSCREEN_NOTOUCH:\n sb.append(\"-notouch\");\n break;\n case TOUCHSCREEN_STYLUS:\n sb.append(\"-stylus\");\n break;\n case TOUCHSCREEN_FINGER:\n sb.append(\"-finger\");\n break;\n default:\n sb.append(\"-touchscreen=\").append(mTouchscreen);\n isInvalid[0] = true;\n break;\n }\n switch (mInputFlags & MASK_KEYSHIDDEN) {\n case KEYSHIDDEN_ANY:\n break;\n case KEYSHIDDEN_NO:\n sb.append(\"-keysexposed\");\n break;\n case KEYSHIDDEN_YES:\n sb.append(\"-keyshidden\");\n break;\n case KEYSHIDDEN_SOFT:\n sb.append(\"-keyssoft\");\n break;\n default:\n sb.append(\"-keysHidden=\").append(mInputFlags & MASK_KEYSHIDDEN);\n isInvalid[0] = true;\n break;\n }\n switch (mKeyboard) {\n case KEYBOARD_ANY:\n break;\n case KEYBOARD_NOKEYS:\n sb.append(\"-nokeys\");\n break;\n case KEYBOARD_QWERTY:\n sb.append(\"-qwerty\");\n break;\n case KEYBOARD_12KEY:\n sb.append(\"-12key\");\n break;\n default:\n sb.append(\"-keyboard=\").append(mKeyboard);\n isInvalid[0] = true;\n break;\n }\n switch (mInputFlags & MASK_NAVHIDDEN) {\n case NAVHIDDEN_ANY:\n break;\n case NAVHIDDEN_NO:\n sb.append(\"-navexposed\");\n break;\n case NAVHIDDEN_YES:\n sb.append(\"-navhidden\");\n break;\n default:\n sb.append(\"-navHidden=\").append(mInputFlags & MASK_NAVHIDDEN);\n isInvalid[0] = true;\n break;\n }\n switch (mNavigation) {\n case NAVIGATION_ANY:\n break;\n case NAVIGATION_NONAV:\n sb.append(\"-nonav\");\n break;\n case NAVIGATION_DPAD:\n sb.append(\"-dpad\");\n break;\n case NAVIGATION_TRACKBALL:\n sb.append(\"-trackball\");\n break;\n case NAVIGATION_WHEEL:\n sb.append(\"-wheel\");\n break;\n default:\n sb.append(\"-navigation=\").append(mNavigation);\n isInvalid[0] = true;\n break;\n }\n if (mScreenWidth != 0 && mScreenHeight != 0) {\n sb.append('-').append(mScreenWidth).append('x').append(mScreenHeight);\n }\n if (mSdkVersion != 0) {\n sb.append(\"-v\").append(mSdkVersion);\n }\n if (mUnknown != null) {\n // We have to separate unknown resources to avoid conflicts.\n sb.append(\"-unk\").append(String.format(\"%08X\", Arrays.hashCode(mUnknown)));\n isInvalid[0] = true;\n }\n return sb.toString();\n }\n\n public boolean isInvalid() {\n return mIsInvalid;\n }\n\n public String toQualifiers() {\n return mQualifiers;\n }\n\n @Override\n public String toString() {\n return \"[\" + (!mQualifiers.isEmpty() ? mQualifiers.substring(1) : \"DEFAULT\") + \"]\";\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResConfig) {\n ResConfig other = (ResConfig) obj;\n return mQualifiers.equals(other.mQualifiers);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return mQualifiers.hashCode();\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResEntry.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport brut.androlib.res.table.value.ResValue;\n\nimport java.util.Objects;\n\npublic class ResEntry {\n private final ResType mType;\n private final ResEntrySpec mSpec;\n private ResValue mValue; // might be updated later\n\n public ResEntry(ResType type, ResEntrySpec spec, ResValue value) {\n assert type != null && spec != null && type.getSpec() == spec.getTypeSpec() && value != null;\n mType = type;\n mSpec = spec;\n mValue = value;\n }\n\n public ResPackage getPackage() {\n return mType.getPackage();\n }\n\n public ResType getType() {\n return mType;\n }\n\n public ResEntrySpec getSpec() {\n return mSpec;\n }\n\n public int getId() {\n return mSpec.getId();\n }\n\n public ResId getResId() {\n return mSpec.getResId();\n }\n\n public String getName() {\n return mSpec.getName();\n }\n\n public ResValue getValue() {\n return mValue;\n }\n\n public void setValue(ResValue value) {\n mValue = value;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResEntry{type=%s, spec=%s, value=%s}\", mType, mSpec, mValue);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResEntry) {\n ResEntry other = (ResEntry) obj;\n return mType.equals(other.mType)\n && mSpec.equals(other.mSpec);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mType, mSpec);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResEntrySpec.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport java.util.Objects;\n\npublic class ResEntrySpec {\n public static final String DUMMY_PREFIX = \"APKTOOL_DUMMY_\";\n public static final String RENAMED_PREFIX = \"APKTOOL_RENAMED_\";\n\n private final ResTypeSpec mTypeSpec;\n private final int mId;\n private final ResId mResId;\n private final String mName;\n\n public ResEntrySpec(ResTypeSpec typeSpec, int id, String name) {\n assert typeSpec != null && id >= 0 && name != null;\n mTypeSpec = typeSpec;\n mId = id;\n mResId = ResId.of(typeSpec.getPackage().getId(), typeSpec.getId(), id);\n // Some apps had their entry names obfuscated or collapsed to a single value in the key string pool.\n mName = isValidEntryName(name) ? name : RENAMED_PREFIX + mResId;\n }\n\n private static boolean isValidEntryName(String name) {\n // Must not be empty.\n int len = name.length();\n if (len == 0) {\n return false;\n }\n // Must start with a valid Java identifier start character.\n if (!Character.isJavaIdentifierStart(name.charAt(0))) {\n return false;\n }\n // The rest must be valid Java identifier part characters or any of the whitelisted special characters.\n for (int i = 1; i < len; i++) {\n char ch = name.charAt(i);\n if (!Character.isJavaIdentifierPart(ch) && ch != '.' && ch != '-') {\n return false;\n }\n }\n return true;\n }\n\n public ResPackage getPackage() {\n return mTypeSpec.getPackage();\n }\n\n public ResTypeSpec getTypeSpec() {\n return mTypeSpec;\n }\n\n public int getId() {\n return mId;\n }\n\n public ResId getResId() {\n return mResId;\n }\n\n public String getName() {\n return mName;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResEntrySpec{typeSpec=%s, id=0x%04x, name=%s}\", mTypeSpec, mId, mName);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResEntrySpec) {\n ResEntrySpec other = (ResEntrySpec) obj;\n return mTypeSpec.equals(other.mTypeSpec)\n && mId == other.mId\n && mName.equals(other.mName);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mTypeSpec, mId, mName);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResId.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class ResId extends Number implements Comparable {\n public static final ResId NULL = new ResId(0);\n\n private static final Map sCache = new HashMap<>();\n\n private final int mId;\n\n private ResId(int id) {\n mId = id;\n }\n\n public static ResId of(int id) {\n return id != 0 ? sCache.computeIfAbsent(id, ResId::new) : NULL;\n }\n\n public static ResId of(int pkgId, int typeId, int entryId) {\n assert (pkgId & 0xFF) == pkgId && (typeId & 0xFF) == typeId && (entryId & 0xFFFF) == entryId;\n return of((pkgId << 24) | (typeId << 16) | entryId);\n }\n\n public int pkgId() {\n return (mId >>> 24) & 0xFF;\n }\n\n public int typeId() {\n return (mId >>> 16) & 0xFF;\n }\n\n public int entryId() {\n return mId & 0xFFFF;\n }\n\n @Override\n public int intValue() {\n return mId;\n }\n\n @Override\n public long longValue() {\n return mId;\n }\n\n @Override\n public float floatValue() {\n return mId;\n }\n\n @Override\n public double doubleValue() {\n return mId;\n }\n\n @Override\n public String toString() {\n return String.format(\"0x%08x\", mId);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResId) {\n ResId other = (ResId) obj;\n return mId == other.mId;\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Integer.hashCode(mId);\n }\n\n @Override\n public int compareTo(ResId other) {\n return Integer.compare(mId, other.mId);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResOverlayable.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport brut.androlib.exceptions.UndefinedResObjectException;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Objects;\nimport java.util.List;\n\npublic class ResOverlayable {\n private static final String TAG = ResOverlayable.class.getName();\n\n private static final int FLAG_NONE = 0;\n private static final int FLAG_PUBLIC = 1 << 0; // 0x0001\n private static final int FLAG_SYSTEM_PARTITION = 1 << 1; // 0x0002\n private static final int FLAG_VENDOR_PARTITION = 1 << 2; // 0x0004\n private static final int FLAG_PRODUCT_PARTITION = 1 << 3; // 0x0008\n private static final int FLAG_SIGNATURE = 1 << 4; // 0x0010\n private static final int FLAG_ODM_PARTITION = 1 << 5; // 0x0020\n private static final int FLAG_OEM_PARTITION = 1 << 6; // 0x0040\n private static final int FLAG_ACTOR_SIGNATURE = 1 << 7; // 0x0080\n private static final int FLAG_CONFIG_SIGNATURE = 1 << 8; // 0x0100\n\n private static final int[] FLAG_MASKS = {\n FLAG_PUBLIC, FLAG_SYSTEM_PARTITION, FLAG_VENDOR_PARTITION, FLAG_PRODUCT_PARTITION, FLAG_SIGNATURE,\n FLAG_ODM_PARTITION, FLAG_OEM_PARTITION, FLAG_ACTOR_SIGNATURE, FLAG_CONFIG_SIGNATURE\n };\n private static final String[] FLAG_NAMES = {\n \"public\", \"system\", \"vendor\", \"product\", \"signature\", \"odm\", \"oem\", \"actor\", \"config_signature\"\n };\n\n private final ResPackage mPackage;\n private final String mName;\n private final String mActor;\n private final List mPolicies;\n\n public ResOverlayable(ResPackage pkg, String name, String actor) {\n assert pkg != null && name != null && actor != null;\n mPackage = pkg;\n mName = name;\n mActor = actor;\n mPolicies = new ArrayList<>();\n }\n\n public ResPackage getPackage() {\n return mPackage;\n }\n\n public String getName() {\n return mName;\n }\n\n public String getActor() {\n return mActor;\n }\n\n public void addPolicy(int flags, ResId[] entries) {\n mPolicies.add(new Policy(flags, entries));\n }\n\n public void serializeToXml(XmlSerializer serial) throws IOException {\n if (mPolicies.isEmpty()) {\n return;\n }\n\n serial.startTag(null, \"overlayable\");\n serial.attribute(null, \"name\", mName);\n if (!mActor.isEmpty()) {\n serial.attribute(null, \"actor\", mActor);\n }\n\n for (Policy policy : mPolicies) {\n String type = renderType(policy.getFlags());\n ResEntrySpec[] entrySpecs = resolveEntries(policy.getEntries());\n if (type == null || entrySpecs == null) {\n continue;\n }\n\n serial.startTag(null, \"policy\");\n serial.attribute(null, \"type\", type);\n\n for (ResEntrySpec entrySpec : entrySpecs) {\n serial.startTag(null, \"item\");\n serial.attribute(null, \"type\", entrySpec.getTypeSpec().getName());\n serial.attribute(null, \"name\", entrySpec.getName());\n serial.endTag(null, \"item\");\n }\n\n serial.endTag(null, \"policy\");\n }\n\n serial.endTag(null, \"overlayable\");\n }\n\n private String renderType(int flags) {\n if (flags == FLAG_NONE) {\n return null;\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < FLAG_MASKS.length; i++) {\n if ((flags & FLAG_MASKS[i]) != 0) {\n if (sb.length() > 0) {\n sb.append('|');\n }\n sb.append(FLAG_NAMES[i]);\n }\n }\n if (sb.length() == 0) {\n return null;\n }\n return sb.toString();\n }\n\n private ResEntrySpec[] resolveEntries(ResId[] entries) {\n if (entries == null || entries.length == 0) {\n return null;\n }\n\n ResEntrySpec[] entrySpecs = new ResEntrySpec[entries.length];\n int entrySpecsCount = 0;\n\n for (int i = 0; i < entries.length; i++) {\n ResId resId = entries[i];\n if (resId == ResId.NULL) {\n continue;\n }\n\n ResEntrySpec entrySpec;\n try {\n entrySpec = mPackage.getEntrySpec(resId.typeId(), resId.entryId());\n } catch (UndefinedResObjectException ignored) {\n Log.w(TAG, \"Unresolved overlayable entry ID: \" + resId);\n continue;\n }\n\n entrySpecs[entrySpecsCount++] = entrySpec;\n }\n\n if (entrySpecsCount < entrySpecs.length) {\n entrySpecs = Arrays.copyOf(entrySpecs, entrySpecsCount);\n }\n\n return entrySpecs;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResOverlayable{pkg=%s, name=%s, actor=%s}\", mPackage, mName, mActor);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResOverlayable) {\n ResOverlayable other = (ResOverlayable) obj;\n return mPackage.equals(other.mPackage)\n && mName.equals(other.mName)\n && mActor.equals(other.mActor);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mPackage, mName, mActor);\n }\n\n private static class Policy {\n private final int mFlags;\n private final ResId[] mEntries;\n\n public Policy(int flags, ResId[] entries) {\n mFlags = flags;\n mEntries = entries;\n }\n\n public int getFlags() {\n return mFlags;\n }\n\n public ResId[] getEntries() {\n return mEntries;\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResPackage.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.UndefinedResObjectException;\nimport brut.androlib.res.table.value.ResValue;\nimport org.apache.commons.lang3.tuple.Pair;\n\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Objects;\nimport java.util.Set;\n\npublic class ResPackage {\n private final ResPackageGroup mGroup;\n private final int mIndex;\n private final Map mTypeSpecs;\n private final Map, ResType> mTypes;\n private final Map mEntrySpecs;\n private final Map, ResEntry> mEntries;\n private final Map mOverlayables;\n private final Map mAliases;\n private final Set mNameRegistry;\n\n public ResPackage(ResPackageGroup group, int index) {\n assert group != null && index >= 0;\n mGroup = group;\n mIndex = index;\n mTypeSpecs = new HashMap<>();\n mTypes = new HashMap<>();\n mEntrySpecs = new HashMap<>();\n mEntries = new HashMap<>();\n mOverlayables = new HashMap<>();\n mAliases = new HashMap<>();\n mNameRegistry = new HashSet<>();\n }\n\n public ResTable getTable() {\n return mGroup.getTable();\n }\n\n public ResPackageGroup getGroup() {\n return mGroup;\n }\n\n public int getId() {\n return mGroup.getId();\n }\n\n public String getName() {\n return mGroup.getName();\n }\n\n public int getIndex() {\n return mIndex;\n }\n\n public boolean hasTypeSpec(int typeId) {\n return mTypeSpecs.containsKey(typeId);\n }\n\n public ResTypeSpec getTypeSpec(int typeId) throws UndefinedResObjectException {\n ResTypeSpec typeSpec = mTypeSpecs.get(typeId);\n if (typeSpec == null) {\n throw new UndefinedResObjectException(\n String.format(\"type spec: pkgId=0x%02x, typeId=0x%02x\", getId(), typeId));\n }\n return typeSpec;\n }\n\n public ResTypeSpec addTypeSpec(int typeId, String typeName) throws AndrolibException {\n ResTypeSpec typeSpec = mTypeSpecs.get(typeId);\n if (typeSpec != null) {\n throw new AndrolibException(\n String.format(\"Repeated type spec: pkgId=0x%02x, typeId=0x%02x, typeName=%s\",\n getId(), typeId, typeName));\n }\n\n typeSpec = new ResTypeSpec(this, typeId, typeName);\n mTypeSpecs.put(typeId, typeSpec);\n return typeSpec;\n }\n\n public int getTypeSpecCount() {\n return mTypeSpecs.size();\n }\n\n public Collection listTypeSpecs() {\n return mTypeSpecs.values();\n }\n\n public boolean hasType(int typeId) {\n return hasType(typeId, ResConfig.DEFAULT);\n }\n\n public boolean hasType(int typeId, ResConfig config) {\n Pair typeKey = Pair.of(typeId, config);\n return mTypes.containsKey(typeKey);\n }\n\n public ResType getType(int typeId) throws UndefinedResObjectException {\n return getType(typeId, ResConfig.DEFAULT);\n }\n\n public ResType getType(int typeId, ResConfig config) throws UndefinedResObjectException {\n Pair typeKey = Pair.of(typeId, config);\n ResType type = mTypes.get(typeKey);\n if (type == null) {\n throw new UndefinedResObjectException(\n String.format(\"type: pkgId=0x%02x, typeId=0x%02x, config=%s\", getId(), typeId, config));\n }\n return type;\n }\n\n public ResType addType(int typeId) throws UndefinedResObjectException {\n return addType(typeId, ResConfig.DEFAULT);\n }\n\n public ResType addType(int typeId, ResConfig config) throws UndefinedResObjectException {\n Pair typeKey = Pair.of(typeId, config);\n ResType type = mTypes.get(typeKey);\n if (type != null) {\n // We can safely skip adding existing types.\n return type;\n }\n\n ResTypeSpec typeSpec = getTypeSpec(typeId);\n type = new ResType(typeSpec, config);\n mTypes.put(typeKey, type);\n return type;\n }\n\n public int getTypeCount() {\n return mTypes.size();\n }\n\n public Collection listTypes() {\n return mTypes.values();\n }\n\n public boolean hasEntrySpec(int typeId, int entryId) {\n ResId resId = ResId.of(getId(), typeId, entryId);\n resId = mAliases.getOrDefault(resId, resId);\n\n return mEntrySpecs.containsKey(resId);\n }\n\n public ResEntrySpec getEntrySpec(int typeId, int entryId) throws UndefinedResObjectException {\n ResId resId = ResId.of(getId(), typeId, entryId);\n if (mAliases.containsKey(resId)) {\n resId = mAliases.get(resId);\n typeId = resId.typeId();\n entryId = resId.entryId();\n }\n\n ResEntrySpec entrySpec = mEntrySpecs.get(resId);\n if (entrySpec == null) {\n throw new UndefinedResObjectException(\n String.format(\"entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x\", getId(), typeId, entryId));\n }\n return entrySpec;\n }\n\n public ResEntrySpec addEntrySpec(int typeId, int entryId, String name) throws AndrolibException {\n ResId resId = ResId.of(getId(), typeId, entryId);\n if (mAliases.containsKey(resId)) {\n resId = mAliases.get(resId);\n typeId = resId.typeId();\n entryId = resId.entryId();\n }\n\n ResEntrySpec entrySpec = mEntrySpecs.get(resId);\n if (entrySpec != null) {\n throw new AndrolibException(\n String.format(\"Repeated entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x\",\n getId(), typeId, entryId));\n }\n\n ResTypeSpec typeSpec = getTypeSpec(typeId);\n\n // Some apps had their entry names obfuscated or collapsed to a single value in the key string pool.\n // Enforce uniqueness by forcing a rename when that happens.\n if (mNameRegistry.contains(typeSpec.getName() + \"/\" + name)) {\n name = \"\";\n }\n\n entrySpec = new ResEntrySpec(typeSpec, entryId, name);\n mEntrySpecs.put(resId, entrySpec);\n\n // Register the name to enforce uniqueness.\n mNameRegistry.add(typeSpec.getName() + \"/\" + entrySpec.getName());\n\n return entrySpec;\n }\n\n public int getEntrySpecCount() {\n return mEntrySpecs.size();\n }\n\n public Collection listEntrySpecs() {\n return mEntrySpecs.values();\n }\n\n public boolean hasEntry(int typeId, int entryId) {\n return hasEntry(typeId, entryId, ResConfig.DEFAULT);\n }\n\n public boolean hasEntry(int typeId, int entryId, ResConfig config) {\n ResId resId = ResId.of(getId(), typeId, entryId);\n resId = mAliases.getOrDefault(resId, resId);\n\n Pair entryKey = Pair.of(resId, config);\n return mEntries.containsKey(entryKey);\n }\n\n public ResEntry getEntry(int typeId, int entryId) throws UndefinedResObjectException {\n return getEntry(typeId, entryId, ResConfig.DEFAULT);\n }\n\n public ResEntry getEntry(int typeId, int entryId, ResConfig config) throws UndefinedResObjectException {\n ResId resId = ResId.of(getId(), typeId, entryId);\n if (mAliases.containsKey(resId)) {\n resId = mAliases.get(resId);\n typeId = resId.typeId();\n entryId = resId.entryId();\n }\n\n Pair entryKey = Pair.of(resId, config);\n ResEntry entry = mEntries.get(entryKey);\n if (entry == null) {\n throw new UndefinedResObjectException(\n String.format(\"entry: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x, config=%s\",\n getId(), typeId, entryId, config));\n }\n return entry;\n }\n\n public ResEntry addEntry(int typeId, int entryId, ResValue value) throws AndrolibException {\n return addEntry(typeId, entryId, ResConfig.DEFAULT, value);\n }\n\n public ResEntry addEntry(int typeId, int entryId, ResConfig config, ResValue value) throws AndrolibException {\n ResId resId = ResId.of(getId(), typeId, entryId);\n if (mAliases.containsKey(resId)) {\n resId = mAliases.get(resId);\n typeId = resId.typeId();\n entryId = resId.entryId();\n }\n\n Pair entryKey = Pair.of(resId, config);\n ResEntry entry = mEntries.get(entryKey);\n if (entry != null) {\n throw new AndrolibException(\n String.format(\"Repeated entry: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x, config=%s\",\n getId(), typeId, entryId, config));\n }\n\n ResEntrySpec entrySpec = getEntrySpec(typeId, entryId);\n Pair typeKey = Pair.of(typeId, config);\n ResType type = mTypes.get(typeKey);\n if (type == null) {\n // We can safely create the type if it's missing.\n ResTypeSpec typeSpec = getTypeSpec(typeId);\n type = new ResType(typeSpec, config);\n mTypes.put(typeKey, type);\n }\n\n entry = new ResEntry(type, entrySpec, value);\n mEntries.put(entryKey, entry);\n return entry;\n }\n\n public int getEntryCount() {\n return mEntries.size();\n }\n\n public Collection listEntries() {\n return mEntries.values();\n }\n\n public boolean hasOverlayable(String name) {\n return mOverlayables.containsKey(name);\n }\n\n public ResOverlayable getOverlayable(String name) throws UndefinedResObjectException {\n ResOverlayable overlayable = mOverlayables.get(name);\n if (overlayable == null) {\n throw new UndefinedResObjectException(\n String.format(\"overlayable: pkgId=0x%02x, name=%s\", getId(), name));\n }\n return overlayable;\n }\n\n public ResOverlayable addOverlayable(String name, String actor) throws AndrolibException {\n ResOverlayable overlayable = mOverlayables.get(name);\n if (overlayable != null) {\n throw new AndrolibException(\n String.format(\"Repeated overlayable: pkgId=0x%02x, name=%s\", getId(), name));\n }\n\n overlayable = new ResOverlayable(this, name, actor);\n mOverlayables.put(name, overlayable);\n return overlayable;\n }\n\n public int getOverlayableCount() {\n return mOverlayables.size();\n }\n\n public Collection listOverlayables() {\n return mOverlayables.values();\n }\n\n public boolean isAlias(ResId resId) {\n return mAliases.containsKey(resId);\n }\n\n public ResId resolveAlias(ResId aliasId) throws UndefinedResObjectException {\n ResId resId = mAliases.get(aliasId);\n if (resId == null) {\n throw new UndefinedResObjectException(\n String.format(\"alias: pkgId=0x%02x, aliasId=%s\", getId(), aliasId));\n }\n return resId;\n }\n\n public void addAlias(ResId aliasId, ResId finalId) throws AndrolibException {\n if (mAliases.containsKey(aliasId)) {\n throw new AndrolibException(\n String.format(\"Repeated alias: pkgId=0x%02x, aliasId=%s\", getId(), aliasId));\n }\n\n mAliases.put(aliasId, finalId);\n }\n\n public int getAliasCount() {\n return mAliases.size();\n }\n\n public Map getAliases() {\n return mAliases;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResPackage{id=0x%02x, name=%s}\", getId(), getName());\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResPackage) {\n ResPackage other = (ResPackage) obj;\n return mGroup.equals(other.mGroup)\n && mIndex == other.mIndex;\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mGroup, mIndex);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResPackageGroup.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport brut.androlib.exceptions.UndefinedResObjectException;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.NoSuchElementException;\nimport java.util.Objects;\n\npublic class ResPackageGroup {\n private final ResTable mTable;\n private final int mId;\n private final String mName;\n private final List mPackages;\n\n public ResPackageGroup(ResTable table, int id, String name) {\n assert table != null && id >= 0 && name != null;\n mTable = table;\n mId = id;\n mName = name;\n mPackages = new ArrayList<>();\n mPackages.add(new ResPackage(this, 0));\n }\n\n public ResTable getTable() {\n return mTable;\n }\n\n public int getId() {\n return mId;\n }\n\n public String getName() {\n return mName;\n }\n\n public int getPackageCount() {\n return mPackages.size();\n }\n\n public Collection listPackages() {\n return mPackages;\n }\n\n public ResPackage getBasePackage() {\n return mPackages.get(0);\n }\n\n public Collection listSubPackages() {\n return mPackages.subList(1, mPackages.size());\n }\n\n public ResPackage addSubPackage() {\n ResPackage pkg = new ResPackage(this, mPackages.size());\n mPackages.add(pkg);\n return pkg;\n }\n\n public boolean hasTypeSpec(int typeId) {\n for (ResPackage pkg : mPackages) {\n if (pkg.hasTypeSpec(typeId)) {\n return true;\n }\n }\n return false;\n }\n\n public ResTypeSpec getTypeSpec(int typeId) throws UndefinedResObjectException {\n for (ResPackage pkg : mPackages) {\n try {\n return pkg.getTypeSpec(typeId);\n } catch (UndefinedResObjectException ignored) {\n }\n }\n throw new UndefinedResObjectException(\n String.format(\"type spec: pkgId=0x%02x, typeId=0x%02x\", mId, typeId));\n }\n\n public boolean hasType(int typeId) {\n return hasType(typeId, ResConfig.DEFAULT);\n }\n\n public boolean hasType(int typeId, ResConfig config) {\n for (ResPackage pkg : mPackages) {\n if (pkg.hasType(typeId, config)) {\n return true;\n }\n }\n return false;\n }\n\n public ResType getType(int typeId) throws UndefinedResObjectException {\n return getType(typeId, ResConfig.DEFAULT);\n }\n\n public ResType getType(int typeId, ResConfig config) throws UndefinedResObjectException {\n for (ResPackage pkg : mPackages) {\n try {\n return pkg.getType(typeId, config);\n } catch (UndefinedResObjectException ignored) {\n }\n }\n throw new UndefinedResObjectException(\n String.format(\"type: pkgId=0x%02x, typeId=0x%02x, config=%s\", mId, typeId, config));\n }\n\n public boolean hasEntrySpec(int typeId, int entryId) {\n for (ResPackage pkg : mPackages) {\n if (pkg.hasEntrySpec(typeId, entryId)) {\n return true;\n }\n }\n return false;\n }\n\n public ResEntrySpec getEntrySpec(int typeId, int entryId) throws UndefinedResObjectException {\n for (ResPackage pkg : mPackages) {\n try {\n return pkg.getEntrySpec(typeId, entryId);\n } catch (UndefinedResObjectException ignored) {\n }\n }\n throw new UndefinedResObjectException(\n String.format(\"entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x\", mId, typeId, entryId));\n }\n\n public Iterable listEntrySpecs() {\n return () -> new Iterator() {\n private Iterator current = Collections.emptyIterator();\n private int index = 0;\n\n @Override\n public boolean hasNext() {\n while (!current.hasNext() && index < mPackages.size()) {\n current = mPackages.get(index++).listEntrySpecs().iterator();\n }\n return current.hasNext();\n }\n\n @Override\n public ResEntrySpec next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n return current.next();\n }\n };\n }\n\n public boolean hasEntry(int typeId, int entryId) {\n return hasEntry(typeId, entryId, ResConfig.DEFAULT);\n }\n\n public boolean hasEntry(int typeId, int entryId, ResConfig config) {\n for (ResPackage pkg : mPackages) {\n if (pkg.hasEntry(typeId, entryId, config)) {\n return true;\n }\n }\n return false;\n }\n\n public ResEntry getEntry(int typeId, int entryId) throws UndefinedResObjectException {\n return getEntry(typeId, entryId, ResConfig.DEFAULT);\n }\n\n public ResEntry getEntry(int typeId, int entryId, ResConfig config) throws UndefinedResObjectException {\n for (ResPackage pkg : mPackages) {\n try {\n return pkg.getEntry(typeId, entryId, config);\n } catch (UndefinedResObjectException ignored) {\n }\n }\n throw new UndefinedResObjectException(\n String.format(\"entry: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x, config=%s\",\n mId, typeId, entryId, config));\n }\n\n public Iterable listEntries() {\n return () -> new Iterator() {\n private Iterator current = Collections.emptyIterator();\n private int index = 0;\n\n @Override\n public boolean hasNext() {\n while (!current.hasNext() && index < mPackages.size()) {\n current = mPackages.get(index++).listEntries().iterator();\n }\n return current.hasNext();\n }\n\n @Override\n public ResEntry next() {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n return current.next();\n }\n };\n }\n\n @Override\n public String toString() {\n return String.format(\"ResPackageGroup{id=0x%02x, name=%s}\", mId, mName);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResPackageGroup) {\n ResPackageGroup other = (ResPackageGroup) obj;\n return mId == other.mId\n && mName.equals(other.mName);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mId, mName);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResTable.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport brut.androlib.Config;\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.UndefinedResObjectException;\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.res.Framework;\nimport brut.androlib.res.decoder.BinaryResourceParser;\nimport brut.common.Log;\nimport brut.directory.DirectoryException;\nimport brut.directory.ExtFile;\nimport brut.directory.ZipRODirectory;\n\nimport java.io.File;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.LinkedHashMap;\nimport java.util.List;\nimport java.util.Map;\n\npublic class ResTable {\n private static final String TAG = ResTable.class.getName();\n\n public static final int SYS_PACKAGE_ID = 0x01;\n public static final int APP_PACKAGE_ID = 0x7F;\n\n private final ApkInfo mApkInfo;\n private final Config mConfig;\n private final Map mPackageGroups;\n private final List mLibPackageIds;\n private final List mFramePackageIds;\n private final Map mDynamicRefTable;\n private int mNextPackageId;\n private ResPackage mMainPackage;\n\n public ResTable(ApkInfo apkInfo, Config config) {\n assert apkInfo != null && config != null;\n mApkInfo = apkInfo;\n mConfig = config;\n mPackageGroups = new LinkedHashMap<>();\n mLibPackageIds = new ArrayList<>();\n mFramePackageIds = new ArrayList<>();\n mDynamicRefTable = new LinkedHashMap<>();\n mNextPackageId = SYS_PACKAGE_ID + 1;\n }\n\n public ApkInfo getApkInfo() {\n return mApkInfo;\n }\n\n public Config getConfig() {\n return mConfig;\n }\n\n public ResPackage getMainPackage() {\n return mMainPackage;\n }\n\n public Collection getLibPackageIds() {\n return mLibPackageIds;\n }\n\n public Collection getFramePackageIds() {\n return mFramePackageIds;\n }\n\n public void load() throws AndrolibException {\n if (mMainPackage != null) {\n return;\n }\n\n Log.i(TAG, \"Loading resource table...\");\n ExtFile apkFile = mApkInfo.getApkFile();\n\n ZipRODirectory zipDir;\n try {\n zipDir = (ZipRODirectory) apkFile.getDirectory();\n } catch (DirectoryException ex) {\n throw new AndrolibException(\"Could not open apk file: \" + apkFile, ex);\n }\n\n loadPackagesFromApk(apkFile, zipDir, true);\n\n ResPackageGroup pkgGroup;\n if (mPackageGroups.isEmpty()) {\n // Empty resources.arsc, create a dummy package group.\n pkgGroup = new ResPackageGroup(this, 0, \"\");\n mPackageGroups.put(0, pkgGroup);\n } else if (mPackageGroups.containsKey(APP_PACKAGE_ID)) {\n // Prefer the standard app package group.\n pkgGroup = mPackageGroups.get(APP_PACKAGE_ID);\n } else {\n // Fall back to the first package group in the table.\n pkgGroup = mPackageGroups.values().iterator().next();\n }\n\n mMainPackage = pkgGroup.getBasePackage();\n }\n\n private void loadPackagesFromApk(File apkFile, ZipRODirectory zipDir, boolean isMainPackage)\n throws AndrolibException {\n try {\n if (!zipDir.containsFile(\"resources.arsc\")) {\n throw new AndrolibException(\"Could not find resources.arsc in file: \" + apkFile);\n }\n\n try (InputStream in = zipDir.getFileInput(\"resources.arsc\")) {\n BinaryResourceParser parser = isMainPackage\n ? new BinaryResourceParser(this, mConfig.isKeepBrokenResources(), mConfig.isDecodeResolveGreedy())\n : new BinaryResourceParser(this, true, true);\n parser.parse(in);\n\n // Only flag the app for the main package.\n if (isMainPackage) {\n if (parser.isSparseEntries()) {\n mApkInfo.getResourcesInfo().setSparseEntries(true);\n }\n if (parser.isCompactEntries()) {\n mApkInfo.getResourcesInfo().setCompactEntries(true);\n }\n }\n }\n } catch (DirectoryException | IOException ex) {\n throw new AndrolibException(\"Could not load resources.arsc from file: \" + apkFile, ex);\n }\n }\n\n public boolean hasPackageGroup(int id) {\n return mPackageGroups.containsKey(id);\n }\n\n public ResPackageGroup getPackageGroup(int id) throws UndefinedResObjectException {\n ResPackageGroup pkgGroup = mPackageGroups.get(id);\n if (pkgGroup == null) {\n throw new UndefinedResObjectException(String.format(\"package group: id=0x%02x\", id));\n }\n return pkgGroup;\n }\n\n public ResPackageGroup addPackageGroup(int id, String name) throws AndrolibException {\n ResPackageGroup pkgGroup = mPackageGroups.get(id);\n if (pkgGroup != null) {\n throw new AndrolibException(String.format(\"Repeated package group: id=0x%02x, name=%s\", id, name));\n }\n\n // If the package ID is 0x00 and the main package is loaded, that means that a shared library is being loaded,\n // so we change it to the reference package ID defined in the dynamic reference table, or assign it the next\n // available ID.\n if (id == 0 && mMainPackage != null) {\n id = getDynamicRefPackageId(name);\n if (id == 0) {\n id = mNextPackageId++;\n }\n }\n\n pkgGroup = new ResPackageGroup(this, id, name);\n mPackageGroups.put(id, pkgGroup);\n return pkgGroup;\n }\n\n public int getPackageGroupCount() {\n return mPackageGroups.size();\n }\n\n public Collection listPackageGroups() {\n return mPackageGroups.values();\n }\n\n public ResPackageGroup resolvePackageGroup(int id) throws AndrolibException {\n ResPackageGroup pkgGroup = mPackageGroups.get(id);\n if (pkgGroup == null) {\n pkgGroup = loadLibraryById(id);\n if (pkgGroup == null) {\n pkgGroup = loadFrameworkById(id);\n }\n }\n return pkgGroup;\n }\n\n private ResPackageGroup loadLibraryById(int id) throws AndrolibException {\n String name = mDynamicRefTable.get(id);\n String[] libFiles = mConfig.getLibraryFiles();\n if (name == null || libFiles == null) {\n return null;\n }\n\n File apkFile = null;\n for (String libEntry : libFiles) {\n String[] parts = libEntry.split(\":\", 2);\n if (parts.length == 2 && name.equals(parts[0])) {\n apkFile = new File(parts[1]);\n break;\n }\n }\n if (apkFile == null) {\n return null;\n }\n\n loadPackagesFromApk(apkFile);\n\n ResPackageGroup pkgGroup = mPackageGroups.get(id);\n if (pkgGroup == null) {\n throw new AndrolibException(String.format(\"Library package not found: id=0x%02x\", id));\n }\n\n mLibPackageIds.add(id);\n return pkgGroup;\n }\n\n private ResPackageGroup loadFrameworkById(int id) throws AndrolibException {\n File apkFile = new Framework(mConfig).getApkFile(id);\n loadPackagesFromApk(apkFile);\n\n ResPackageGroup pkgGroup = mPackageGroups.get(id);\n if (pkgGroup == null) {\n throw new AndrolibException(String.format(\"Framework package not found: id=0x%02x\", id));\n }\n\n mFramePackageIds.add(id);\n return pkgGroup;\n }\n\n private void loadPackagesFromApk(File apkFile) throws AndrolibException {\n Log.i(TAG, \"Loading resource table from file: \" + apkFile);\n\n try (ZipRODirectory zipDir = new ZipRODirectory(apkFile)) {\n loadPackagesFromApk(apkFile, zipDir, false);\n } catch (DirectoryException ex) {\n throw new AndrolibException(\"Could not open apk file: \" + apkFile, ex);\n }\n }\n\n public ResEntrySpec resolve(ResId resId) throws AndrolibException {\n return resolvePackageGroup(resId.pkgId()).getEntrySpec(resId.typeId(), resId.entryId());\n }\n\n public ResEntry resolveEntry(ResId resId) throws AndrolibException {\n return resolvePackageGroup(resId.pkgId()).getEntry(resId.typeId(), resId.entryId());\n }\n\n public String getDynamicRefPackageName(int id) {\n String name = mDynamicRefTable.get(id);\n if (name == null) {\n Log.w(TAG, \"Dynamic ref package name not defined for package ID: 0x02x\", id);\n }\n return name;\n }\n\n public int getDynamicRefPackageId(String name) {\n for (Map.Entry entry : mDynamicRefTable.entrySet()) {\n if (name.equals(entry.getValue())) {\n return entry.getKey();\n }\n }\n Log.w(TAG, \"Dynamic ref package ID not defined for package: \" + name);\n return 0;\n }\n\n public void addDynamicRefPackage(int id, String name) {\n // Ensure the package ID isn't already mapped to a different name.\n String existing = mDynamicRefTable.get(id);\n if (existing != null) {\n if (!existing.equals(name)) {\n Log.w(TAG, \"Repeated dynamic ref package ID: %s (assigned to name: %s)\", id, existing);\n return;\n }\n // Identical mappings are normal.\n return;\n }\n\n // Ensure the package name isn't already mapped to a different ID.\n for (Map.Entry entry : mDynamicRefTable.entrySet()) {\n if (name.equals(entry.getValue())) {\n Log.w(TAG, \"Repeated dynamic ref package name: %s (assigned to ID: %s)\", name, entry.getKey());\n return;\n }\n }\n\n mDynamicRefTable.put(id, name);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResType.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport java.util.Objects;\n\npublic class ResType {\n private final ResTypeSpec mSpec;\n private final ResConfig mConfig;\n\n public ResType(ResTypeSpec spec, ResConfig config) {\n assert spec != null && config != null;\n mSpec = spec;\n mConfig = config;\n }\n\n public ResPackage getPackage() {\n return mSpec.getPackage();\n }\n\n public ResTypeSpec getSpec() {\n return mSpec;\n }\n\n public int getId() {\n return mSpec.getId();\n }\n\n public String getName() {\n return mSpec.getName();\n }\n\n public boolean isBagType() {\n return mSpec.isBagType();\n }\n\n public ResConfig getConfig() {\n return mConfig;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResType{spec=%s, config=%s}\", mSpec, mConfig);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResType) {\n ResType other = (ResType) obj;\n return mSpec.equals(other.mSpec)\n && mConfig.equals(other.mConfig);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mSpec, mConfig);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResTypeSpec.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table;\n\nimport java.util.Objects;\n\npublic class ResTypeSpec {\n private final ResPackage mPackage;\n private final int mId;\n private final String mName;\n\n public ResTypeSpec(ResPackage pkg, int id, String name) {\n assert pkg != null && id > 0 && name != null;\n mPackage = pkg;\n mId = id;\n mName = name;\n }\n\n public ResPackage getPackage() {\n return mPackage;\n }\n\n public int getId() {\n return mId;\n }\n\n public String getName() {\n return mName;\n }\n\n public boolean isBagType() {\n switch (mName) {\n case \"attr\":\n case \"^attr-private\":\n case \"array\":\n case \"plurals\":\n case \"style\":\n return true;\n default:\n return false;\n }\n }\n\n @Override\n public String toString() {\n return String.format(\"ResTypeSpec{pkg=%s, id=0x%02x, name=%s}\", mPackage, mId, mName);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResTypeSpec) {\n ResTypeSpec other = (ResTypeSpec) obj;\n return mPackage.equals(other.mPackage)\n && mId == other.mId\n && mName.equals(other.mName);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mPackage, mId, mName);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResArray.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.ResEntrySpec;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Arrays;\n\npublic class ResArray extends ResBag {\n private final ResItem[] mItems;\n\n public ResArray(ResReference parent, ResItem[] items) {\n super(parent);\n assert items != null;\n mItems = items;\n }\n\n public static ResArray parse(ResReference parent, RawItem[] rawItems) {\n ResItem[] items = new ResItem[rawItems.length];\n\n for (int i = 0; i < rawItems.length; i++) {\n items[i] = rawItems[i].getValue();\n }\n\n return new ResArray(parent, items);\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String format = resolveFormat();\n\n // It's safe to use the format as the array type since the only typed arrays are string-array and integer-array.\n String tagName = \"array\";\n if (format != null) {\n switch (format) {\n case \"string\":\n case \"integer\":\n tagName = format + \"-\" + tagName;\n break;\n }\n }\n\n serial.startTag(null, tagName);\n serial.attribute(null, \"name\", entry.getName());\n\n for (ResItem value : mItems) {\n serial.startTag(null, \"item\");\n serial.text(value.toXmlTextValue());\n serial.endTag(null, \"item\");\n }\n\n serial.endTag(null, tagName);\n }\n\n private String resolveFormat() {\n String format = null;\n\n for (ResItem value : mItems) {\n String itemFormat = null;\n\n if (value instanceof ResReference) {\n // The reference format is ambiguous. Since the only typed arrays are string-array and integer-array,\n // we can infer a more specific format from the type of the referenced entry spec without mapping it\n // explicitly to a format.\n try {\n ResEntrySpec spec = ((ResReference) value).resolve();\n if (spec != null) {\n itemFormat = spec.getTypeSpec().getName();\n }\n } catch (AndrolibException ignored) {\n }\n } else {\n itemFormat = value.getFormat();\n }\n\n // Ignore @null and @empty.\n if (itemFormat == null) {\n continue;\n }\n\n if (format == null) {\n format = itemFormat;\n } else if (!format.equals(itemFormat)) {\n // Items with differing formats imply the array is generic.\n format = null;\n break;\n }\n }\n\n return format;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResArray{items=%s}\", Arrays.toString(mItems));\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResArray) {\n ResArray other = (ResArray) obj;\n return Arrays.equals(mItems, other.mItems);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Arrays.hashCode(mItems);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResAttribute.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResPackage;\nimport brut.androlib.res.xml.ResStringEncoder;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Objects;\n\npublic class ResAttribute extends ResBag {\n private static final String TAG = ResAttribute.class.getName();\n\n private static final int ATTR_TYPE = 0x01000000;\n private static final int ATTR_MIN = 0x01000001;\n private static final int ATTR_MAX = 0x01000002;\n private static final int ATTR_L10N = 0x01000003;\n\n public static final int ATTR_TYPE_ANY = 0x0000FFFF;\n public static final int ATTR_TYPE_REFERENCE = 1 << 0; // 0x01\n public static final int ATTR_TYPE_STRING = 1 << 1; // 0x02\n public static final int ATTR_TYPE_INTEGER = 1 << 2; // 0x04\n public static final int ATTR_TYPE_BOOLEAN = 1 << 3; // 0x08\n public static final int ATTR_TYPE_COLOR = 1 << 4; // 0x10\n public static final int ATTR_TYPE_FLOAT = 1 << 5; // 0x20\n public static final int ATTR_TYPE_DIMENSION = 1 << 6; // 0x40\n public static final int ATTR_TYPE_FRACTION = 1 << 7; // 0x80\n public static final int ATTR_TYPE_ENUM = 1 << 16; // 0x00010000\n public static final int ATTR_TYPE_FLAGS = 1 << 17; // 0x00020000\n\n private static final int[] ATTR_TYPE_MASKS = {\n ATTR_TYPE_STRING, ATTR_TYPE_INTEGER, ATTR_TYPE_BOOLEAN, ATTR_TYPE_COLOR, ATTR_TYPE_FLOAT,\n ATTR_TYPE_DIMENSION, ATTR_TYPE_FRACTION, ATTR_TYPE_REFERENCE\n };\n private static final String[] ATTR_TYPE_NAMES = {\n \"string\", \"integer\", \"boolean\", \"color\", \"float\", \"dimension\", \"fraction\", \"reference\"\n };\n\n private static final int ATTR_L10N_NOT_REQUIRED = 0;\n private static final int ATTR_L10N_SUGGESTED = 1;\n\n public static final ResAttribute DEFAULT = new ResAttribute(\n null, ATTR_TYPE_ANY, Integer.MIN_VALUE, Integer.MAX_VALUE, ATTR_L10N_NOT_REQUIRED);\n\n protected int mType; // might be updated later\n protected final int mMin;\n protected final int mMax;\n protected final int mL10n;\n\n public ResAttribute(ResReference parent, int type, int min, int max, int l10n) {\n super(parent);\n mType = type;\n mMin = min;\n mMax = max;\n mL10n = l10n;\n }\n\n public static ResAttribute parse(ResReference parent, RawItem[] rawItems) {\n int type = ATTR_TYPE_ANY;\n int min = Integer.MIN_VALUE;\n int max = Integer.MAX_VALUE;\n int l10n = ATTR_L10N_NOT_REQUIRED;\n\n int i = 0, n = rawItems.length;\n for (; i < n; i++) {\n RawItem rawItem = rawItems[i];\n ResPrimitive value = (ResPrimitive) rawItem.getValue();\n\n switch (rawItem.getKey()) {\n case ATTR_TYPE:\n type = value.getData();\n continue;\n case ATTR_MIN:\n min = value.getData();\n continue;\n case ATTR_MAX:\n max = value.getData();\n continue;\n case ATTR_L10N:\n l10n = value.getData();\n continue;\n }\n break;\n }\n if (i == n) {\n // The attribute doesn't have any symbols.\n return new ResAttribute(parent, type, min, max, l10n);\n }\n\n Symbol[] symbols = new Symbol[n - i];\n ResPackage pkg = parent.getPackage();\n\n for (int j = 0; i < n; i++, j++) {\n RawItem rawItem = rawItems[i];\n // The name of the symbol as a reference to a generated ID resource value.\n int nameId = rawItem.getKey();\n ResReference name = new ResReference(pkg, ResId.of(nameId));\n ResPrimitive value = (ResPrimitive) rawItem.getValue();\n\n symbols[j] = new Symbol(name, value);\n }\n\n if ((type & ATTR_TYPE_ENUM) != 0) {\n return new ResEnum(parent, type, min, max, l10n, symbols);\n } else if ((type & ATTR_TYPE_FLAGS) != 0) {\n return new ResFlags(parent, type, min, max, l10n, symbols);\n } else {\n Log.w(TAG, \"Invalid attribute type: 0x%08x\", type);\n return new ResAttribute(parent, type, min, max, l10n);\n }\n }\n\n public static class Symbol {\n private final ResReference mKey;\n private final ResPrimitive mValue;\n\n public Symbol(ResReference key, ResPrimitive value) {\n assert key != null && value != null;\n mKey = key;\n mValue = value;\n }\n\n public ResReference getKey() {\n return mKey;\n }\n\n public ResPrimitive getValue() {\n return mValue;\n }\n }\n\n public void addValueType(int valueType) {\n if ((mType & ATTR_TYPE_ANY) == ATTR_TYPE_ANY) {\n return;\n }\n switch (valueType) {\n case TYPE_NULL:\n case TYPE_REFERENCE:\n case TYPE_DYNAMIC_REFERENCE:\n case TYPE_ATTRIBUTE:\n case TYPE_DYNAMIC_ATTRIBUTE:\n mType |= ATTR_TYPE_REFERENCE;\n return;\n case TYPE_STRING:\n mType |= ATTR_TYPE_STRING;\n return;\n case TYPE_FLOAT:\n mType |= ATTR_TYPE_FLOAT;\n return;\n case TYPE_DIMENSION:\n mType |= ATTR_TYPE_DIMENSION;\n return;\n case TYPE_FRACTION:\n mType |= ATTR_TYPE_FRACTION;\n return;\n case TYPE_INT_BOOLEAN:\n mType |= ATTR_TYPE_BOOLEAN;\n return;\n default:\n if (valueType >= TYPE_FIRST_COLOR_INT && valueType <= TYPE_LAST_COLOR_INT) {\n mType |= ATTR_TYPE_COLOR;\n } else if (valueType >= TYPE_FIRST_INT && valueType <= TYPE_LAST_INT) {\n mType |= ATTR_TYPE_INTEGER;\n }\n return;\n }\n }\n\n public boolean hasSymbolsForValue(ResItem value) {\n return getSymbolsForValue(value) != null;\n }\n\n protected Symbol[] getSymbolsForValue(ResItem value) {\n // Stub for attribute types with symbols.\n return null;\n }\n\n public String formatAsTextValue(ResItem value) throws AndrolibException {\n return formatValue(value, false);\n }\n\n public String formatAsAttributeValue(ResItem value) throws AndrolibException {\n return formatValue(value, true);\n }\n\n private String formatValue(ResItem value, boolean asAttrValue) throws AndrolibException {\n String formatted = formatValueFromSymbols(value);\n if (formatted != null) {\n return formatted;\n }\n\n // Ensure strings are escaped for attribute values according to the attribute type.\n if (asAttrValue && value instanceof ResString) {\n CharSequence strValue = ((ResString) value).getValue();\n return ResStringEncoder.encodeAttributeValue(strValue, mType);\n }\n\n return asAttrValue ? value.toXmlAttributeValue() : value.toXmlTextValue();\n }\n\n protected String formatValueFromSymbols(ResItem value) throws AndrolibException {\n // Stub for attribute types with symbols.\n return null;\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String tagName = \"attr\";\n serial.startTag(null, tagName);\n serial.attribute(null, \"name\", entry.getName());\n String format = renderFormat();\n if (format != null) {\n serial.attribute(null, \"format\", format);\n }\n if (mMin != Integer.MIN_VALUE) {\n serial.attribute(null, \"min\", Integer.toString(mMin));\n }\n if (mMax != Integer.MAX_VALUE) {\n serial.attribute(null, \"max\", Integer.toString(mMax));\n }\n if (mL10n == ATTR_L10N_SUGGESTED) {\n serial.attribute(null, \"localization\", \"suggested\");\n }\n serializeSymbolsToValuesXml(serial, entry);\n serial.endTag(null, tagName);\n }\n\n private String renderFormat() {\n if ((mType & ATTR_TYPE_ANY) == ATTR_TYPE_ANY) {\n return null;\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < ATTR_TYPE_MASKS.length; i++) {\n if ((mType & ATTR_TYPE_MASKS[i]) != 0) {\n if (sb.length() > 0) {\n sb.append('|');\n }\n sb.append(ATTR_TYPE_NAMES[i]);\n }\n }\n if (sb.length() == 0) {\n return null;\n }\n return sb.toString();\n }\n\n protected void serializeSymbolsToValuesXml(XmlSerializer serial, ResEntry entry)\n throws AndrolibException, IOException {\n // Stub for attribute types with symbols.\n }\n\n @Override\n public String toString() {\n return String.format(\"ResAttribute{type=0x%04x, min=%s, max=%s, l10n=%s}\", mType, mMin, mMax, mL10n);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResAttribute) {\n ResAttribute other = (ResAttribute) obj;\n return mType == other.mType\n && mMin == other.mMin\n && mMax == other.mMax\n && mL10n == other.mL10n;\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mType, mMin, mMax, mL10n);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResBag.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.xml.ValuesXmlSerializable;\nimport brut.common.Log;\n\npublic abstract class ResBag extends ResValue implements ValuesXmlSerializable {\n private static final String TAG = ResBag.class.getName();\n\n protected final ResReference mParent;\n\n protected ResBag(ResReference parent) {\n mParent = parent;\n }\n\n public static ResBag parse(String typeName, ResReference parent, RawItem[] rawItems) {\n switch (typeName) {\n case \"attr\":\n case \"^attr-private\":\n return ResAttribute.parse(parent, rawItems);\n case \"array\":\n return ResArray.parse(parent, rawItems);\n case \"plurals\":\n return ResPlural.parse(parent, rawItems);\n case \"style\":\n return ResStyle.parse(parent, rawItems);\n default:\n Log.w(TAG, \"Unsupported type for bags: \" + typeName);\n return null;\n }\n }\n\n public static class RawItem {\n private final int mKey;\n private final ResItem mValue;\n\n public RawItem(int key, ResItem value) {\n assert value != null;\n mKey = key;\n mValue = value;\n }\n\n public int getKey() {\n return mKey;\n }\n\n public ResItem getValue() {\n return mValue;\n }\n }\n\n public void resolveKeys() throws AndrolibException {\n // Stub for bags with resolvable keys.\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResCustom.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.xml.ValuesXmlSerializable;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Objects;\n\npublic class ResCustom extends ResValue implements ValuesXmlSerializable {\n public static final ResCustom ID = new ResCustom(\"id\");\n\n private final String mType;\n private final Object mValue;\n private final boolean mAsItem;\n\n public ResCustom(String type) {\n this(type, null, false);\n }\n\n public ResCustom(String type, boolean asItem) {\n this(type, null, asItem);\n }\n\n public ResCustom(String type, Object value) {\n this(type, value, false);\n }\n\n public ResCustom(String type, Object value, boolean asItem) {\n assert type != null;\n mType = type;\n mValue = value;\n mAsItem = asItem;\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String tagName = mAsItem ? \"item\" : mType;\n serial.startTag(null, tagName);\n if (mAsItem) {\n serial.attribute(null, \"type\", mType);\n }\n serial.attribute(null, \"name\", entry.getName());\n if (mValue != null) {\n serial.text(mValue.toString());\n }\n serial.endTag(null, tagName);\n }\n\n @Override\n public String toString() {\n return String.format(\"ResCustom{type=%s, value=%s, asItem=%s}\", mType, mValue, mAsItem);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResCustom) {\n ResCustom other = (ResCustom) obj;\n return mType.equals(other.mType)\n && Objects.equals(mValue, other.mValue)\n && mAsItem == other.mAsItem;\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mType, mValue, mAsItem);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResEnum.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.ResEntrySpec;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResPackage;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Objects;\n\npublic class ResEnum extends ResAttribute {\n private static final String TAG = ResEnum.class.getName();\n\n private final Symbol[] mSymbols;\n private Map mSymbolsCache;\n private Map mFormatsCache;\n\n public ResEnum(ResReference parent, int type, int min, int max, int l10n, Symbol[] symbols) {\n super(parent, type, min, max, l10n);\n assert parent != null && symbols != null;\n mSymbols = symbols;\n }\n\n @Override\n public void resolveKeys() throws AndrolibException {\n ResPackage pkg = mParent.getPackage();\n boolean skipUnresolved = pkg.getTable().getConfig().isDecodeResolveLazy();\n\n for (Symbol symbol : mSymbols) {\n ResReference key = symbol.getKey();\n if (key.resolve() != null) {\n continue;\n }\n\n ResId keyId = key.getResId();\n\n // #2836 - Skip item if the resource cannot be resolved.\n if (skipUnresolved || keyId.pkgId() != pkg.getId()) {\n Log.w(TAG, \"Unresolved enum reference: key=%s, value=%s\", key, symbol.getValue());\n continue;\n }\n\n pkg.addEntrySpec(keyId.typeId(), keyId.entryId(), ResEntrySpec.DUMMY_PREFIX + keyId);\n pkg.addEntry(keyId.typeId(), keyId.entryId(), ResCustom.ID);\n }\n }\n\n @Override\n protected Symbol[] getSymbolsForValue(ResItem value) {\n if (!isSymbolValueType(value)) {\n return null;\n }\n\n int data = ((ResPrimitive) value).getData();\n return getSymbols(data);\n }\n\n private boolean isSymbolValueType(ResItem value) {\n if (!(value instanceof ResPrimitive)) {\n return false;\n }\n\n int type = value.getType();\n return type == TYPE_INT_DEC || type == TYPE_INT_HEX;\n }\n\n private Symbol[] getSymbols(int data) {\n if (mSymbolsCache == null) {\n // Lazily establish a symbols cache for performance.\n mSymbolsCache = new HashMap<>();\n } else if (mSymbolsCache.containsKey(data)) {\n return mSymbolsCache.get(data);\n }\n\n Symbol[] symbols = new Symbol[mSymbols.length];\n int symbolsCount = 0;\n\n for (Symbol symbol : mSymbols) {\n if (symbol.getValue().getData() == data) {\n symbols[symbolsCount++] = symbol;\n }\n }\n\n if (symbolsCount == 0) {\n symbols = null;\n } else if (symbolsCount < symbols.length) {\n symbols = Arrays.copyOf(symbols, symbolsCount);\n }\n\n mSymbolsCache.put(data, symbols);\n return symbols;\n }\n\n @Override\n protected String formatValueFromSymbols(ResItem value) throws AndrolibException {\n if (!isSymbolValueType(value)) {\n return null;\n }\n\n int data = ((ResPrimitive) value).getData();\n if (mFormatsCache == null) {\n // Lazily establish a formats cache for performance.\n mFormatsCache = new HashMap<>();\n } else if (mFormatsCache.containsKey(data)) {\n return mFormatsCache.get(data);\n }\n\n Symbol[] symbols = getSymbols(data);\n String formatted = null;\n\n if (symbols != null) {\n for (Symbol symbol : symbols) {\n ResEntrySpec keySpec = symbol.getKey().resolve();\n if (keySpec == null) {\n continue;\n }\n\n formatted = keySpec.getName();\n\n // fill_parent is deprecated since API 8 but appears first.\n // Keep looking for match_parent and use it instead if found.\n if (data == -1 && formatted.equals(\"fill_parent\")) {\n continue;\n }\n break;\n }\n }\n\n mFormatsCache.put(data, formatted);\n return formatted;\n }\n\n @Override\n protected void serializeSymbolsToValuesXml(XmlSerializer serial, ResEntry entry)\n throws AndrolibException, IOException {\n for (Symbol symbol : mSymbols) {\n ResEntrySpec keySpec = symbol.getKey().resolve();\n if (keySpec == null) {\n continue;\n }\n\n serial.startTag(null, \"enum\");\n serial.attribute(null, \"name\", keySpec.getName());\n serial.attribute(null, \"value\", symbol.getValue().toXmlAttributeValue());\n serial.endTag(null, \"enum\");\n }\n }\n\n @Override\n public String toString() {\n return String.format(\"ResEnum{parent=%s, type=0x%04x, min=%s, max=%s, l10n=%s, symbols=%s}\",\n mParent, mType, mMin, mMax, mL10n, Arrays.toString(mSymbols));\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResEnum) {\n ResEnum other = (ResEnum) obj;\n return mParent.equals(other.mParent)\n && mType == other.mType\n && mMin == other.mMin\n && mMax == other.mMax\n && mL10n == other.mL10n\n && Arrays.equals(mSymbols, other.mSymbols);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mParent, mType, mMin, mMax, mL10n, Arrays.hashCode(mSymbols));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResFileReference.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\npublic class ResFileReference extends ResValue {\n private final String mPath;\n\n public ResFileReference(String path) {\n assert path != null;\n mPath = path;\n }\n\n public String getPath() {\n return mPath;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResFileReference{path=%s}\", mPath);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResFileReference) {\n ResFileReference other = (ResFileReference) obj;\n return mPath.equals(other.mPath);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return mPath.hashCode();\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResFlags.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.ResEntrySpec;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResPackage;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Objects;\n\npublic class ResFlags extends ResAttribute {\n private static final String TAG = ResFlags.class.getName();\n\n private final Symbol[] mSymbols;\n private Map mSymbolsCache;\n private Map mFormatsCache;\n private Symbol[] mSortedSymbols;\n\n public ResFlags(ResReference parent, int type, int min, int max, int l10n, Symbol[] symbols) {\n super(parent, type, min, max, l10n);\n assert parent != null && symbols != null;\n mSymbols = symbols;\n }\n\n @Override\n public void resolveKeys() throws AndrolibException {\n ResPackage pkg = mParent.getPackage();\n boolean skipUnresolved = pkg.getTable().getConfig().isDecodeResolveLazy();\n\n for (Symbol symbol : mSymbols) {\n ResReference key = symbol.getKey();\n if (key.resolve() != null) {\n continue;\n }\n\n ResId keyId = key.getResId();\n\n // #2836 - Skip item if the resource cannot be resolved.\n if (skipUnresolved || keyId.pkgId() != pkg.getId()) {\n Log.w(TAG, \"Unresolved flag reference: key=%s, value=%s\", key, symbol.getValue());\n continue;\n }\n\n pkg.addEntrySpec(keyId.typeId(), keyId.entryId(), ResEntrySpec.DUMMY_PREFIX + keyId);\n pkg.addEntry(keyId.typeId(), keyId.entryId(), ResCustom.ID);\n }\n }\n\n @Override\n protected Symbol[] getSymbolsForValue(ResItem value) {\n if (!isSymbolValueType(value)) {\n return null;\n }\n\n int data = ((ResPrimitive) value).getData();\n return getSymbols(data);\n }\n\n private boolean isSymbolValueType(ResItem value) {\n if (!(value instanceof ResPrimitive)) {\n return false;\n }\n\n int type = value.getType();\n return type == TYPE_INT_DEC || type == TYPE_INT_HEX;\n }\n\n private Symbol[] getSymbols(int data) {\n if (mSymbolsCache == null) {\n // Lazily establish a symbols cache for performance.\n mSymbolsCache = new HashMap<>();\n } else if (mSymbolsCache.containsKey(data)) {\n return mSymbolsCache.get(data);\n }\n\n if (mSortedSymbols == null) {\n // Lazily establish a priority list for the flags.\n // This can never be completely accurate to the source, but it's a best-effort approach.\n mSortedSymbols = mSymbols.clone();\n Comparator byBitCount = Comparator.comparingInt(\n (Symbol symbol) -> Integer.bitCount(symbol.getValue().getData()));\n Comparator byRawValue = Comparator.comparingInt(\n (Symbol symbol) -> symbol.getValue().getData());\n Arrays.sort(mSortedSymbols, byBitCount.reversed().thenComparing(byRawValue));\n }\n\n Symbol[] symbols = new Symbol[mSortedSymbols.length];\n int symbolsCount = 0;\n\n if (data == 0) {\n for (Symbol symbol : mSortedSymbols) {\n if (symbol.getValue().getData() == 0) {\n symbols[symbolsCount++] = symbol;\n }\n }\n } else {\n int mask = 0;\n\n for (Symbol symbol : mSortedSymbols) {\n int flag = symbol.getValue().getData();\n if ((data & flag) != flag || (mask & flag) == flag) {\n continue;\n }\n\n symbols[symbolsCount++] = symbol;\n mask |= flag;\n\n if (mask == data) {\n break;\n }\n }\n\n // Filter out redundant flags.\n if (symbolsCount > 2) {\n Symbol[] filtered = new Symbol[symbolsCount];\n int filteredCount = 0;\n\n for (int i = 0; i < symbolsCount; i++) {\n Symbol symbol = symbols[i];\n mask = 0;\n\n // Combine the other flags.\n for (int j = 0; j < symbolsCount; j++) {\n Symbol other = symbols[j];\n\n if (j != i) {\n mask |= other.getValue().getData();\n }\n }\n\n // Skip if it doesn't add at least one unique bit.\n if ((symbol.getValue().getData() & ~mask) == 0) {\n continue;\n }\n\n filtered[filteredCount++] = symbol;\n }\n\n symbols = filtered;\n symbolsCount = filteredCount;\n }\n }\n\n if (symbolsCount == 0) {\n symbols = null;\n } else if (symbolsCount < symbols.length) {\n symbols = Arrays.copyOf(symbols, symbolsCount);\n }\n\n mSymbolsCache.put(data, symbols);\n return symbols;\n }\n\n @Override\n protected String formatValueFromSymbols(ResItem value) throws AndrolibException {\n if (!isSymbolValueType(value)) {\n return null;\n }\n\n int data = ((ResPrimitive) value).getData();\n if (mFormatsCache == null) {\n // Lazily establish a formats cache for performance.\n mFormatsCache = new HashMap<>();\n } else if (mFormatsCache.containsKey(data)) {\n return mFormatsCache.get(data);\n }\n\n Symbol[] symbols = getSymbols(data);\n String formatted = null;\n\n if (symbols != null) {\n StringBuilder sb = new StringBuilder();\n\n for (Symbol symbol : symbols) {\n ResEntrySpec keySpec = symbol.getKey().resolve();\n if (keySpec == null) {\n continue;\n }\n\n if (sb.length() > 0) {\n sb.append('|');\n }\n sb.append(keySpec.getName());\n }\n\n formatted = sb.toString();\n }\n\n mFormatsCache.put(data, formatted);\n return formatted;\n }\n\n @Override\n protected void serializeSymbolsToValuesXml(XmlSerializer serial, ResEntry entry)\n throws AndrolibException, IOException {\n for (Symbol symbol : mSymbols) {\n ResEntrySpec keySpec = symbol.getKey().resolve();\n if (keySpec == null) {\n continue;\n }\n\n serial.startTag(null, \"flag\");\n serial.attribute(null, \"name\", keySpec.getName());\n serial.attribute(null, \"value\", symbol.getValue().toXmlAttributeValue());\n serial.endTag(null, \"flag\");\n }\n }\n\n @Override\n public String toString() {\n return String.format(\"ResFlags{parent=%s, type=0x%04x, min=%s, max=%s, l10n=%s, symbols=%s}\",\n mParent, mType, mMin, mMax, mL10n, Arrays.toString(mSymbols));\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResFlags) {\n ResFlags other = (ResFlags) obj;\n return mParent.equals(other.mParent)\n && mType == other.mType\n && mMin == other.mMin\n && mMax == other.mMax\n && mL10n == other.mL10n\n && Arrays.equals(mSymbols, other.mSymbols);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mParent, mType, mMin, mMax, mL10n, Arrays.hashCode(mSymbols));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResItem.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResPackage;\nimport brut.androlib.res.xml.ValuesXmlSerializable;\nimport brut.common.Log;\nimport com.google.common.collect.Sets;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Set;\n\npublic abstract class ResItem extends ResValue implements ValuesXmlSerializable {\n private static final String TAG = ResItem.class.getName();\n\n protected static final Map> STANDARD_TYPE_FORMATS = new HashMap<>();\n static {\n STANDARD_TYPE_FORMATS.put(\"bool\", Sets.newHashSet(\"boolean\"));\n STANDARD_TYPE_FORMATS.put(\"color\", Sets.newHashSet(\"color\"));\n STANDARD_TYPE_FORMATS.put(\"dimen\", Sets.newHashSet(\"float\", \"fraction\", \"dimension\"));\n STANDARD_TYPE_FORMATS.put(\"drawable\", Sets.newHashSet(\"color\"));\n STANDARD_TYPE_FORMATS.put(\"fraction\", Sets.newHashSet(\"float\", \"fraction\", \"dimension\"));\n STANDARD_TYPE_FORMATS.put(\"integer\", Sets.newHashSet(\"integer\"));\n STANDARD_TYPE_FORMATS.put(\"string\", Sets.newHashSet(\"string\"));\n }\n\n protected final int mType;\n\n protected ResItem(int type) {\n mType = type;\n }\n\n public static ResItem parse(ResPackage pkg, int type, int data) {\n assert type != TYPE_STRING;\n switch (type) {\n case TYPE_NULL:\n return data == DATA_NULL_EMPTY ? ResPrimitive.EMPTY : ResPrimitive.NULL;\n case TYPE_REFERENCE:\n case TYPE_DYNAMIC_REFERENCE:\n return new ResReference(pkg, ResId.of(data));\n case TYPE_ATTRIBUTE:\n case TYPE_DYNAMIC_ATTRIBUTE:\n return new ResReference(pkg, ResId.of(data), true);\n case TYPE_FLOAT:\n case TYPE_DIMENSION:\n case TYPE_FRACTION:\n return new ResPrimitive(type, data);\n }\n // Handle integer, boolean and color.\n if (type >= TYPE_FIRST_INT && type <= TYPE_LAST_INT) {\n return new ResPrimitive(type, data);\n }\n Log.w(TAG, \"Invalid value type: 0x%02x\", type);\n return null;\n }\n\n public int getType() {\n return mType;\n }\n\n public String getFormat() {\n switch (mType) {\n case TYPE_NULL:\n return null;\n case TYPE_REFERENCE:\n case TYPE_DYNAMIC_REFERENCE:\n case TYPE_ATTRIBUTE:\n case TYPE_DYNAMIC_ATTRIBUTE:\n return \"reference\";\n case TYPE_STRING:\n return \"string\";\n case TYPE_FLOAT:\n return \"float\";\n case TYPE_DIMENSION:\n return \"dimension\";\n case TYPE_FRACTION:\n return \"fraction\";\n case TYPE_INT_BOOLEAN:\n return \"boolean\";\n }\n if (mType >= TYPE_FIRST_COLOR_INT && mType <= TYPE_LAST_COLOR_INT) {\n return \"color\";\n }\n if (mType >= TYPE_FIRST_INT && mType <= TYPE_LAST_INT) {\n return \"integer\";\n }\n Log.w(TAG, \"Unexpected value type: 0x%02x\", mType);\n return null;\n }\n\n // Must never return null.\n public abstract String toXmlTextValue() throws AndrolibException;\n\n // Must never return null.\n public String toXmlAttributeValue() throws AndrolibException {\n return toXmlTextValue();\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResPlural.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.xml.ResStringEncoder;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Arrays;\n\npublic class ResPlural extends ResBag {\n private static final String TAG = ResPlural.class.getName();\n\n private static final int ATTR_OTHER = 0x01000004;\n private static final int ATTR_ZERO = 0x01000005;\n private static final int ATTR_ONE = 0x01000006;\n private static final int ATTR_TWO = 0x01000007;\n private static final int ATTR_FEW = 0x01000008;\n private static final int ATTR_MANY = 0x01000009;\n\n private final RawItem[] mItems;\n\n public ResPlural(ResReference parent, RawItem[] items) {\n super(parent);\n assert items != null;\n mItems = items;\n }\n\n public static ResPlural parse(ResReference parent, RawItem[] rawItems) {\n return new ResPlural(parent, rawItems);\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String tagName = \"plurals\";\n serial.startTag(null, tagName);\n serial.attribute(null, \"name\", entry.getName());\n\n for (RawItem item : mItems) {\n int key = item.getKey();\n String quantity;\n switch (key) {\n case ATTR_OTHER:\n quantity = \"other\";\n break;\n case ATTR_ZERO:\n quantity = \"zero\";\n break;\n case ATTR_ONE:\n quantity = \"one\";\n break;\n case ATTR_TWO:\n quantity = \"two\";\n break;\n case ATTR_FEW:\n quantity = \"few\";\n break;\n case ATTR_MANY:\n quantity = \"many\";\n break;\n default:\n Log.w(TAG, \"Invalid plurals key: 0x%08x\", key);\n continue;\n }\n\n ResItem value = item.getValue();\n String body = value.toXmlTextValue();\n if (!body.isEmpty()) {\n body = ResStringEncoder.normalizeFormatSpecifiers(body);\n }\n\n serial.startTag(null, \"item\");\n serial.attribute(null, \"quantity\", quantity);\n serial.text(body);\n serial.endTag(null, \"item\");\n }\n\n serial.endTag(null, tagName);\n }\n\n @Override\n public String toString() {\n return String.format(\"ResPlural{items=%s}\", Arrays.toString(mItems));\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResPlural) {\n ResPlural other = (ResPlural) obj;\n return Arrays.equals(mItems, other.mItems);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Arrays.hashCode(mItems);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResPrimitive.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Locale;\nimport java.util.Objects;\nimport java.util.Set;\n\npublic class ResPrimitive extends ResItem {\n private static final String TAG = ResPrimitive.class.getName();\n\n // Complex data\n private static final int COMPLEX_UNIT_MASK = 0xF;\n private static final int COMPLEX_RADIX_SHIFT = 4;\n private static final int COMPLEX_RADIX_MASK = 0x3;\n private static final int COMPLEX_MANTISSA_SHIFT = 8;\n private static final int COMPLEX_MANTISSA_MASK = 0xFFFFFF;\n private static final float MANTISSA_MULT = 1.0f / (1 << COMPLEX_MANTISSA_SHIFT);\n private static final float[] RADIX_MULTS = {\n MANTISSA_MULT, 1.0f / (1 << 7) * MANTISSA_MULT, 1.0f / (1 << 15) * MANTISSA_MULT,\n 1.0f / (1 << 23) * MANTISSA_MULT\n };\n\n // Complex units in TYPE_DIMENSION\n private static final int COMPLEX_UNIT_PX = 0;\n private static final int COMPLEX_UNIT_DIP = 1;\n private static final int COMPLEX_UNIT_SP = 2;\n private static final int COMPLEX_UNIT_PT = 3;\n private static final int COMPLEX_UNIT_IN = 4;\n private static final int COMPLEX_UNIT_MM = 5;\n\n // Complex units in TYPE_FRACTION\n private static final int COMPLEX_UNIT_FRACTION = 0;\n private static final int COMPLEX_UNIT_FRACTION_PARENT = 1;\n\n public static final ResPrimitive NULL = new ResPrimitive(TYPE_NULL, DATA_NULL_UNDEFINED);\n public static final ResPrimitive EMPTY = new ResPrimitive(TYPE_NULL, DATA_NULL_EMPTY);\n public static final ResPrimitive FALSE = new ResPrimitive(TYPE_INT_BOOLEAN, 0);\n public static final ResPrimitive TRUE = new ResPrimitive(TYPE_INT_BOOLEAN, 0xFFFFFFFF);\n\n private final int mData;\n\n public ResPrimitive(int type, int data) {\n super(type);\n mData = data;\n }\n\n public int getData() {\n return mData;\n }\n\n @Override\n public String toXmlTextValue() {\n switch (mType) {\n case TYPE_NULL:\n return mData == DATA_NULL_EMPTY ? \"@empty\" : \"@null\";\n case TYPE_FLOAT:\n return floatToString(Float.intBitsToFloat(mData));\n case TYPE_DIMENSION: {\n String value = floatToString(complexToFloat(mData));\n int unitType = mData & COMPLEX_UNIT_MASK;\n switch (unitType) {\n case COMPLEX_UNIT_PX:\n value += \"px\";\n break;\n case COMPLEX_UNIT_DIP:\n value += \"dp\";\n break;\n case COMPLEX_UNIT_SP:\n value += \"sp\";\n break;\n case COMPLEX_UNIT_PT:\n value += \"pt\";\n break;\n case COMPLEX_UNIT_IN:\n value += \"in\";\n break;\n case COMPLEX_UNIT_MM:\n value += \"mm\";\n break;\n default:\n Log.w(TAG, \"Unexpected value unit: \" + unitType);\n value += \"??\";\n break;\n }\n return value;\n }\n case TYPE_FRACTION: {\n String value = floatToString(complexToFloat(mData) * 100);\n int unitType = mData & COMPLEX_UNIT_MASK;\n switch (unitType) {\n case COMPLEX_UNIT_FRACTION:\n value += \"%\";\n break;\n case COMPLEX_UNIT_FRACTION_PARENT:\n value += \"%p\";\n break;\n default:\n Log.w(TAG, \"Unexpected value unit: \" + unitType);\n value += \"??\";\n break;\n }\n return value;\n }\n case TYPE_INT_BOOLEAN:\n return mData != 0 ? \"true\" : \"false\";\n }\n if (mType >= TYPE_FIRST_COLOR_INT && mType <= TYPE_LAST_COLOR_INT) {\n switch (mType) {\n default:\n case TYPE_INT_COLOR_ARGB8:\n return String.format(\"#%08x\", mData);\n case TYPE_INT_COLOR_RGB8:\n return String.format(\"#%06x\", mData & 0xFFFFFF);\n case TYPE_INT_COLOR_ARGB4:\n return String.format(\"#%x%x%x%x\",\n (mData >>> 28) & 0xF, (mData >>> 20) & 0xF,\n (mData >>> 12) & 0xF, (mData >>> 4) & 0xF);\n case TYPE_INT_COLOR_RGB4:\n return String.format(\"#%x%x%x\",\n (mData >>> 20) & 0xF, (mData >>> 12) & 0xF,\n (mData >>> 4) & 0xF);\n }\n }\n if (mType >= TYPE_FIRST_INT && mType <= TYPE_LAST_INT) {\n switch (mType) {\n default:\n case TYPE_INT_DEC:\n return Integer.toString(mData);\n case TYPE_INT_HEX:\n return String.format(\"0x%x\", mData);\n }\n }\n Log.w(TAG, \"Unexpected value type: 0x%02x\", mType);\n return \"\";\n }\n\n private static String floatToString(float value) {\n // Use one decimal to show it's a float for exact integers.\n if (value == (long) value) {\n return String.format(Locale.ROOT, \"%.1f\", value);\n }\n // Use Java's default minimal string representation.\n return Float.toString(value);\n }\n\n private static float complexToFloat(int complex) {\n return (complex & (COMPLEX_MANTISSA_MASK << COMPLEX_MANTISSA_SHIFT))\n * RADIX_MULTS[(complex >> COMPLEX_RADIX_SHIFT) & COMPLEX_RADIX_MASK];\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String typeName = entry.getType().getName();\n\n // Specify format for tags when the resource type doesn't directly support this value's format.\n Set stdFormats = STANDARD_TYPE_FORMATS.get(typeName);\n String format = stdFormats != null ? getFormat() : null;\n boolean asItem = format != null && !stdFormats.contains(format);\n\n String tagName = asItem ? \"item\" : typeName;\n serial.startTag(null, tagName);\n if (asItem) {\n serial.attribute(null, \"type\", typeName);\n }\n serial.attribute(null, \"name\", entry.getName());\n if (asItem) {\n serial.attribute(null, \"format\", format);\n }\n serial.text(toXmlTextValue());\n serial.endTag(null, tagName);\n }\n\n @Override\n public String toString() {\n return String.format(\"ResPrimitive{type=0x%02x, data=0x%08x}\", mType, mData);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResPrimitive) {\n ResPrimitive other = (ResPrimitive) obj;\n return mType == other.mType\n && mData == other.mData;\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mType, mData);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResReference.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.exceptions.UndefinedResObjectException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.ResEntrySpec;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResPackage;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Objects;\n\npublic class ResReference extends ResItem {\n private final ResPackage mPackage;\n private final ResId mResId;\n private final boolean mAsAttr;\n\n public ResReference(ResPackage pkg, ResId resId) {\n this(pkg, resId, false);\n }\n\n public ResReference(ResPackage pkg, ResId resId, boolean asAttr) {\n super(asAttr ? TYPE_ATTRIBUTE : TYPE_REFERENCE);\n assert pkg != null && resId != null;\n mPackage = pkg;\n mResId = resId;\n mAsAttr = asAttr;\n }\n\n public ResPackage getPackage() {\n return mPackage;\n }\n\n public ResId getResId() {\n return mResId;\n }\n\n public ResEntrySpec resolve() throws AndrolibException {\n if (mPackage != null && mResId != ResId.NULL) {\n ResId resId = fixDynamicResourceId(mResId);\n try {\n return mPackage.getTable().resolve(resId);\n } catch (UndefinedResObjectException ignored) {\n }\n }\n return null;\n }\n\n public ResEntry resolveEntry() throws AndrolibException {\n if (mPackage != null && mResId != ResId.NULL) {\n ResId resId = fixDynamicResourceId(mResId);\n try {\n return mPackage.getTable().resolveEntry(resId);\n } catch (UndefinedResObjectException ignored) {\n }\n }\n return null;\n }\n\n private ResId fixDynamicResourceId(ResId resId) {\n if (resId.pkgId() == 0 && mPackage.getId() != 0) {\n // If the package ID is 0x00, that means that a shared library is accessing its own local resource,\n // so fix it up with calling package ID.\n resId = ResId.of(mPackage.getId(), resId.typeId(), resId.entryId());\n }\n return resId;\n }\n\n @Override\n public String toXmlTextValue() throws AndrolibException {\n ResEntrySpec spec = resolve();\n if (spec == null) {\n // @null is a special primitive, not a true reference, but we have to fall back to it if we can't\n // resolve the reference.\n return \"@null\";\n }\n\n boolean includePackage = mPackage.getGroup() != spec.getPackage().getGroup();\n boolean includeType = !mAsAttr || !spec.getTypeSpec().getName().equals(\"attr\");\n return (mAsAttr ? \"?\" : \"@\")\n + (includePackage ? spec.getPackage().getName() + \":\" : \"\")\n + (includeType ? spec.getTypeSpec().getName() + \"/\" : \"\")\n + spec.getName();\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String typeName = entry.getType().getName();\n\n // A bag type with a reference value must be an tag.\n // Otherwise, when the decoded app is rebuilt, the reference will be lost.\n boolean asItem = entry.getType().isBagType();\n\n // Only set body if not @null or the entry is a tag.\n // @null is the default value for all item types except string.\n // Note: We never set @null to tags.\n boolean needsBody = resolve() != null || typeName.equals(\"string\");\n\n String tagName = asItem ? \"item\" : typeName;\n serial.startTag(null, tagName);\n if (asItem) {\n serial.attribute(null, \"type\", typeName);\n }\n serial.attribute(null, \"name\", entry.getName());\n if (needsBody) {\n serial.text(toXmlTextValue());\n }\n serial.endTag(null, tagName);\n }\n\n @Override\n public String toString() {\n return String.format(\"ResReference{pkg=%s, id=%s, type=%s}\", mPackage, mResId, mAsAttr ? \"attr\" : \"ref\");\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResReference) {\n ResReference other = (ResReference) obj;\n return mPackage.equals(other.mPackage)\n && mResId == other.mResId\n && mAsAttr == other.mAsAttr;\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mPackage, mResId, mAsAttr);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResString.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.xml.ResStringEncoder;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Set;\n\npublic class ResString extends ResItem {\n public static final ResString EMPTY = new ResString(\"\");\n\n private final CharSequence mValue;\n\n public ResString(CharSequence value) {\n super(TYPE_STRING);\n assert value != null;\n mValue = value;\n }\n\n public CharSequence getValue() {\n return mValue;\n }\n\n @Override\n public String toXmlTextValue() {\n return ResStringEncoder.encodeTextValue(mValue);\n }\n\n @Override\n public String toXmlAttributeValue() {\n return ResStringEncoder.encodeAttributeValue(mValue);\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String typeName = entry.getType().getName();\n\n // Specify format for tags when the resource type doesn't directly support this value's format.\n Set stdFormats = STANDARD_TYPE_FORMATS.get(typeName);\n String format = stdFormats != null ? getFormat() : null;\n boolean asItem = format != null && !stdFormats.contains(format);\n\n String tagName = asItem ? \"item\" : typeName;\n serial.startTag(null, tagName);\n if (asItem) {\n serial.attribute(null, \"type\", typeName);\n }\n serial.attribute(null, \"name\", entry.getName());\n if (asItem) {\n serial.attribute(null, \"format\", format);\n }\n if (!asItem && !isFormatted()) {\n serial.attribute(null, \"formatted\", \"false\");\n }\n String body = toXmlTextValue();\n if (!body.isEmpty()) {\n serial.text(body);\n }\n serial.endTag(null, tagName);\n }\n\n private boolean isFormatted() {\n if (mValue.length() == 0) {\n return true;\n }\n // Formatting must be disabled if the string has multiple sequential format specifier.\n int[][] specs = ResStringEncoder.findFormatSpecifiers(mValue.toString());\n int[] sequential = specs[0];\n int[] positional = specs[1];\n return sequential.length == 0 || sequential.length + positional.length <= 1;\n }\n\n @Override\n public String toString() {\n return String.format(\"ResString{value=%s}\", mValue);\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResString) {\n ResString other = (ResString) obj;\n return mValue.equals(other.mValue);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return mValue.hashCode();\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResStyle.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport brut.androlib.res.table.ResEntrySpec;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResPackage;\nimport brut.common.Log;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.Objects;\nimport java.util.Set;\n\npublic class ResStyle extends ResBag {\n private static final String TAG = ResStyle.class.getName();\n\n private final Item[] mItems;\n\n public ResStyle(ResReference parent, Item[] items) {\n super(parent);\n assert parent != null && items != null;\n mItems = items;\n }\n\n public static ResStyle parse(ResReference parent, RawItem[] rawItems) {\n Item[] items = new Item[rawItems.length];\n ResPackage pkg = parent.getPackage();\n\n for (int i = 0; i < rawItems.length; i++) {\n RawItem rawItem = rawItems[i];\n // A reference to the XML attribute.\n int keyId = rawItem.getKey();\n ResReference key = new ResReference(pkg, ResId.of(keyId));\n ResItem value = rawItem.getValue();\n\n items[i] = new Item(key, value);\n }\n\n return new ResStyle(parent, items);\n }\n\n public static class Item {\n private final ResReference mKey;\n private final ResItem mValue;\n\n public Item(ResReference key, ResItem value) {\n assert key != null && value != null;\n mKey = key;\n mValue = value;\n }\n\n public ResReference getKey() {\n return mKey;\n }\n\n public ResItem getValue() {\n return mValue;\n }\n }\n\n @Override\n public void resolveKeys() throws AndrolibException {\n ResPackage pkg = mParent.getPackage();\n boolean skipUnresolved = pkg.getTable().getConfig().isDecodeResolveLazy();\n\n for (Item item : mItems) {\n ResReference key = item.getKey();\n if (key.resolveEntry() != null) {\n continue;\n }\n\n ResId keyId = key.getResId();\n\n // #2836 - Skip item if the resource cannot be resolved.\n if (skipUnresolved || keyId.pkgId() != pkg.getId()) {\n Log.w(TAG, \"Unresolved style reference: key=%s, value=%s\", key, item.getValue());\n continue;\n }\n\n pkg.addEntrySpec(keyId.typeId(), keyId.entryId(), ResEntrySpec.DUMMY_PREFIX + keyId);\n pkg.addEntry(keyId.typeId(), keyId.entryId(), ResAttribute.DEFAULT);\n }\n }\n\n @Override\n public void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException {\n String tagName = \"style\";\n serial.startTag(null, tagName);\n serial.attribute(null, \"name\", entry.getName());\n if (mParent.resolve() != null) {\n serial.attribute(null, \"parent\", mParent.toXmlAttributeValue());\n } else if (entry.getName().indexOf('.') != -1) {\n serial.attribute(null, \"parent\", \"\");\n }\n\n ResPackage pkg = mParent.getPackage();\n boolean skipDuplicates = !pkg.getTable().getConfig().isAnalysisMode();\n Set processedKeys = new HashSet<>();\n for (Item item : mItems) {\n ResReference key = item.getKey();\n ResEntry keyEntry = key.resolveEntry();\n if (keyEntry == null) {\n continue;\n }\n\n ResId keyId = key.getResId();\n\n // #3400 - Skip duplicate items in styles.\n if (skipDuplicates && processedKeys.contains(keyId)) {\n continue;\n }\n\n processedKeys.add(keyId);\n\n boolean includePackage = pkg.getGroup() != keyEntry.getPackage().getGroup();\n String keyName = (includePackage ? keyEntry.getPackage().getName() + \":\" : \"\") + keyEntry.getName();\n\n ResItem value = item.getValue();\n String body;\n if (keyEntry.getValue() instanceof ResAttribute) {\n // Format the value with the attribute entry's value.\n ResAttribute keyValue = (ResAttribute) keyEntry.getValue();\n body = keyValue.formatAsTextValue(value);\n } else {\n Log.w(TAG, \"Unexpected style item key: \" + keyEntry);\n // Format the value with the default attribute.\n body = ResAttribute.DEFAULT.formatAsTextValue(value);\n }\n\n serial.startTag(null, \"item\");\n serial.attribute(null, \"name\", keyName);\n serial.text(body);\n serial.endTag(null, \"item\");\n }\n\n serial.endTag(null, tagName);\n }\n\n @Override\n public String toString() {\n return String.format(\"ResStyle{parent=%s, items=%s}\", mParent, Arrays.toString(mItems));\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj == this) {\n return true;\n }\n if (obj instanceof ResStyle) {\n ResStyle other = (ResStyle) obj;\n return mParent.equals(other.mParent)\n && Arrays.equals(mItems, other.mItems);\n }\n return false;\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(mParent, Arrays.hashCode(mItems));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResValue.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.table.value;\n\npublic abstract class ResValue {\n // The value contains no data.\n public static final int TYPE_NULL = 0x00;\n // The data field holds a resource identifier.\n public static final int TYPE_REFERENCE = 0x01;\n // The data field holds an attribute resource identifier (referencing an attribute in the current theme style, not\n // a resource entry).\n public static final int TYPE_ATTRIBUTE = 0x02;\n // The string field holds string data. In addition, if data is non-zero then it is the string block index of the\n // string and assetCookie is the set of assets the string came from.\n public static final int TYPE_STRING = 0x03;\n // The data field holds an IEEE 754 floating point number.\n public static final int TYPE_FLOAT = 0x04;\n // The data field holds a complex number encoding a dimension value.\n public static final int TYPE_DIMENSION = 0x05;\n // The data field holds a complex number encoding a fraction of a container.\n public static final int TYPE_FRACTION = 0x06;\n // The data holds a dynamic res table reference, which needs to be resolved before it can be used like\n // TYPE_REFERENCE.\n public static final int TYPE_DYNAMIC_REFERENCE = 0x07;\n // The data an attribute resource identifier, which needs to be resolved before it can be used like a\n // TYPE_ATTRIBUTE.\n public static final int TYPE_DYNAMIC_ATTRIBUTE = 0x08;\n // Identifies the start of plain integer values. Any type value from this to TYPE_LAST_INT means the data field\n // holds a generic integer value.\n public static final int TYPE_FIRST_INT = 0x10;\n // The data field holds a number that was originally specified in decimal.\n public static final int TYPE_INT_DEC = 0x10;\n // The data field holds a number that was originally specified in hexadecimal (0xn).\n public static final int TYPE_INT_HEX = 0x11;\n // The data field holds 0 or 1 that was originally specified as \"false\" or \"true\".\n public static final int TYPE_INT_BOOLEAN = 0x12;\n // Identifies the start of integer values that were specified as color constants (starting with '#').\n public static final int TYPE_FIRST_COLOR_INT = 0x1C;\n // The data field holds a color that was originally specified as #AARRGGBB.\n public static final int TYPE_INT_COLOR_ARGB8 = 0x1C;\n // The data field holds a color that was originally specified as #RRGGBB.\n public static final int TYPE_INT_COLOR_RGB8 = 0x1D;\n // The data field holds a color that was originally specified as #ARGB.\n public static final int TYPE_INT_COLOR_ARGB4 = 0x1E;\n // The data field holds a color that was originally specified as #RGB.\n public static final int TYPE_INT_COLOR_RGB4 = 0x1F;\n // Identifies the end of integer values that were specified as color constants.\n public static final int TYPE_LAST_COLOR_INT = 0x1F;\n // Identifies the end of plain integer values.\n public static final int TYPE_LAST_INT = 0x1F;\n\n // TYPE_NULL data indicating the value was not specified.\n public static final int DATA_NULL_UNDEFINED = 0;\n // TYPE_NULL data indicating the value was explicitly set to null.\n public static final int DATA_NULL_EMPTY = 1;\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResStringEncoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.xml;\n\nimport brut.androlib.res.data.StyledString;\nimport brut.androlib.res.table.value.ResAttribute;\nimport brut.util.TextUtils;\n\nimport java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.Deque;\nimport java.util.regex.Pattern;\n\npublic final class ResStringEncoder {\n private static final Pattern TAG_SPLIT_PATTERN = Pattern.compile(\";(?=[\\\\p{L}_][\\\\p{L}\\\\p{N}_.-]*=)\");\n\n private ResStringEncoder() {\n // Private constructor for utility class.\n }\n\n public static String encodeTextValue(CharSequence text) {\n return text instanceof StyledString\n ? encodeStyledString((StyledString) text)\n : encodeRawString(text.toString(), 0);\n }\n\n public static String encodeAttributeValue(CharSequence text) {\n return encodeAttributeValue(text, ResAttribute.ATTR_TYPE_ANY);\n }\n\n public static String encodeAttributeValue(CharSequence text, int attrType) {\n return encodeRawString(text.toString(), attrType);\n }\n\n private static String encodeStyledString(StyledString styledStr) {\n String str = styledStr.getValue();\n StyledString.Span[] spans = styledStr.getSpans();\n int len = str.length();\n if (len == 0 && spans.length == 0) {\n return \"\";\n }\n\n StringBuilder out = new StringBuilder(len * 2);\n Deque stack = new ArrayDeque<>();\n\n int offset = 0;\n for (int i = 0; i <= spans.length; i++) {\n int prevOffset = offset;\n StyledString.Span span;\n if (i < spans.length) {\n span = spans[i];\n offset = span.getFirstChar();\n } else {\n span = null;\n offset = len;\n }\n\n // Close nested spans that end before the current offset.\n while (!stack.isEmpty() && stack.peek().getLastChar() < offset) {\n StyledString.Span prevSpan = stack.pop();\n int prevSpanEnd = prevSpan.getLastChar() + 1;\n\n // Flush any remaining text inside this span.\n if (prevOffset < prevSpanEnd) {\n appendEscapedString(out, str, prevOffset, prevSpanEnd, 0, true);\n prevOffset = prevSpanEnd;\n }\n\n // Write the closing tag.\n String prevTag = prevSpan.getTag();\n int prevTagEnd = prevTag.indexOf(';');\n if (prevTagEnd == -1) {\n prevTagEnd = prevTag.length();\n }\n out.append(\"');\n }\n\n // Ignore spans that start beyond nested spans.\n if (prevOffset > offset) {\n continue;\n }\n\n // Flush any text between tags.\n if (prevOffset < offset) {\n appendEscapedString(out, str, prevOffset, offset, 0, true);\n }\n\n // Break if all spans have been handled.\n if (span == null) {\n break;\n }\n\n // Start current span.\n int spanEnd = span.getLastChar() + 1;\n String tag = span.getTag();\n int tagEnd = tag.indexOf(';');\n if (tagEnd == -1) {\n tagEnd = tag.length();\n }\n // Ignore this span if the tag is missing.\n if (tagEnd == 0) {\n continue;\n }\n\n // Write the opening tag.\n out.append('<').append(tag, 0, tagEnd);\n\n // Append the attributes.\n if (tagEnd < tag.length()) {\n for (String attr : TAG_SPLIT_PATTERN.split(tag.substring(tagEnd + 1))) {\n int attrLen = attr.length();\n if (attrLen == 0) {\n continue;\n }\n int nameEnd = attr.indexOf('=');\n if (nameEnd == -1) {\n continue;\n }\n int valueStart = nameEnd + 1;\n out.append(' ').append(attr, 0, valueStart).append('\"');\n if (valueStart < attrLen) {\n appendTagAttributeValue(out, attr, valueStart, attrLen);\n }\n out.append('\"');\n }\n }\n\n // Write as a self-closing tag if needed.\n if (offset == spanEnd) {\n out.append(\"/>\");\n continue;\n }\n\n // Push onto the stack for inner text and possible nested spans.\n out.append('>');\n stack.push(span);\n }\n\n return out.toString();\n }\n\n private static String encodeRawString(String str, int attrType) {\n int len = str.length();\n if (len == 0) {\n return \"\";\n }\n\n StringBuilder out = new StringBuilder(len * 2);\n appendEscapedString(out, str, 0, len, attrType, false);\n\n // Raw strings might get encoded as typed values in edge cases. We skip this if the string has been quoted.\n if (out.charAt(0) != '\"' && isAmbiguousString(out, attrType)) {\n out.insert(0, '\\\\');\n }\n\n return out.toString();\n }\n\n private static void appendEscapedString(StringBuilder out, String str, int start, int end, int attrType,\n boolean styled) {\n int len = str.length();\n int offset = out.length();\n boolean quote = false;\n char ch = 0, prev = 0, prev2 = 0;\n for (int i = start; i < end; i++, prev2 = prev, prev = ch) {\n ch = str.charAt(i);\n if (ch == '\\n') {\n if (attrType != 0) {\n out.append(\"\\\\n\");\n } else {\n out.append(ch);\n quote = true;\n }\n continue;\n } else if (ch == '\\t') {\n out.append(\"\\\\t\");\n continue;\n } else if (TextUtils.isPrintableChar(ch)) {\n if (ch == '\\\\') {\n out.append('\\\\');\n // fallthrough\n } else if (attrType == 0) {\n // The following are used for values XMLs only. The serializer will handle attribute values.\n if (ch == ' ') {\n // Normal strings collapse whitespace and trim both ends, while styled strings only collapse\n // whitespace.\n if (prev == ' ' || (!styled && (i == 0 || i == len - 1))) {\n quote = true;\n }\n // fallthrough\n } else if (ch == '\\'') {\n quote = true;\n // fallthrough\n } else if (ch == '\"') {\n out.append('\\\\');\n // fallthrough\n } else if (ch == '&') {\n out.append(\"&\");\n continue;\n } else if (ch == '<') {\n out.append(\"<\");\n continue;\n } else if (ch == '>' && prev == ']' && prev2 == ']') {\n out.append(\">\");\n continue;\n }\n // fallthrough\n }\n out.append(ch);\n continue;\n } else if (Character.isHighSurrogate(ch) && i < end - 1) {\n // Is this high surrogate followed by a valid low surrogate?\n char low = str.charAt(i + 1);\n if (Character.isLowSurrogate(low)) {\n out.append(ch);\n out.append(low);\n i++;\n continue;\n }\n // fallthrough\n }\n // Skip writing trailing \\u0000 if we are at end of string.\n if (ch == 0 && i == len - 1) {\n break;\n }\n // Java-style Unicode escape the non-printable character.\n out.append(String.format(\"\\\\u%04x\", (int) ch));\n }\n if (quote) {\n out.insert(offset, '\"').append('\"');\n }\n }\n\n private static boolean isAmbiguousString(CharSequence text, int attrType) {\n int len = text.length();\n char ch = text.charAt(0);\n\n // Check for a reference.\n // Note: We don't check attribute type here because a reference is valid for any type.\n if (ch == '@') {\n if (len == 5) {\n if (text.charAt(1) == 'n' && text.charAt(2) == 'u' && text.charAt(3) == 'l' && text.charAt(4) == 'l') {\n return true;\n }\n } else if (len == 6) {\n if (text.charAt(1) == 'e' && text.charAt(2) == 'm' && text.charAt(3) == 'p' && text.charAt(4) == 't'\n && text.charAt(5) == 'y') {\n return true;\n }\n }\n for (int i = 1; i < len; i++) {\n if (text.charAt(i) == '/') {\n return true;\n }\n }\n return false;\n }\n if (ch == '?') {\n return len > 1;\n }\n\n // The following can only be ambiguous in attribute values.\n // Note: We can't escape a boolean in attribute values since \\t is a tab.\n if (attrType == 0) {\n return false;\n }\n\n // Check for a color.\n if (ch == '#') {\n if ((attrType & ResAttribute.ATTR_TYPE_COLOR) != 0) {\n try {\n TextUtils.parseColor(text, 0, len);\n return true;\n } catch (NumberFormatException ignored) {\n }\n }\n return false;\n }\n\n // Check for an integer.\n if ((attrType & ResAttribute.ATTR_TYPE_INTEGER) != 0) {\n try {\n TextUtils.parseInt(text, 0, len);\n return true;\n } catch (NumberFormatException ignored) {\n }\n }\n\n // Check for a float or a complex value.\n boolean checkFloat = (attrType & ResAttribute.ATTR_TYPE_FLOAT) != 0;\n boolean checkDimen = (attrType & ResAttribute.ATTR_TYPE_DIMENSION) != 0;\n boolean checkFraction = (attrType & ResAttribute.ATTR_TYPE_FRACTION) != 0;\n if (checkFloat || checkDimen || checkFraction) {\n int suffixLen = 0;\n if (checkDimen) {\n String suffix = TextUtils.matchSuffix(\n text, \"px\", \"dp\", \"dip\", \"sp\", \"pt\", \"in\", \"mm\");\n if (suffix != null) {\n suffixLen = suffix.length();\n }\n }\n if (checkFraction && suffixLen == 0) {\n String suffix = TextUtils.matchSuffix(text, \"%\", \"%p\");\n if (suffix != null) {\n suffixLen = suffix.length();\n }\n }\n if ((checkFloat && suffixLen == 0) || suffixLen > 0) {\n try {\n TextUtils.parseFloat(text, 0, len - suffixLen);\n return true;\n } catch (NumberFormatException ignored) {\n }\n }\n }\n return false;\n }\n\n private static void appendTagAttributeValue(StringBuilder out, String str, int start, int end) {\n char ch = 0, prev = 0, prev2 = 0;\n for (int i = start; i < end; i++, prev2 = prev, prev = ch) {\n ch = str.charAt(i);\n if (ch == '\\n') {\n out.append(\" \");\n } else if (ch == '\\r') {\n out.append(\" \");\n } else if (ch == '\\t') {\n out.append(\" \");\n } else if (ch == '\"') {\n out.append(\""\");\n } else if (ch == '&') {\n out.append(\"&\");\n } else if (ch == '<') {\n out.append(\"<\");\n } else if (ch == '>' && prev == ']' && prev2 == ']') {\n out.append(\">\");\n } else {\n out.append(ch);\n }\n }\n }\n\n public static String normalizeFormatSpecifiers(String str) {\n int len = str.length();\n if (len == 0) {\n return str;\n }\n\n int[][] specs = findFormatSpecifiers(str);\n int[] sequential = specs[0];\n int[] positional = specs[1];\n if (sequential.length == 0 || sequential.length + positional.length < 2) {\n return str;\n }\n\n StringBuilder out = new StringBuilder(len + sequential.length * 2);\n int i = 0;\n int count = 0;\n for (int j : sequential) {\n out.append(str, i, ++j).append(++count).append('$');\n i = j;\n }\n\n out.append(str, i, len);\n return out.toString();\n }\n\n /**\n * Returns a pair of int arrays:\n * 1. Offsets of sequential format specifiers. (e.g. %s, %d, etc.)\n * 2. Offsets of positional format specifiers. (e.g. %1$s, %2$d, etc.)\n */\n public static int[][] findFormatSpecifiers(String str) {\n int[] sequential = new int[4];\n int sequentialCount = 0;\n int[] positional = new int[4];\n int positionalCount = 0;\n\n int len = str.length();\n int i, j = 0;\n while ((i = str.indexOf('%', j)) != -1) {\n j = i + 1;\n if (j == len) {\n if (sequentialCount == sequential.length) {\n sequential = Arrays.copyOf(sequential, sequential.length + 4);\n }\n sequential[sequentialCount++] = i - 1;\n break;\n }\n\n char ch = str.charAt(j++);\n if (ch == '%') {\n continue;\n }\n if (ch >= '0' && ch <= '9' && j < len) {\n while ((ch = str.charAt(j++)) >= '0' && ch <= '9' && j < len);\n if (ch == '$') {\n if (positionalCount == positional.length) {\n positional = Arrays.copyOf(positional, positional.length + 4);\n }\n positional[positionalCount++] = i;\n continue;\n }\n }\n\n if (sequentialCount == sequential.length) {\n sequential = Arrays.copyOf(sequential, sequential.length + 4);\n }\n sequential[sequentialCount++] = i;\n }\n\n if (sequentialCount < sequential.length) {\n sequential = Arrays.copyOf(sequential, sequentialCount);\n }\n if (positionalCount < positional.length) {\n positional = Arrays.copyOf(positional, positionalCount);\n }\n\n return new int[][] { sequential, positional };\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlSerializer.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.xml;\n\nimport brut.common.Log;\nimport brut.util.TextUtils;\nimport brut.xml.XmlUtils;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.io.OutputStreamWriter;\nimport java.io.Writer;\nimport java.nio.charset.StandardCharsets;\nimport java.util.Arrays;\n\npublic class ResXmlSerializer implements XmlSerializer {\n private static final String TAG = ResXmlSerializer.class.getName();\n private static final String NOT_SUPPORTED = \"Method is not supported.\";\n\n private static final int BUFFER_SIZE = 8192;\n\n private final boolean mAutoEscape;\n private final char[] mBuffer;\n private boolean[] mIndent;\n private String[] mElementStack;\n private int[] mNamespaceCounts;\n private String[] mNamespaceStack;\n\n private Writer mWriter;\n private int mDepth;\n private boolean mPending;\n private int mAutoNamespace;\n private int mBufferIndex;\n\n public ResXmlSerializer(boolean autoEscape) {\n mAutoEscape = autoEscape;\n mBuffer = new char[BUFFER_SIZE];\n mIndent = new boolean[4];\n mElementStack = new String[12];\n mNamespaceCounts = new int[6];\n mNamespaceStack = new String[12];\n }\n\n // XmlSerializer\n\n @Override\n public void setFeature(String name, boolean state) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public boolean getFeature(String name) {\n return false;\n }\n\n @Override\n public void setProperty(String name, Object value) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public Object getProperty(String name) {\n return null;\n }\n\n @Override\n public void setOutput(OutputStream os, String encoding) throws IOException {\n if (encoding != null && !encoding.equalsIgnoreCase(StandardCharsets.UTF_8.name())) {\n throw new UnsupportedOperationException();\n }\n setOutput(new OutputStreamWriter(os, StandardCharsets.UTF_8));\n }\n\n @Override\n public void setOutput(Writer writer) {\n mWriter = writer;\n mDepth = 0;\n mIndent[0] = true;\n mPending = false;\n mAutoNamespace = 0;\n mNamespaceCounts[0] = 3;\n mNamespaceCounts[1] = 3;\n mNamespaceStack[0] = \"\";\n mNamespaceStack[1] = \"\";\n mNamespaceStack[2] = XmlUtils.XML_PREFIX;\n mNamespaceStack[3] = XmlUtils.XML_URI;\n mNamespaceStack[4] = XmlUtils.XMLNS_PREFIX;\n mNamespaceStack[5] = XmlUtils.XMLNS_URI;\n }\n\n @Override\n public void startDocument(String encoding, Boolean standalone) throws IOException {\n write(XmlUtils.XML_PROLOG);\n }\n\n @Override\n public void endDocument() throws IOException {\n while (mDepth > 0) {\n endTag(mElementStack[mDepth * 3 - 3], mElementStack[mDepth * 3 - 1]);\n }\n write(System.lineSeparator());\n flush();\n }\n\n @Override\n public void setPrefix(String prefix, String namespace) throws IOException {\n check(false);\n if (prefix == null) {\n prefix = \"\";\n }\n if (namespace == null) {\n namespace = \"\";\n }\n\n // Ignore identical prefix definitions.\n if (prefix.equals(getPrefix(namespace, true, false))) {\n return;\n }\n\n int i = (mNamespaceCounts[mDepth + 1]++) << 1;\n if (mNamespaceStack.length < i + 1) {\n String[] newStack = new String[mNamespaceStack.length + 16];\n System.arraycopy(mNamespaceStack, 0, newStack, 0, i);\n mNamespaceStack = newStack;\n }\n\n mNamespaceStack[i++] = prefix;\n mNamespaceStack[i] = namespace;\n }\n\n @Override\n public String getPrefix(String namespace, boolean generatePrefix) {\n try {\n return getPrefix(namespace, false, generatePrefix);\n }\n catch (IOException ex) {\n throw new RuntimeException(ex);\n }\n }\n\n private String getPrefix(String namespace, boolean includeDefault, boolean generatePrefix) throws IOException {\n for (int i = mNamespaceCounts[mDepth + 1] * 2 - 2; i >= 0; i -= 2) {\n if (mNamespaceStack[i + 1].equals(namespace) && (includeDefault || !mNamespaceStack[i].isEmpty())) {\n String candidate = mNamespaceStack[i];\n for (int j = i + 2; j < mNamespaceCounts[mDepth + 1] * 2; j++) {\n if (mNamespaceStack[j].equals(candidate)) {\n candidate = null;\n break;\n }\n }\n if (candidate != null) {\n return candidate;\n }\n }\n }\n\n if (!generatePrefix) {\n return null;\n }\n\n String prefix;\n if (namespace.isEmpty()) {\n prefix = \"\";\n } else {\n do {\n prefix = \"n\" + (mAutoNamespace++);\n for (int i = mNamespaceCounts[mDepth + 1] * 2 - 2; i >= 0; i -= 2) {\n if (prefix.equals(mNamespaceStack[i])) {\n prefix = null;\n break;\n }\n }\n }\n while (prefix == null);\n }\n\n boolean pending = mPending;\n mPending = false;\n setPrefix(prefix, namespace);\n mPending = pending;\n return prefix;\n }\n\n @Override\n public int getDepth() {\n return mPending ? mDepth + 1 : mDepth;\n }\n\n @Override\n public String getNamespace() {\n int depth = getDepth();\n return depth > 0 ? mElementStack[depth * 3 - 3] : null;\n }\n\n @Override\n public String getName() {\n int depth = getDepth();\n return depth > 0 ? mElementStack[depth * 3 - 1] : null;\n }\n\n @Override\n public XmlSerializer startTag(String namespace, String name) throws IOException {\n check(false);\n writeIndent();\n\n int i = mDepth * 3;\n if (mElementStack.length < i + 3) {\n String[] newStack = new String[mElementStack.length + 12];\n System.arraycopy(mElementStack, 0, newStack, 0, i);\n mElementStack = newStack;\n }\n\n String prefix = namespace != null ? getPrefix(namespace, true, true) : \"\";\n if (namespace != null && namespace.isEmpty()) {\n for (int j = mNamespaceCounts[mDepth]; j < mNamespaceCounts[mDepth + 1]; j++) {\n if (mNamespaceStack[j * 2].isEmpty() && !mNamespaceStack[j * 2 + 1].isEmpty()) {\n throw new IllegalStateException(\"Could not set default namespace for elements in no namespace.\");\n }\n }\n }\n\n mElementStack[i++] = namespace;\n mElementStack[i++] = prefix;\n mElementStack[i] = name;\n\n write('<');\n if (!prefix.isEmpty()) {\n write(prefix);\n write(':');\n }\n write(name);\n\n mIndent[mDepth] = true;\n mPending = true;\n return this;\n }\n\n @Override\n public XmlSerializer endTag(String namespace, String name) throws IOException {\n if (!mPending) {\n mDepth--;\n }\n if ((namespace == null && mElementStack[mDepth * 3] != null)\n || (namespace != null && !namespace.equals(mElementStack[mDepth * 3]))\n || !mElementStack[mDepth * 3 + 2].equals(name)) {\n throw new IllegalArgumentException(\" does not match start.\");\n }\n\n if (mPending) {\n check(true);\n mDepth--;\n } else {\n if (mIndent[mDepth + 1]) {\n writeIndent();\n }\n write(\"');\n }\n\n mNamespaceCounts[mDepth + 1] = mNamespaceCounts[mDepth];\n return this;\n }\n\n @Override\n public XmlSerializer attribute(String namespace, String name, String value) throws IOException {\n if (!mPending) {\n throw new IllegalStateException(\"Illegal position for attribute.\");\n }\n if (namespace == null) {\n namespace = \"\";\n }\n\n write(' ');\n String prefix = !namespace.isEmpty() ? getPrefix(namespace, false, true) : \"\";\n if (!prefix.isEmpty()) {\n write(prefix);\n write(':');\n }\n write(name);\n write(\"=\\\"\");\n if (mAutoEscape) {\n writeEscaped(value, true);\n } else {\n write(value);\n }\n write('\"');\n return this;\n }\n\n @Override\n public XmlSerializer text(String text) throws IOException {\n check(false);\n mIndent[mDepth] = false;\n if (mAutoEscape) {\n writeEscaped(text, false);\n } else {\n write(text);\n }\n return this;\n }\n\n @Override\n public XmlSerializer text(char[] buf, int start, int len) throws IOException {\n return text(new String(buf, start, len));\n }\n\n @Override\n public void cdsect(String text) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public void entityRef(String text) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public void processingInstruction(String text) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public void comment(String text) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public void docdecl(String text) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public void ignorableWhitespace(String text) {\n throw new IllegalStateException(NOT_SUPPORTED);\n }\n\n @Override\n public void flush() throws IOException {\n check(false);\n flushBuffer();\n }\n\n // Utility methods\n\n private void check(boolean close) throws IOException {\n if (!mPending) {\n return;\n }\n if (mIndent[mDepth] && mNamespaceCounts[mDepth] < mNamespaceCounts[mDepth + 1]) {\n writeIndent();\n write(' ');\n }\n\n mPending = false;\n mDepth++;\n\n if (mIndent.length <= mDepth) {\n boolean[] newIndent = new boolean[mDepth + 4];\n System.arraycopy(mIndent, 0, newIndent, 0, mDepth);\n mIndent = newIndent;\n }\n mIndent[mDepth] = mIndent[mDepth - 1];\n\n for (int i = mNamespaceCounts[mDepth - 1]; i < mNamespaceCounts[mDepth]; i++) {\n String prefix = mNamespaceStack[i * 2];\n String uri = mNamespaceStack[i * 2 + 1];\n write(\" xmlns\");\n if (!prefix.isEmpty()) {\n write(':');\n write(prefix);\n } else if (getNamespace().isEmpty() && !uri.isEmpty()) {\n throw new IllegalStateException(\"Could not set default namespace for elements in no namespace.\");\n }\n write(\"=\\\"\");\n if (mAutoEscape) {\n writeEscaped(uri, true);\n } else {\n write(uri);\n }\n write('\"');\n }\n\n if (mNamespaceCounts.length <= mDepth + 1) {\n int[] newCounts = new int[mDepth + 8];\n System.arraycopy(mNamespaceCounts, 0, newCounts, 0, mDepth + 1);\n mNamespaceCounts = newCounts;\n }\n\n mNamespaceCounts[mDepth + 1] = mNamespaceCounts[mDepth];\n\n if (close) {\n write(\" />\");\n } else {\n write('>');\n }\n }\n\n private void flushBuffer() throws IOException {\n if (mBufferIndex > 0) {\n mWriter.write(mBuffer, 0, mBufferIndex);\n mWriter.flush();\n mBufferIndex = 0;\n }\n }\n\n private void writeIndent() throws IOException {\n write(System.lineSeparator());\n int len = mDepth * 4;\n while (len > 0) {\n if (mBufferIndex == BUFFER_SIZE) {\n flushBuffer();\n }\n int batch = BUFFER_SIZE - mBufferIndex;\n if (batch > len) {\n batch = len;\n }\n Arrays.fill(mBuffer, mBufferIndex, mBufferIndex + batch, ' ');\n len -= batch;\n mBufferIndex += batch;\n }\n }\n\n private void write(char ch) throws IOException {\n if (mBufferIndex >= BUFFER_SIZE) {\n flushBuffer();\n }\n mBuffer[mBufferIndex++] = ch;\n }\n\n private void write(String str) throws IOException {\n write(str, 0, str.length());\n }\n\n private void write(String str, int start, int len) throws IOException {\n while (len > 0) {\n if (mBufferIndex == BUFFER_SIZE) {\n flushBuffer();\n }\n int batch = BUFFER_SIZE - mBufferIndex;\n if (batch > len) {\n batch = len;\n }\n str.getChars(start, start + batch, mBuffer, mBufferIndex);\n start += batch;\n len -= batch;\n mBufferIndex += batch;\n }\n }\n\n /**\n * Only used to safely serialize manifest and resource XMLs.\n * Must be disabled when serializing values XMLs.\n */\n private void writeEscaped(String str, boolean attr) throws IOException {\n char ch = 0, prev = 0, prev2 = 0;\n for (int i = 0, n = str.length(); i < n; i++, prev2 = prev, prev = ch) {\n ch = str.charAt(i);\n if (ch == '\\n') {\n if (attr) {\n write(\" \");\n continue;\n }\n // fallthrough\n } else if (ch == '\\r') {\n if (attr) {\n write(\" \");\n continue;\n }\n // fallthrough\n } else if (ch == '\\t') {\n if (attr) {\n write(\" \");\n continue;\n }\n // fallthrough\n } else if (ch == '\"') {\n if (attr) {\n write(\""\");\n continue;\n }\n // fallthrough\n } else if (ch == '&') {\n write(\"&\");\n continue;\n } else if (ch == '<') {\n write(\"<\");\n continue;\n } else if (ch == '>') {\n if (prev == ']' && prev2 == ']') {\n write(\">\");\n continue;\n }\n // fallthrough\n } else if (TextUtils.isPrintableChar(ch)) {\n // fallthrough\n } else if (Character.isHighSurrogate(ch) && i < n - 1) {\n // Is this high surrogate followed by a valid low surrogate?\n char low = str.charAt(i + 1);\n if (Character.isLowSurrogate(low)) {\n write(ch);\n write(low);\n i++;\n } else {\n Log.w(TAG, \"Bad surrogate pair (U+%04x U+%04x)\", (int) ch, (int) low);\n }\n continue;\n } else {\n Log.w(TAG, \"Illegal character (U+%04x)\", (int) ch);\n continue;\n }\n write(ch);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlUtils.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.xml;\n\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.*;\nimport org.xml.sax.SAXException;\n\nimport javax.xml.parsers.ParserConfigurationException;\nimport javax.xml.transform.TransformerException;\nimport javax.xml.xpath.XPathExpressionException;\nimport java.io.*;\nimport java.util.*;\n\npublic final class ResXmlUtils {\n public static final String ANDROID_RES_NS = \"http://schemas.android.com/apk/res/android\";\n public static final String ANDROID_RES_NS_AUTO = \"http://schemas.android.com/apk/res-auto\";\n\n private ResXmlUtils() {\n // Private constructor for utility class.\n }\n\n /**\n * Sets \"debuggable\" attribute to true for application.\n *\n * @param file File for AndroidManifest.xml\n */\n public static void setApplicationDebugTagTrue(File file) {\n try {\n Document doc = XmlUtils.loadDocument(file);\n Node application = doc.getElementsByTagName(\"application\").item(0);\n NamedNodeMap attrs = application.getAttributes();\n boolean changed = false;\n\n Node debugAttr = attrs.getNamedItem(\"android:debuggable\");\n if (debugAttr == null) {\n debugAttr = doc.createAttribute(\"android:debuggable\");\n debugAttr.setNodeValue(\"true\");\n attrs.setNamedItem(debugAttr);\n changed = true;\n } else if (!debugAttr.getNodeValue().equals(\"true\")) {\n debugAttr.setNodeValue(\"true\");\n changed = true;\n }\n\n if (changed) {\n XmlUtils.saveDocument(doc, file);\n }\n } catch (IOException | SAXException | ParserConfigurationException | TransformerException ignored) {\n }\n }\n\n /**\n * Sets the network security config attribute for application.\n *\n * @param file File for AndroidManifest.xml\n */\n public static void setNetworkSecurityConfig(File file) {\n try {\n Document doc = XmlUtils.loadDocument(file);\n Node application = doc.getElementsByTagName(\"application\").item(0);\n NamedNodeMap attrs = application.getAttributes();\n boolean changed = false;\n\n Node netSecConfAttr = attrs.getNamedItem(\"android:networkSecurityConfig\");\n if (netSecConfAttr == null) {\n netSecConfAttr = doc.createAttribute(\"android:networkSecurityConfig\");\n netSecConfAttr.setNodeValue(\"@xml/network_security_config\");\n attrs.setNamedItem(netSecConfAttr);\n changed = true;\n } else if (!netSecConfAttr.getNodeValue().equals(\"@xml/network_security_config\")) {\n netSecConfAttr.setNodeValue(\"@xml/network_security_config\");\n changed = true;\n }\n\n if (changed) {\n XmlUtils.saveDocument(doc, file);\n }\n } catch (IOException | SAXException | ParserConfigurationException | TransformerException ignored) {\n }\n }\n\n /**\n * Modifies a network security config to be more permissive.\n *\n * @param file Network security config file\n */\n public static void modNetworkSecurityConfig(File file) {\n try {\n Document doc;\n if (file.exists()) {\n doc = XmlUtils.loadDocument(file);\n doc.getDocumentElement().normalize();\n } else {\n doc = XmlUtils.newDocument();\n }\n boolean changed = false;\n\n Element root = (Element) doc.getElementsByTagName(\"network-security-config\").item(0);\n if (root == null) {\n root = doc.createElement(\"network-security-config\");\n doc.appendChild(root);\n changed = true;\n }\n\n Element baseConfig = (Element) root.getElementsByTagName(\"base-config\").item(0);\n if (baseConfig == null) {\n baseConfig = doc.createElement(\"base-config\");\n root.appendChild(baseConfig);\n changed = true;\n }\n\n Element trustAnchors = (Element) baseConfig.getElementsByTagName(\"trust-anchors\").item(0);\n if (trustAnchors == null) {\n trustAnchors = doc.createElement(\"trust-anchors\");\n baseConfig.appendChild(trustAnchors);\n changed = true;\n }\n\n NodeList certificates = trustAnchors.getElementsByTagName(\"certificates\");\n boolean hasSystemCert = false;\n boolean hasUserCert = false;\n for (int i = 0; i < certificates.getLength(); i++) {\n Element cert = (Element) certificates.item(i);\n String src = cert.getAttribute(\"src\");\n if (src.equals(\"system\")) {\n hasSystemCert = true;\n } else if (src.equals(\"user\")) {\n hasUserCert = true;\n }\n }\n\n if (!hasSystemCert) {\n Element certSystem = doc.createElement(\"certificates\");\n certSystem.setAttribute(\"src\", \"system\");\n trustAnchors.appendChild(certSystem);\n changed = true;\n }\n\n if (!hasUserCert) {\n Element certUser = doc.createElement(\"certificates\");\n certUser.setAttribute(\"src\", \"user\");\n trustAnchors.appendChild(certUser);\n changed = true;\n }\n\n if (changed) {\n XmlUtils.saveDocument(doc, file);\n }\n } catch (IOException | SAXException | ParserConfigurationException | TransformerException ignored) {\n }\n }\n\n /**\n * Removes attributes like \"versionCode\" and \"versionName\" from file.\n *\n * @param file File for AndroidManifest.xml\n */\n public static void removeManifestVersions(File file) {\n try {\n Document doc = XmlUtils.loadDocument(file);\n Node manifest = doc.getFirstChild();\n NamedNodeMap attrs = manifest.getAttributes();\n boolean changed = false;\n\n Node versionCodeAttr = attrs.getNamedItem(\"android:versionCode\");\n if (versionCodeAttr != null) {\n attrs.removeNamedItem(\"android:versionCode\");\n changed = true;\n }\n\n Node versionNameAttr = attrs.getNamedItem(\"android:versionName\");\n if (versionNameAttr != null) {\n attrs.removeNamedItem(\"android:versionName\");\n changed = true;\n }\n\n if (changed) {\n XmlUtils.saveDocument(doc, file);\n }\n } catch (IOException | SAXException | ParserConfigurationException | TransformerException ignored) {\n }\n }\n\n /**\n * Finds all feature flags set on permissions in AndroidManifest.xml.\n *\n * @param file File for AndroidManifest.xml\n * @return String[]|null\n */\n public static String[] pullManifestFeatureFlags(File file) {\n try {\n Document doc = XmlUtils.loadDocument(file, true);\n String expression = \"/manifest//@android:featureFlag\";\n NodeList nodes = XmlUtils.evaluateXPath(doc, expression, NodeList.class);\n\n String[] featureFlags = new String[nodes.getLength()];\n\n for (int i = 0; i < featureFlags.length; i++) {\n featureFlags[i] = nodes.item(i).getNodeValue();\n }\n\n return featureFlags;\n } catch (IOException | SAXException | ParserConfigurationException | XPathExpressionException ignored) {\n return null;\n }\n }\n\n /**\n * Any @string reference in a provider value in AndroidManifest.xml will break on\n * build, thus preventing the application from installing. This is from a bug/error\n * in AOSP where public resources cannot be part of an authorities attribute within\n * a provider tag.\n *

\n * This finds any reference and replaces it with the literal value found in the\n * res/values/strings.xml file.\n *\n * @param file File for AndroidManifest.xml\n */\n public static void fixingPublicAttrsInProviderAttributes(File file) {\n try {\n Document doc = XmlUtils.loadDocument(file, true);\n boolean changed = false;\n\n String expression = \"/manifest/application/provider/@android:authorities\";\n NodeList nodes = XmlUtils.evaluateXPath(doc, expression, NodeList.class);\n\n for (int i = 0; i < nodes.getLength(); i++) {\n if (replaceStringReference(file, nodes.item(i))) {\n changed = true;\n }\n }\n\n expression = \"/manifest/application/activity/intent-filter/data/@android:scheme\";\n nodes = XmlUtils.evaluateXPath(doc, expression, NodeList.class);\n\n for (int i = 0; i < nodes.getLength(); i++) {\n if (replaceStringReference(file, nodes.item(i))) {\n changed = true;\n }\n }\n\n if (changed) {\n XmlUtils.saveDocument(doc, file);\n }\n } catch (IOException | SAXException | ParserConfigurationException | XPathExpressionException\n | TransformerException ignored) {\n }\n }\n\n /**\n * Replaces a string reference in a node with the referenced string.\n * Returns true if the replacement was properly made to a node, false otherwise.\n *\n * @param file File we are searching for value\n * @param node Node with a string reference\n * @return boolean\n */\n private static boolean replaceStringReference(File file, Node node) {\n String replacement = pullValueFromStrings(file.getParentFile(), node.getNodeValue());\n if (replacement == null) {\n return false;\n }\n\n node.setNodeValue(replacement);\n return true;\n }\n\n /**\n * Finds key in strings.xml file and returns text value.\n *\n * @param apkDir Root directory of apk\n * @param key String reference (ie @string/foo)\n * @return String|null\n */\n public static String pullValueFromStrings(File apkDir, String key) {\n return pullValueFromXml(new File(apkDir, \"res/values/strings.xml\"), \"string\", key);\n }\n\n /**\n * Finds key in integers.xml file and returns text value.\n *\n * @param apkDir Root directory of apk\n * @param key Integer reference (ie @integer/foo)\n * @return String|null\n */\n public static String pullValueFromIntegers(File apkDir, String key) {\n return pullValueFromXml(new File(apkDir, \"res/values/integers.xml\"), \"integer\", key);\n }\n\n /**\n * Finds key in a values XML file and returns text value.\n *\n * @param file File to pull the value from\n * @param type Resource type\n * @param key Resource reference\n * @return String|null\n */\n private static String pullValueFromXml(File file, String type, String key) {\n if (!file.isFile() || key == null || key.indexOf('@') == -1) {\n return null;\n }\n\n key = key.replace(\"@\" + type + \"/\", \"\");\n try {\n Document doc = XmlUtils.loadDocument(file);\n String expression = String.format(\"/resources/%s[@name='%s']/text()\", type, key);\n\n return XmlUtils.evaluateXPath(doc, expression, String.class);\n } catch (IOException | SAXException | ParserConfigurationException | XPathExpressionException ignored) {\n return null;\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ValuesXmlSerializable.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.xml;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.androlib.res.table.ResEntry;\nimport org.xmlpull.v1.XmlSerializer;\n\nimport java.io.IOException;\n\npublic interface ValuesXmlSerializable {\n void serializeToValuesXml(XmlSerializer serial, ResEntry entry) throws AndrolibException, IOException;\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/smali/SmaliBuilder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.smali;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.directory.DirectoryException;\nimport brut.directory.FileDirectory;\nimport brut.common.Log;\nimport brut.util.OS;\nimport com.android.tools.smali.dexlib2.Opcodes;\nimport com.android.tools.smali.dexlib2.writer.builder.DexBuilder;\nimport com.android.tools.smali.dexlib2.writer.io.FileDataStore;\nimport com.android.tools.smali.smali.smaliFlexLexer;\nimport com.android.tools.smali.smali.smaliParser;\nimport com.android.tools.smali.smali.smaliTreeWalker;\nimport org.antlr.runtime.CommonTokenStream;\nimport org.antlr.runtime.RecognitionException;\nimport org.antlr.runtime.Token;\nimport org.antlr.runtime.tree.CommonTree;\nimport org.antlr.runtime.tree.CommonTreeNodeStream;\n\nimport java.io.File;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\nimport java.nio.charset.StandardCharsets;\nimport java.nio.file.Files;\n\npublic class SmaliBuilder {\n private static final String TAG = SmaliBuilder.class.getName();\n\n private static final boolean VERBOSE_ERRORS = false;\n private static final boolean PRINT_TOKENS = false;\n\n private final int mApiLevel;\n\n public SmaliBuilder(int apiLevel) {\n // #3641 - Limit opcode API level to 29 or below (dex version up to 039).\n mApiLevel = Math.min(apiLevel, 29);\n }\n\n public void build(File smaliDir, File dexFile) throws AndrolibException {\n try {\n DexBuilder dexBuilder = new DexBuilder(mApiLevel > 0 ? Opcodes.forApi(mApiLevel) : Opcodes.getDefault());\n\n for (String fileName : new FileDirectory(smaliDir).getFiles(true)) {\n if (!fileName.endsWith(\".smali\")) {\n Log.w(TAG, \"Unknown file type, ignoring: \" + fileName);\n continue;\n }\n\n buildFile(smaliDir, fileName, dexBuilder);\n }\n\n if (dexFile.exists()) {\n OS.rmfile(dexFile);\n } else {\n File parentDir = dexFile.getParentFile();\n if (parentDir != null) {\n OS.mkdir(parentDir);\n }\n }\n\n dexBuilder.writeTo(new FileDataStore(dexFile));\n } catch (DirectoryException | IOException | RuntimeException ex) {\n throw new AndrolibException(\"Could not smali folder: \" + smaliDir.getName(), ex);\n }\n }\n\n private void buildFile(File smaliDir, String dexName, DexBuilder dexBuilder) throws AndrolibException {\n boolean success;\n Exception cause;\n try {\n File smaliFile = new File(smaliDir, dexName);\n success = buildFile(smaliFile, dexBuilder);\n cause = null;\n } catch (Exception ex) {\n success = false;\n cause = ex;\n }\n if (!success) {\n AndrolibException ex = new AndrolibException(\"Could not smali file: \" + dexName);\n if (cause != null) {\n ex.initCause(cause);\n }\n throw ex;\n }\n }\n\n private boolean buildFile(File smaliFile, DexBuilder dexBuilder) throws IOException, RecognitionException {\n try (InputStreamReader reader = new InputStreamReader(\n Files.newInputStream(smaliFile.toPath()), StandardCharsets.UTF_8)) {\n smaliFlexLexer lexer = new smaliFlexLexer(reader, mApiLevel);\n lexer.setSourceFile(smaliFile);\n\n CommonTokenStream tokens = new CommonTokenStream(lexer);\n\n if (PRINT_TOKENS) {\n for (Token token : tokens.getTokens()) {\n if (token.getChannel() != smaliParser.HIDDEN) {\n System.out.println(smaliParser.tokenNames[token.getType()] + \": \" + token.getText());\n }\n }\n }\n\n smaliParser parser = new smaliParser(tokens);\n parser.setApiLevel(mApiLevel);\n parser.setVerboseErrors(VERBOSE_ERRORS);\n\n smaliParser.smali_file_return result = parser.smali_file();\n\n if (parser.getNumberOfSyntaxErrors() > 0 || lexer.getNumberOfSyntaxErrors() > 0) {\n return false;\n }\n\n CommonTree tree = result.getTree();\n CommonTreeNodeStream treeStream = new CommonTreeNodeStream(tree);\n treeStream.setTokenStream(tokens);\n\n smaliTreeWalker treeWalker = new smaliTreeWalker(treeStream);\n treeWalker.setApiLevel(mApiLevel);\n treeWalker.setVerboseErrors(VERBOSE_ERRORS);\n treeWalker.setDexBuilder(dexBuilder);\n treeWalker.smali_file();\n\n return treeWalker.getNumberOfSyntaxErrors() == 0;\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/main/java/brut/androlib/smali/SmaliDecoder.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.smali;\n\nimport brut.androlib.exceptions.AndrolibException;\nimport brut.util.OS;\nimport com.android.tools.smali.baksmali.Baksmali;\nimport com.android.tools.smali.baksmali.BaksmaliOptions;\nimport com.android.tools.smali.dexlib2.DexFileFactory;\nimport com.android.tools.smali.dexlib2.analysis.InlineMethodResolver;\nimport com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile;\nimport com.android.tools.smali.dexlib2.dexbacked.DexBackedOdexFile;\nimport com.android.tools.smali.dexlib2.iface.DexFile;\nimport com.android.tools.smali.dexlib2.iface.MultiDexContainer;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.HashSet;\nimport java.util.Set;\n\npublic class SmaliDecoder {\n private final File mApkFile;\n private final boolean mDebugMode;\n private final Set mDexFiles;\n private int mInferredApiLevel;\n\n public SmaliDecoder(File apkFile, boolean debugMode) {\n mApkFile = apkFile;\n mDebugMode = debugMode;\n mDexFiles = new HashSet<>();\n }\n\n public Set getDexFiles() {\n return mDexFiles;\n }\n\n public int getInferredApiLevel() {\n return mInferredApiLevel;\n }\n\n public void decode(String dexName, File smaliDir) throws AndrolibException {\n try {\n BaksmaliOptions options = new BaksmaliOptions();\n options.deodex = false;\n options.implicitReferences = false;\n options.parameterRegisters = true;\n options.localsDirective = true;\n options.sequentialLabels = true;\n options.debugInfo = mDebugMode;\n options.codeOffsets = false;\n options.accessorComments = false;\n options.registerInfo = 0;\n options.inlineResolver = null;\n\n // Set jobs automatically.\n int jobs = Runtime.getRuntime().availableProcessors();\n if (jobs > 6) {\n jobs = 6;\n }\n\n // Create the container.\n MultiDexContainer container = DexFileFactory.loadDexContainer(mApkFile, null);\n\n // If we have 1 item, ignore the passed file. Pull the DexFile we need.\n MultiDexContainer.DexEntry dexEntry =\n container.getDexEntryNames().size() == 1\n ? container.getEntry(container.getDexEntryNames().get(0))\n : container.getEntry(dexName);\n\n // Double-check the passed param exists.\n if (dexEntry == null) {\n dexEntry = container.getEntry(container.getDexEntryNames().get(0));\n assert dexEntry != null;\n }\n\n DexBackedDexFile dexFile = dexEntry.getDexFile();\n\n if (dexFile.supportsOptimizedOpcodes()) {\n throw new AndrolibException(\"Could not disassemble an odex file without deodexing it.\");\n }\n\n if (dexFile instanceof DexBackedOdexFile) {\n options.inlineResolver = InlineMethodResolver.createInlineMethodResolver(\n ((DexBackedOdexFile) dexFile).getOdexVersion());\n }\n\n OS.mkdir(smaliDir);\n Baksmali.disassembleDexFile(dexFile, smaliDir, jobs, options);\n\n synchronized (mDexFiles) {\n int apiLevel = dexFile.getOpcodes().api;\n if (mInferredApiLevel == 0 || mInferredApiLevel > apiLevel) {\n mInferredApiLevel = apiLevel;\n }\n\n mDexFiles.add(dexName);\n }\n } catch (IOException ex) {\n throw new AndrolibException(\"Could not baksmali file: \" + dexName, ex);\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/AndResGuardTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class AndResGuardTest extends BaseTest {\n private static final String TEST_APK = \"issue1170.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(AndResGuardTest.class, \"issue1170\", sTmpDir);\n }\n\n @Test\n public void checkifAndResDecodeRemapsRFolder() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/mipmap-hdpi-v4/a.png\").isFile());\n }\n\n @Test\n public void checkIfAndResDecodeIgnoresRFolderInRawMode() throws Exception {\n sConfig.setDecodeResources(Config.DecodeResources.NONE);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.raw\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"unknown/r/a/a.png\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/AndroidOreoNotSparseTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class AndroidOreoNotSparseTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue1594-orig\");\n sTestNewDir = new File(sTmpDir, \"issue1594-new\");\n\n log(\"Unpacking not_sparse.apk...\");\n copyResourceDir(AndroidOreoNotSparseTest.class, \"issue1594\", sTestOrigDir);\n\n log(\"Decoding not_sparse.apk...\");\n File testApk = new File(sTestOrigDir, \"not_sparse.apk\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n\n log(\"Building not_sparse.apk...\");\n new ApkBuilder(sTestNewDir, sConfig).build(testApk);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n assertTrue(sTestOrigDir.isDirectory());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/AndroidOreoSparseTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class AndroidOreoSparseTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue1594-orig\");\n sTestNewDir = new File(sTmpDir, \"issue1594-new\");\n\n log(\"Unpacking sparse.apk...\");\n copyResourceDir(AndroidOreoSparseTest.class, \"issue1594\", sTestOrigDir);\n\n log(\"Decoding sparse.apk...\");\n File testApk = new File(sTestOrigDir, \"sparse.apk\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n\n log(\"Building sparse.apk...\");\n new ApkBuilder(sTestNewDir, sConfig).build(testApk);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n assertTrue(sTestOrigDir.isDirectory());\n }\n\n @Test\n public void ensureStringsOreoTest() {\n assertTrue(new File(sTestNewDir, \"res/values-v26/strings.xml\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.Config;\nimport brut.androlib.res.Framework;\nimport brut.common.Log;\nimport brut.directory.FileDirectory;\nimport brut.util.OS;\n\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.InputStream;\nimport java.io.IOException;\nimport java.io.Reader;\nimport java.net.URL;\nimport java.net.URLDecoder;\nimport java.nio.file.Files;\n\nimport org.junit.*;\nimport static org.junit.Assert.assertTrue;\nimport org.custommonkey.xmlunit.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class BaseTest {\n private static final String TAG = \"TEST\";\n\n protected static Config sConfig;\n protected static File sTmpDir;\n protected static File sTestOrigDir;\n protected static File sTestNewDir;\n\n static {\n XMLUnit.setEnableXXEProtection(true);\n XMLUnit.setIgnoreAttributeOrder(true);\n XMLUnit.setIgnoreWhitespace(true);\n }\n\n private static void cleanFrameworkFile() throws Exception {\n File apkFile = new File(new Framework(sConfig).getDirectory(), \"1.apk\");\n if (apkFile.isFile()) {\n OS.rmfile(apkFile.getAbsolutePath());\n }\n }\n\n @BeforeClass\n public static void beforeEachClass() throws Exception {\n sConfig = new Config(TAG);\n cleanFrameworkFile();\n\n sTmpDir = OS.createTempDirectory();\n }\n\n @AfterClass\n public static void afterEachClass() throws Exception {\n sTestOrigDir = null;\n sTestNewDir = null;\n\n OS.rmdir(sTmpDir);\n sTmpDir = null;\n\n cleanFrameworkFile();\n sConfig = null;\n }\n\n @Before\n public void beforeEachTest() {\n sConfig = new Config(TAG);\n }\n\n protected static void log(String message) {\n Log.i(TAG, message);\n }\n\n protected static void log(String message, Object... args) {\n Log.i(TAG, message, args);\n }\n\n protected static void copyResourceDir(Class clz, String dirPath, File outDir) throws Exception {\n if (clz == null) {\n clz = Class.class;\n }\n\n URL dirURL = clz.getClassLoader().getResource(dirPath);\n if (dirURL != null && dirURL.getProtocol().equals(\"file\")) {\n String jarPath = URLDecoder.decode(dirURL.getFile(), \"UTF-8\");\n new FileDirectory(jarPath).copyToDir(outDir);\n return;\n }\n\n if (dirURL == null) {\n String className = clz.getName().replace('.', '/') + \".class\";\n dirURL = clz.getClassLoader().getResource(className);\n }\n\n if (dirURL.getProtocol().equals(\"jar\")) {\n String jarPath = URLDecoder.decode(dirURL.getPath().substring(5, dirURL.getPath().indexOf('!')), \"UTF-8\");\n new FileDirectory(jarPath).copyToDir(outDir);\n }\n }\n\n protected static String readTextFile(File file) throws Exception {\n return new String(Files.readAllBytes(file.toPath()));\n }\n\n protected static byte[] readHeaderOfFile(File file, int size) throws Exception {\n byte[] buffer = new byte[size];\n\n try (InputStream in = Files.newInputStream(file.toPath())) {\n if (in.read(buffer) != buffer.length) {\n throw new IOException(\"File size too small for buffer length: \" + size);\n }\n }\n\n return buffer;\n }\n\n protected static String replaceNewlines(String value) {\n return value.replaceAll(\"[\\n\\r]\", \"\");\n }\n\n protected static void compareBinaryFolder(String path) throws Exception {\n compareBinaryFolder(sTestOrigDir, sTestNewDir, path);\n }\n\n protected static void compareBinaryFolder(File controlDir, File testDir, String path) throws Exception {\n File controlBase = new File(controlDir, path);\n File testBase = new File(testDir, path);\n\n boolean exists = true;\n\n for (String fileName : new FileDirectory(controlBase).getFiles(true)) {\n File control = new File(controlBase, fileName);\n File test = new File(testBase, fileName);\n\n if (!control.isFile() || !test.isFile()) {\n exists = false;\n }\n }\n\n assertTrue(exists);\n }\n\n protected static void compareValuesFiles(String path) throws Exception {\n compareValuesFiles(sTestOrigDir, sTestNewDir, path);\n }\n\n protected static void compareValuesFiles(File controlDir, File testDir, String path) throws Exception {\n compareXmlFiles(controlDir, testDir, \"res/\" + path, new ElementNameAndAttributeQualifier(\"name\"));\n }\n\n protected static void compareXmlFiles(String path) throws Exception {\n compareXmlFiles(sTestOrigDir, sTestNewDir, path, null);\n }\n\n protected static void compareXmlFiles(File controlDir, File testDir, String path) throws Exception {\n compareXmlFiles(controlDir, testDir, path, null);\n }\n\n private static void compareXmlFiles(File controlDir, File testDir, String path, ElementQualifier qualifier) throws Exception {\n try (\n Reader control = new FileReader(new File(controlDir, path));\n Reader test = new FileReader(new File(testDir, path))\n ) {\n if (qualifier == null) {\n assertXMLEqual(control, test);\n return;\n }\n\n DetailedDiff diff = new DetailedDiff(new Diff(control, test));\n diff.overrideElementQualifier(qualifier);\n\n assertTrue(path + \": \" + diff.getAllDifferences().toString(), diff.similar());\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeApkTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\nimport brut.directory.ExtFile;\nimport brut.util.OSDetection;\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\n\nimport javax.imageio.ImageIO;\nimport java.awt.image.BufferedImage;\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.junit.Assume.assumeTrue;\n\npublic class BuildAndDecodeApkTest extends BaseTest {\n private static ExtFile sTestApk;\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"testapp-orig\");\n sTestNewDir = new File(sTmpDir, \"testapp-new\");\n\n log(\"Unpacking testapp...\");\n copyResourceDir(BuildAndDecodeApkTest.class, \"testapp\", sTestOrigDir);\n\n sConfig.setVerbose(true);\n\n log(\"Building testapp.apk...\");\n sTestApk = new ExtFile(sTmpDir, \"testapp.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(sTestApk);\n\n log(\"Decoding testapp.apk...\");\n new ApkDecoder(sTestApk, sConfig).decode(sTestNewDir);\n }\n\n @AfterClass\n public static void afterClass() throws Exception {\n sTestApk.close();\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void confirmFeatureFlagsRecorded() throws Exception {\n ApkInfo testInfo = ApkInfo.load(sTestNewDir);\n assertTrue(testInfo.getFeatureFlags().get(\"brut.feature.permission\"));\n assertTrue(testInfo.getFeatureFlags().get(\"brut.feature.activity\"));\n }\n\n @Test\n public void confirmZeroByteFileExtensionIsNotStored() throws Exception {\n ApkInfo testInfo = ApkInfo.load(sTestNewDir);\n assertFalse(testInfo.getDoNotCompress().contains(\"jpg\"));\n }\n\n @Test\n public void confirmZeroByteFileIsStored() throws Exception {\n ApkInfo testInfo = ApkInfo.load(sTestNewDir);\n assertTrue(testInfo.getDoNotCompress().contains(\"assets/0byte_file.jpg\"));\n }\n\n @Test\n public void confirmManifestStructureTest() throws Exception {\n compareXmlFiles(\"AndroidManifest.xml\");\n }\n\n @Test\n public void confirmPlatformManifestValuesTest() throws Exception {\n Document doc = XmlUtils.loadDocument(new File(sTestNewDir, \"AndroidManifest.xml\"));\n Node application = doc.getElementsByTagName(\"manifest\").item(0);\n NamedNodeMap attrs = application.getAttributes();\n\n Node platformBuildVersionNameAttr = attrs.getNamedItem(\"platformBuildVersionName\");\n assertEquals(\"6.0-2438415\", platformBuildVersionNameAttr.getNodeValue());\n\n Node platformBuildVersionCodeAttr = attrs.getNamedItem(\"platformBuildVersionCode\");\n assertEquals(\"23\", platformBuildVersionCodeAttr.getNodeValue());\n\n Node compileSdkVersionAttr = attrs.getNamedItem(\"compileSdkVersion\");\n assertNull(\"compileSdkVersion should have been stripped\", compileSdkVersionAttr);\n\n Node compileSdkVersionCodenameAttr = attrs.getNamedItem(\"compileSdkVersionCodename\");\n assertNull(\"compileSdkVersionCodename should have been stripped\", compileSdkVersionCodenameAttr);\n }\n\n @Test\n public void valuesAnimsTest() throws Exception {\n compareValuesFiles(\"values-mcc001/anims.xml\");\n }\n\n @Test\n public void valuesArraysTest() throws Exception {\n compareValuesFiles(\"values-mcc001/arrays.xml\");\n }\n\n @Test\n public void valuesArraysCastingTest() throws Exception {\n compareValuesFiles(\"values-mcc002/arrays.xml\");\n compareValuesFiles(\"values-mcc003/arrays.xml\");\n }\n\n @Test\n public void valuesAttrsTest() throws Exception {\n compareValuesFiles(\"values/attrs.xml\");\n }\n\n @Test\n public void valuesBoolsTest() throws Exception {\n compareValuesFiles(\"values-mcc001/bools.xml\");\n }\n\n @Test\n public void valuesColorsTest() throws Exception {\n compareValuesFiles(\"values/colors.xml\");\n compareValuesFiles(\"values-mcc001/colors.xml\");\n }\n\n @Test\n public void valuesDimensTest() throws Exception {\n compareValuesFiles(\"values-mcc001/dimens.xml\");\n }\n\n @Test\n public void valuesDrawablesTest() throws Exception {\n compareValuesFiles(\"values-mcc001/drawables.xml\");\n }\n\n @Test\n public void valuesIdsTest() throws Exception {\n compareValuesFiles(\"values-mcc001/ids.xml\");\n }\n\n @Test\n public void valuesIntegersTest() throws Exception {\n compareValuesFiles(\"values-mcc001/integers.xml\");\n }\n\n @Test\n public void valuesLayoutsTest() throws Exception {\n compareValuesFiles(\"values-mcc001/layouts.xml\");\n }\n\n @Test\n public void valuesPluralsTest() throws Exception {\n compareValuesFiles(\"values-mcc001/plurals.xml\");\n }\n\n @Test\n public void valuesOverlayableTest() throws Exception {\n compareValuesFiles(\"values/overlayable.xml\");\n }\n\n @Test\n public void valuesStringsTest() throws Exception {\n compareValuesFiles(\"values/strings.xml\");\n compareValuesFiles(\"values-mcc001/strings.xml\");\n }\n\n @Test\n public void valuesStylesTest() throws Exception {\n compareValuesFiles(\"values-mcc001/styles.xml\");\n }\n\n @Test\n public void valuesExtraLongTest() throws Exception {\n compareValuesFiles(\"values-en/strings.xml\");\n }\n\n @Test\n public void valuesMaxLengthTest() throws Exception {\n Document doc = XmlUtils.loadDocument(new File(sTestNewDir, \"res/values-en/strings.xml\"));\n\n // long_string_32767 should be exactly 0x7FFF chars of \"a\",\n // which is the longest allowed length for UTF-8 strings.\n // String longer than that is replaced with \"STRING_TOO_LARGE\".\n // valuesExtraLongTest covers this scenario, but we want a specific test\n // for such an edge case.\n String expression = \"/resources/string[@name='long_string_32767']/text()\";\n String str = XmlUtils.evaluateXPath(doc, expression, String.class);\n assertEquals(0x7FFF, str.length());\n }\n\n @Test\n public void valuesGrammaticalGenderTest() throws Exception {\n compareValuesFiles(\"values-neuter/strings.xml\");\n compareValuesFiles(\"values-feminine/strings.xml\");\n }\n\n @Test\n public void bug702Test() throws Exception {\n compareValuesFiles(\"values-mcc001-mnc00/strings.xml\");\n }\n\n @Test\n public void valuesReferencesTest() throws Exception {\n compareValuesFiles(\"values-mcc002/strings.xml\");\n }\n\n @Test\n public void crossTypeTest() throws Exception {\n compareValuesFiles(\"values-mcc003/strings.xml\");\n compareValuesFiles(\"values-mcc003/integers.xml\");\n compareValuesFiles(\"values-mcc003/bools.xml\");\n }\n\n @Test\n public void qualifiersTest() throws Exception {\n compareValuesFiles(\n \"values-mcc004-mnc04-en-rUS-ldrtl-sw100dp-w200dp-h300dp\"\n + \"-long-round-highdr-land-desk-night-xhdpi-finger-keyssoft-12key\"\n + \"-navhidden-dpad-v26/strings.xml\");\n }\n\n @Test\n public void shortendedMncTest() throws Exception {\n compareValuesFiles(\"values-mcc001-mnc01/strings.xml\");\n }\n\n @Test\n public void shortMncHtcTest() throws Exception {\n compareValuesFiles(\"values-mnc01/strings.xml\");\n }\n\n @Test\n public void shortMncv2Test() throws Exception {\n compareValuesFiles(\"values-mcc238-mnc06/strings.xml\");\n }\n\n @Test\n public void longMncTest() throws Exception {\n compareValuesFiles(\"values-mcc238-mnc870/strings.xml\");\n }\n\n @Test\n public void anyDpiTest() throws Exception {\n compareValuesFiles(\"values-watch/strings.xml\");\n }\n\n @Test\n public void packed3CharsTest() throws Exception {\n compareValuesFiles(\"values-ast-rES/strings.xml\");\n }\n\n @Test\n public void rightToLeftTest() throws Exception {\n compareValuesFiles(\"values-ldrtl/strings.xml\");\n }\n\n @Test\n public void threeLetterLangBcp47Test() throws Exception {\n compareValuesFiles(\"values-ast/strings.xml\");\n }\n\n @Test\n public void androidOStringTest() throws Exception {\n compareValuesFiles(\"values-ast/strings.xml\");\n }\n\n @Test\n public void twoLetterNotHandledAsBcpTest() {\n assertTrue(new File(sTestNewDir, \"res/values-fr\").isDirectory());\n }\n\n @Test\n public void twoLetterLangBcp47Test() throws Exception {\n compareValuesFiles(\"values-en-rUS/strings.xml\");\n }\n\n @Test\n public void scriptBcp47Test() throws Exception {\n compareValuesFiles(\"values-b+en+Latn+US/strings.xml\");\n }\n\n @Test\n public void regionLocaleBcp47Test() throws Exception {\n compareValuesFiles(\"values-b+en+Latn+419/strings.xml\");\n }\n\n @Test\n public void numericalRegionBcp47Test() throws Exception {\n compareValuesFiles(\"values-b+eng+419/strings.xml\");\n }\n\n @Test\n public void variantBcp47Test() throws Exception {\n compareValuesFiles(\"values-b+en+US+posix/strings.xml\");\n }\n\n @Test\n public void valuesBcp47LanguageVariantTest() throws Exception {\n compareValuesFiles(\"values-b+iw+660/strings.xml\");\n }\n\n @Test\n public void valuesBcp47LanguageScriptRegionVariantTest() throws Exception {\n compareValuesFiles(\"values-b+ast+Latn+IT+arevela/strings.xml\");\n compareValuesFiles(\"values-b+ast+Hant+IT+arabext/strings.xml\");\n }\n\n @Test\n public void api23ConfigurationsTest() throws Exception {\n compareValuesFiles(\"values-round/strings.xml\");\n compareValuesFiles(\"values-notround/strings.xml\");\n }\n\n @Test\n public void api26ConfigurationsTest() throws Exception {\n compareValuesFiles(\"values-widecg-v26/strings.xml\");\n compareValuesFiles(\"values-lowdr-v26/strings.xml\");\n compareValuesFiles(\"values-nowidecg-v26/strings.xml\");\n compareValuesFiles(\"values-vrheadset-v26/strings.xml\");\n }\n\n @Test\n public void leadingDollarSignResourceNameTest() throws Exception {\n compareXmlFiles(\"res/drawable/$avd_hide_password__0.xml\");\n compareXmlFiles(\"res/drawable/$avd_show_password__0.xml\");\n compareXmlFiles(\"res/drawable/$avd_show_password__1.xml\");\n compareXmlFiles(\"res/drawable/$avd_show_password__2.xml\");\n compareXmlFiles(\"res/drawable/avd_show_password.xml\");\n }\n\n @Test\n public void fontTest() throws Exception {\n File fontXml = new File(sTestNewDir, \"res/font/lobster.xml\");\n File fontFile = new File(sTestNewDir, \"res/font/lobster_regular.otf\");\n\n // Per #1662, ensure font file is not encoded.\n assertTrue(fontXml.isFile());\n compareXmlFiles(\"res/font/lobster.xml\");\n\n // If we properly skipped decoding the font (otf) file, this file should not exist\n assertFalse(new File(sTestNewDir, \"res/values/fonts.xml\").isFile());\n assertTrue(fontFile.isFile());\n }\n\n @Test\n public void xmlReferenceAttributeTest() throws Exception {\n compareXmlFiles(\"res/layout/issue1040.xml\");\n }\n\n @Test\n public void xmlCustomAttributeTest() throws Exception {\n compareXmlFiles(\"res/layout/issue1063.xml\");\n }\n\n @Test\n public void xmlCustomAttrsNotAndroidTest() throws Exception {\n compareXmlFiles(\"res/layout/issue1157.xml\");\n }\n\n @Test\n public void xmlExpectMatchParentTest() throws Exception {\n compareXmlFiles(\"res/layout/issue1274.xml\");\n }\n\n @Test\n public void xmlUniformAutoTextTest() throws Exception {\n compareXmlFiles(\"res/layout/issue1674.xml\");\n }\n\n @Test\n public void navigationResourceTest() throws Exception {\n compareXmlFiles(\"res/navigation/nav_graph.xml\");\n }\n\n @Test\n public void xmlXsdFileTest() throws Exception {\n compareXmlFiles(\"res/xml/ww_box_styles_schema.xsd\");\n }\n\n @Test\n public void xmlLiteralsTest() throws Exception {\n compareXmlFiles(\"res/xml/literals.xml\");\n }\n\n @Test\n public void xmlReferencesTest() throws Exception {\n compareXmlFiles(\"res/xml/references.xml\");\n }\n\n @Test\n public void xmlAccessibilityTest() throws Exception {\n compareXmlFiles(\"res/xml/accessibility_service_config.xml\");\n }\n\n @Test\n public void drawableNoDpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-nodpi\");\n }\n\n @Test\n public void drawableAnyDpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-anydpi\");\n }\n\n @Test\n public void drawableNumberedDpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-534dpi\");\n }\n\n @Test\n public void drawableLdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-ldpi\");\n }\n\n @Test\n public void drawableMdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-mdpi\");\n }\n\n @Test\n public void drawableTvdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-tvdpi\");\n }\n\n @Test\n public void drawableXhdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-xhdpi\");\n }\n\n @Test\n public void ninePatchImageColorTest() throws Exception {\n String fileName = \"res/drawable-xhdpi/ninepatch.9.png\";\n\n File control = new File(sTestOrigDir, fileName);\n File test = new File(sTestNewDir, fileName);\n\n BufferedImage controlImage = ImageIO.read(control);\n BufferedImage testImage = ImageIO.read(test);\n\n // lets start with 0,0 - empty\n assertEquals(controlImage.getRGB(0, 0), testImage.getRGB(0, 0));\n\n // then with 30, 0 - black\n assertEquals(controlImage.getRGB(30, 0), testImage.getRGB(30, 0));\n\n // then 30, 30 - blue\n assertEquals(controlImage.getRGB(30, 30), testImage.getRGB(30, 30));\n }\n\n @Test\n public void issue1508Test() throws Exception {\n String fileName = \"res/drawable-xhdpi/btn_zoom_up_normal.9.png\";\n\n File control = new File(sTestOrigDir, fileName);\n File test = new File(sTestNewDir, fileName);\n\n BufferedImage controlImage = ImageIO.read(control);\n BufferedImage testImage = ImageIO.read(test);\n\n // 0, 0 = clear\n assertEquals(controlImage.getRGB(0, 0), testImage.getRGB(0, 0));\n\n // 30, 0 = black line\n assertEquals(controlImage.getRGB(0, 30), testImage.getRGB(0, 30));\n\n // 30, 30 = greyish button\n assertEquals(controlImage.getRGB(30, 30), testImage.getRGB(30, 30));\n }\n\n @Test\n public void issue1511Test() throws Exception {\n String fileName = \"res/drawable-xxhdpi/textfield_activated_holo_dark.9.png\";\n\n File control = new File(sTestOrigDir, fileName);\n File test = new File(sTestNewDir, fileName);\n\n BufferedImage controlImage = ImageIO.read(control);\n BufferedImage testImage = ImageIO.read(test);\n\n // Check entire image as we cannot mess this up\n int w = controlImage.getWidth();\n int h = controlImage.getHeight();\n\n int[] controlImageGrid = controlImage.getRGB(0, 0, w, h, null, 0, w);\n int[] testImageGrid = testImage.getRGB(0, 0, w, h, null, 0, w);\n\n for (int i = 0; i < controlImageGrid.length; i++) {\n assertEquals(\"Image lost Optical Bounds at i = \" + i, controlImageGrid[i], testImageGrid[i]);\n }\n }\n\n @Test\n public void robust9patchTest() throws Exception {\n String[] ninePatches = {\n \"ic_notification_overlay.9.png\",\n \"status_background.9.png\",\n \"search_bg_transparent.9.png\",\n \"screenshot_panel.9.png\",\n \"recents_lower_gradient.9.png\",\n };\n\n for (String ninePatch : ninePatches) {\n String fileName = \"res/drawable-xxhdpi/\" + ninePatch;\n\n File control = new File(sTestOrigDir, fileName);\n File test = new File(sTestNewDir, fileName);\n\n BufferedImage controlImage = ImageIO.read(control);\n BufferedImage testImage = ImageIO.read(test);\n\n int w = controlImage.getWidth();\n int h = controlImage.getHeight();\n\n // Check the entire horizontal line\n for (int i = 1; i < w; i++) {\n if (isTransparent(controlImage.getRGB(i, 0))) {\n assertTrue(isTransparent(testImage.getRGB(i, 0)));\n } else {\n assertEquals(\"Image lost npTc chunk on image \" + ninePatch + \" at (x, y) (\" + i + \",\" + 0 + \")\",\n controlImage.getRGB(i, 0), testImage.getRGB(i, 0));\n }\n }\n\n // Check the entire vertical line\n for (int i = 1; i < h; i++) {\n if (isTransparent(controlImage.getRGB(0, i))) {\n assertTrue(isTransparent(testImage.getRGB(0, i)));\n } else {\n assertEquals(\"Image lost npTc chunk on image \" + ninePatch + \" at (x, y) (\" + 0 + \",\" + i + \")\",\n controlImage.getRGB(0, i), testImage.getRGB(0, i));\n }\n }\n }\n }\n\n private static boolean isTransparent(int pixel) {\n return (pixel >> 24) == 0;\n }\n\n @Test\n public void drawableXxhdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-xxhdpi\");\n }\n\n @Test\n public void drawableQualifierXxhdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-xxhdpi-v4\");\n }\n\n @Test\n public void drawableXxxhdpiTest() throws Exception {\n compareBinaryFolder(\"res/drawable-xxxhdpi\");\n }\n\n @Test\n public void resRawTest() throws Exception {\n compareBinaryFolder(\"res/raw\");\n }\n\n @Test\n public void storedMp3FilesAreNotCompressedTest() throws Exception {\n assertEquals(0, sTestApk.getDirectory().getCompressionLevel(\"res/raw/rain.mp3\"));\n }\n\n @Test\n public void libsTest() throws Exception {\n compareBinaryFolder(\"lib\");\n }\n\n @Test\n public void fileAssetTest() throws Exception {\n compareBinaryFolder(\"assets/txt\");\n }\n\n @Test\n public void unicodeAssetTest() throws Exception {\n assumeTrue(!OSDetection.isWindows());\n compareBinaryFolder(\"assets/unicode-txt\");\n }\n\n @Test\n public void unknownFolderTest() throws Exception {\n compareBinaryFolder(\"unknown\");\n }\n\n @Test\n public void multipleDexTest() throws Exception {\n compareBinaryFolder(\"smali_classes2\");\n compareBinaryFolder(\"smali_classes3\");\n assertTrue(new File(sTestOrigDir, \"build/apk/classes2.dex\").isFile());\n assertTrue(new File(sTestOrigDir, \"build/apk/classes3.dex\").isFile());\n }\n\n @Test\n public void singleDexTest() throws Exception {\n compareBinaryFolder(\"smali\");\n assertTrue(new File(sTestOrigDir, \"build/apk/classes.dex\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeJarTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class BuildAndDecodeJarTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"testjar-orig\");\n sTestNewDir = new File(sTmpDir, \"testjar-new\");\n\n log(\"Unpacking testjar...\");\n copyResourceDir(BuildAndDecodeJarTest.class, \"testjar\", sTestOrigDir);\n\n log(\"Building testjar.jar...\");\n File testJar = new File(sTmpDir, \"testjar.jar\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testJar);\n\n log(\"Decoding testjar.jar...\");\n new ApkDecoder(testJar, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/CompactResourceTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NodeList;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class CompactResourceTest extends BaseTest {\n private static final String TEST_APK = \"issue3366.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(CompactResourceTest.class, \"issue3366\", sTmpDir);\n }\n\n @Test\n public void checkIfDecodeSucceeds() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n Document doc = XmlUtils.loadDocument(new File(testDir, \"res/values/strings.xml\"));\n String expression = \"/resources/string[@name]\";\n NodeList nodes = XmlUtils.evaluateXPath(doc, expression, NodeList.class);\n assertEquals(1002, nodes.getLength());\n\n new ApkBuilder(testDir, sConfig).build(null);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DebuggableFalseChangeToTrueTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class DebuggableFalseChangeToTrueTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue2328-debuggable-false-orig\");\n sTestNewDir = new File(sTmpDir, \"issue2328-debuggable-false-new\");\n\n log(\"Unpacking issue2328-debuggable-false...\");\n copyResourceDir(DebuggableFalseChangeToTrueTest.class, \"issue2328/debuggable-false\", sTestOrigDir);\n\n sConfig.setDebuggable(true);\n sConfig.setVerbose(true);\n\n log(\"Building issue2328-debuggable-false.apk...\");\n File testApk = new File(sTmpDir, \"issue2328-debuggable-false.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testApk);\n\n log(\"Decoding issue2328-debuggable-false.apk...\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void debugIsTruePriorToBeingFalseTest() throws Exception {\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"AndroidManifest.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DebuggableTrueAddedTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class DebuggableTrueAddedTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue2328-debuggable-missing-orig\");\n sTestNewDir = new File(sTmpDir, \"issue2328-debuggable-missing-new\");\n\n log(\"Unpacking issue2328-debuggable-missing...\");\n copyResourceDir(DebuggableTrueAddedTest.class, \"issue2328/debuggable-missing\", sTestOrigDir);\n\n sConfig.setDebuggable(true);\n sConfig.setVerbose(true);\n\n log(\"Building issue2328-debuggable-missing.apk...\");\n File testApk = new File(sTmpDir, \"issue2328-debuggable-missing.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testApk);\n\n log(\"Decoding issue2328-debuggable-missing.apk...\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void debugIsTruePriorToBeingFalseTest() throws Exception {\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"AndroidManifest.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DebuggableTrueRetainedTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class DebuggableTrueRetainedTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue2328-debuggable-true-orig\");\n sTestNewDir = new File(sTmpDir, \"issue2328-debuggable-true-new\");\n\n log(\"Unpacking issue2328-debuggable-true...\");\n copyResourceDir(DebuggableTrueRetainedTest.class, \"issue2328/debuggable-true\", sTestOrigDir);\n\n sConfig.setDebuggable(true);\n sConfig.setVerbose(true);\n\n log(\"Building issue2328-debuggable-true.apk...\");\n File testApk = new File(sTmpDir, \"issue2328-debuggable-true.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testApk);\n\n log(\"Decoding issue2328-debuggable-true.apk...\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void debugIsTruePriorToBeingFalseTest() throws Exception {\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"AndroidManifest.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DecodeArrayTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResTable;\nimport brut.androlib.res.table.value.ResArray;\nimport brut.androlib.res.table.value.ResValue;\nimport brut.directory.ExtFile;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DecodeArrayTest extends BaseTest {\n private static ExtFile sTestApk;\n private static ResTable sTable;\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(MissingVersionManifestTest.class, \"issue1994\", sTmpDir);\n\n log(\"Decoding issue1994.apk...\");\n sTestApk = new ExtFile(sTmpDir, \"issue1994.apk\");\n ApkInfo testInfo = new ApkInfo();\n testInfo.setApkFile(sTestApk);\n sTable = new ResTable(testInfo, sConfig);\n sTable.load();\n }\n\n @AfterClass\n public static void afterClass() throws Exception {\n sTestApk.close();\n }\n\n @Test\n public void decodeStringArray() throws Exception {\n ResValue value = sTable.resolveEntry(ResId.of(0x7F020001)).getValue();\n assertTrue(\"Not a ResArray. Found: \" + value.getClass(), value instanceof ResArray);\n }\n\n @Test\n public void decodeArray() throws Exception {\n ResValue value = sTable.resolveEntry(ResId.of(0x7F020000)).getValue();\n assertTrue(\"Not a ResArray. Found: \" + value.getClass(), value instanceof ResArray);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DecodeResolveTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.Document;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DecodeResolveTest extends BaseTest {\n private static final String TEST_APK = \"issue2836.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(DecodeResolveTest.class, \"issue2836\", sTmpDir);\n }\n\n @Test\n public void decodeResolveDefaultTest() throws Exception {\n sConfig.setDecodeResolve(Config.DecodeResolve.DEFAULT);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.default\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/values/strings.xml\").isFile());\n\n Document attrDocument = XmlUtils.loadDocument(new File(testDir, \"res/values/attrs.xml\"));\n assertEquals(4, attrDocument.getElementsByTagName(\"enum\").getLength());\n\n Document colorDocument = XmlUtils.loadDocument(new File(testDir, \"res/values/colors.xml\"));\n assertEquals(8, colorDocument.getElementsByTagName(\"color\").getLength());\n\n Document publicDocument = XmlUtils.loadDocument(new File(testDir, \"res/values/public.xml\"));\n assertEquals(22, publicDocument.getElementsByTagName(\"public\").getLength());\n }\n\n @Test\n public void decodeResolveGreedyTest() throws Exception {\n sConfig.setDecodeResolve(Config.DecodeResolve.GREEDY);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.greedy\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/values/strings.xml\").isFile());\n\n File attrXml = new File(testDir, \"res/values/attrs.xml\");\n Document attrDocument = XmlUtils.loadDocument(attrXml);\n assertEquals(4, attrDocument.getElementsByTagName(\"enum\").getLength());\n\n File colorXml = new File(testDir, \"res/values/colors.xml\");\n Document colorDocument = XmlUtils.loadDocument(colorXml);\n assertEquals(9, colorDocument.getElementsByTagName(\"color\").getLength());\n\n File publicXml = new File(testDir, \"res/values/public.xml\");\n Document publicDocument = XmlUtils.loadDocument(publicXml);\n assertEquals(23, publicDocument.getElementsByTagName(\"public\").getLength());\n }\n\n @Test\n public void decodeResolveLazyTest() throws Exception {\n sConfig.setDecodeResolve(Config.DecodeResolve.LAZY);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.lazy\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/values/strings.xml\").isFile());\n\n File attrXml = new File(testDir, \"res/values/attrs.xml\");\n Document attrDocument = XmlUtils.loadDocument(attrXml);\n assertEquals(3, attrDocument.getElementsByTagName(\"enum\").getLength());\n\n File colorXml = new File(testDir, \"res/values/colors.xml\");\n Document colorDocument = XmlUtils.loadDocument(colorXml);\n assertEquals(8, colorDocument.getElementsByTagName(\"color\").getLength());\n\n File publicXml = new File(testDir, \"res/values/public.xml\");\n Document publicDocument = XmlUtils.loadDocument(publicXml);\n assertEquals(21, publicDocument.getElementsByTagName(\"public\").getLength());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DecodeResourcesTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\nimport java.util.Arrays;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DecodeResourcesTest extends BaseTest {\n private static final String TEST_APK = \"issue1680.apk\";\n\n private static final byte[] XML_HEADER = {\n 0x3C, // <\n 0x3F, // ?\n 0x78, // x\n 0x6D, // m\n 0x6C, // l\n 0x20, // (empty)\n };\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(DecodeResourcesTest.class, \"issue1680\", sTmpDir);\n }\n\n @Test\n public void decodeResourcesNoneTest() throws Exception {\n sConfig.setDecodeResources(Config.DecodeResources.NONE);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.none\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n // assert that manifest is not XML\n assertFalse(Arrays.equals(XML_HEADER, readHeaderOfFile(new File(testDir, \"AndroidManifest.xml\"), 6)));\n\n // assert that resources.arsc exists\n assertTrue(new File(testDir, \"resources.arsc\").isFile());\n }\n\n @Test\n public void decodeResourcesFullTest() throws Exception {\n sConfig.setDecodeResources(Config.DecodeResources.FULL);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.full\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n // assert that manifest is XML\n assertTrue(Arrays.equals(XML_HEADER, readHeaderOfFile(new File(testDir, \"AndroidManifest.xml\"), 6)));\n\n // assert that resources.arsc does not exist\n assertFalse(new File(testDir, \"resources.arsc\").isFile());\n }\n\n @Test\n public void decodeResourcesOnlyManifestTest() throws Exception {\n sConfig.setDecodeResources(Config.DecodeResources.ONLY_MANIFEST);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.manifest\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n // assert that manifest is XML\n assertTrue(Arrays.equals(XML_HEADER, readHeaderOfFile(new File(testDir, \"AndroidManifest.xml\"), 6)));\n\n // assert that resources.arsc exists\n assertTrue(new File(testDir, \"resources.arsc\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DefaultBaksmaliVariableTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DefaultBaksmaliVariableTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue1481-orig\");\n sTestNewDir = new File(sTmpDir, \"issue1481-new\");\n\n log(\"Unpacking issue1481...\");\n copyResourceDir(DefaultBaksmaliVariableTest.class, \"issue1481\", sTestOrigDir);\n\n log(\"Building issue1481.jar...\");\n File testJar = new File(sTmpDir, \"issue1481.jar\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testJar);\n\n log(\"Decoding issue1481.jar...\");\n new ApkDecoder(testJar, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void confirmBaksmaliParamsAreTheSame() throws Exception {\n String expected =\n \".class public final Lcom/ibotpeaches/issue1481/BuildConfig;\\n\"\n + \".super Ljava/lang/Object;\\n\"\n + \".source \\\"BuildConfig.java\\\"\\n\"\n + \"\\n\"\n + \"\\n\"\n + \"# static fields\\n\"\n + \".field public static final APPLICATION_ID:Ljava/lang/String; = \\\"com.ibotpeaches.issue1481\\\"\\n\"\n + \"\\n\"\n + \".field public static final BUILD_TYPE:Ljava/lang/String; = \\\"debug\\\"\\n\"\n + \"\\n\"\n + \".field public static final DEBUG:Z\\n\"\n + \"\\n\"\n + \".field public static final FLAVOR:Ljava/lang/String; = \\\"\\\"\\n\"\n + \"\\n\"\n + \".field public static final VERSION_CODE:I = 0x1\\n\"\n + \"\\n\"\n + \".field public static final VERSION_NAME:Ljava/lang/String; = \\\"1.0\\\"\\n\"\n + \"\\n\"\n + \"\\n\"\n + \"# direct methods\\n\"\n + \".method static constructor ()V\\n\"\n + \" .locals 1\\n\"\n + \"\\n\"\n + \" .prologue\\n\"\n + \" .line 7\\n\"\n + \" const-string v0, \\\"true\\\"\\n\"\n + \"\\n\"\n + \" invoke-static {v0}, Ljava/lang/Boolean;->parseBoolean(Ljava/lang/String;)Z\\n\"\n + \"\\n\"\n + \" move-result v0\\n\"\n + \"\\n\"\n + \" sput-boolean v0, Lcom/ibotpeaches/issue1481/BuildConfig;->DEBUG:Z\\n\"\n + \"\\n\"\n + \" return-void\\n\"\n + \".end method\\n\"\n + \"\\n\"\n + \".method public constructor ()V\\n\"\n + \" .locals 0\\n\"\n + \"\\n\"\n + \" .prologue\\n\"\n + \" .line 6\\n\"\n + \" invoke-direct {p0}, Ljava/lang/Object;->()V\\n\"\n + \"\\n\"\n + \" return-void\\n\"\n + \".end method\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"smali/com/ibotpeaches/issue1481/BuildConfig.smali\"));\n\n assertEquals(replaceNewlines(expected), replaceNewlines(obtained));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DexStaticFieldValueTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DexStaticFieldValueTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue2543-orig\");\n sTestNewDir = new File(sTmpDir, \"issue2543-new\");\n\n log(\"Unpacking issue2543...\");\n copyResourceDir(DexStaticFieldValueTest.class, \"issue2543\", sTestOrigDir);\n\n sConfig.setBaksmaliDebugMode(false);\n\n log(\"Building issue2543.jar...\");\n File testJar = new File(sTmpDir, \"issue2543.jar\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testJar);\n\n log(\"Decoding issue2543.jar...\");\n new ApkDecoder(testJar, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void disassembleDexFileToKeepDefaultParameters() throws Exception {\n String expected =\n \".class public LHelloWorld;\\n\"\n + \".super Ljava/lang/Object;\\n\"\n + \"\\n\"\n + \"\\n\"\n + \"# static fields\\n\"\n + \".field private static b:Z = false\\n\"\n + \"\\n\"\n + \".field private static c:Z = true\\n\"\n + \"\\n\"\n + \"\\n\"\n + \"# direct methods\\n\"\n + \".method public static main([Ljava/lang/String;)V\\n\"\n + \" .locals 1\\n\"\n + \"\\n\"\n + \" return-void\\n\"\n + \".end method\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"smali/HelloWorld.smali\"));\n\n assertEquals(replaceNewlines(expected), replaceNewlines(obtained));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DoubleExtensionUnknownFileTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\nimport org.apache.commons.lang3.StringUtils;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DoubleExtensionUnknownFileTest extends BaseTest {\n private static final String TEST_APK = \"issue1244.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(DoubleExtensionUnknownFileTest.class, \"issue1244\", sTmpDir);\n }\n\n @Test\n public void multipleExtensionUnknownFileTest() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n ApkInfo testInfo = ApkInfo.load(testDir);\n for (String path : testInfo.getDoNotCompress()) {\n if (StringUtils.countMatches(path, '.') > 1) {\n assertTrue(path.equals(\"assets/bin/Data/sharedassets1.assets.split0\"));\n }\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/DynamicDexTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DynamicDexTest extends BaseTest {\n private static final String TEST_APK = \"dynamic_dex.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n log(\"Unpacking \" + TEST_APK + \"...\");\n copyResourceDir(DynamicDexTest.class, \"dynamic_dex\", sTmpDir);\n }\n\n @Test\n public void decodeOnlyMainClassesTest() throws Exception {\n sConfig.setDecodeSources(Config.DecodeSources.ONLY_MAIN_CLASSES);\n\n log(\"Decoding \" + TEST_APK + \"...\");\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.main\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n log(\"Building \" + TEST_APK + \"...\");\n new ApkBuilder(testDir, sConfig).build(null);\n }\n\n @Test\n public void decodeAllSourcesTest() throws Exception {\n sConfig.setDecodeSources(Config.DecodeSources.FULL);\n\n log(\"Decoding \" + TEST_APK + \"...\");\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.full\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n log(\"Building \" + TEST_APK + \"...\");\n new ApkBuilder(testDir, sConfig).build(null);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/Empty9PatchTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class Empty9PatchTest extends BaseTest {\n private static final String TEST_APK = \"empty_9patch.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(Empty9PatchTest.class, \"empty_9patch\", sTmpDir);\n }\n\n @Test\n public void decodeWithEmpty9PatchFile() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n File aPng = new File(testDir, \"res/drawable-xhdpi/empty.9.png\");\n assertTrue(aPng.isFile());\n assertEquals(0, aPng.length());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/EmptyArscTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class EmptyArscTest extends BaseTest {\n private static final String TEST_APK = \"issue2701.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(EmptyArscTest.class, \"issue2701\", sTmpDir);\n }\n\n @Test\n public void decodeWithEmptyArscFile() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/values/public.xml\").isFile());\n assertTrue(new File(testDir, \"AndroidManifest.xml\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/EmptyResourcesArscTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class EmptyResourcesArscTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"issue1730-orig\");\n sTestNewDir = new File(sTmpDir, \"issue1730-new\");\n\n log(\"Unpacking issue1730.apk...\");\n copyResourceDir(EmptyResourcesArscTest.class, \"issue1730\", sTestOrigDir);\n\n log(\"Decoding issue1730.apk...\");\n File testApk = new File(sTestOrigDir, \"issue1730.apk\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n\n log(\"Building issue1730.apk...\");\n new ApkBuilder(sTestNewDir, sConfig).build(testApk);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n assertTrue(sTestOrigDir.isDirectory());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/ExternalEntityTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class ExternalEntityTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"doctype-orig\");\n sTestNewDir = new File(sTmpDir, \"doctype-new\");\n\n log(\"Unpacking doctype...\");\n copyResourceDir(ExternalEntityTest.class, \"doctype\", sTestOrigDir);\n\n log(\"Building doctype.apk...\");\n File testApk = new File(sTmpDir, \"doctype.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testApk);\n\n log(\"Decoding doctype.apk...\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void doctypeTest() throws Exception {\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"AndroidManifest.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/FrameworkTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.res.Framework;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class FrameworkTest extends BaseTest {\n private static final String FRAMEWORK_APK = \"framework.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(FrameworkTest.class, \"framework\", sTmpDir);\n }\n\n @Test\n public void isFrameworkTaggingWorking() throws Exception {\n sConfig.setFrameworkDirectory(sTmpDir.getAbsolutePath());\n sConfig.setFrameworkTag(\"building\");\n\n File frameApk = new File(sTmpDir, FRAMEWORK_APK);\n new Framework(sConfig).install(frameApk);\n\n assertTrue(new File(sTmpDir, \"2-building.apk\").exists());\n }\n\n @Test\n public void isFrameworkInstallingWorking() throws Exception {\n sConfig.setFrameworkDirectory(sTmpDir.getAbsolutePath());\n\n File frameApk = new File(sTmpDir, FRAMEWORK_APK);\n new Framework(sConfig).install(frameApk);\n\n assertTrue(new File(sTmpDir, \"2.apk\").exists());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/LargeCompactResourceTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NodeList;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class LargeCompactResourceTest extends BaseTest {\n private static final String TEST_APK = \"issue3705.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(CompactResourceTest.class, \"issue3705\", sTmpDir);\n }\n\n @Test\n public void checkIfDecodeSucceeds() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n Document doc = XmlUtils.loadDocument(new File(testDir, \"res/values/strings.xml\"));\n String expression = \"/resources/string[contains(@name, 'APKTOOL')]\";\n NodeList nodes = XmlUtils.evaluateXPath(doc, expression, NodeList.class);\n assertEquals(0, nodes.getLength());\n\n new ApkBuilder(testDir, sConfig).build(null);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/LargeIntsInManifestTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class LargeIntsInManifestTest extends BaseTest {\n private static final String TEST_APK = \"issue767.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(LargeIntsInManifestTest.class, \"issue767\", sTmpDir);\n }\n\n @Test\n public void checkIfLargeIntsAreHandledTest() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n new ApkBuilder(testDir, sConfig).build(null);\n\n File newApk = new File(testDir, \"dist/\" + testApk.getName());\n File newDir = new File(testApk + \".out.new\");\n new ApkDecoder(newApk, sConfig).decode(newDir);\n\n compareXmlFiles(testDir, newDir, \"AndroidManifest.xml\");\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/MinifiedArscTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class MinifiedArscTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(MinifiedArscTest.class, \"issue1157\", sTmpDir);\n\n File testApk = new File(sTmpDir, \"issue1157.apk\");\n sTestNewDir = new File(testApk + \".out\");\n\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void checkIfMinifiedArscLayoutFileMatchesTest() throws Exception {\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"res/xml/custom.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/MissingVersionManifestTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class MissingVersionManifestTest extends BaseTest {\n private static final String TEST_APK = \"issue1264.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(MissingVersionManifestTest.class, \"issue1264\", sTmpDir);\n }\n\n @Test\n public void missingVersionParsesCorrectlyTest() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n ApkInfo testInfo = ApkInfo.load(testDir);\n assertNull(testInfo.getVersionInfo().getVersionName());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/NetworkConfigTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class NetworkConfigTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"network_config-orig\");\n sTestNewDir = new File(sTmpDir, \"network_config-new\");\n\n log(\"Unpacking network_config...\");\n copyResourceDir(NetworkConfigTest.class, \"network_config/existing\", sTestOrigDir);\n\n sConfig.setNetSecConf(true);\n\n log(\"Building network_config.apk...\");\n File testApk = new File(sTmpDir, \"network_config.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testApk);\n\n log(\"Decoding network_config.apk...\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void netSecConfGeneric() throws Exception {\n log(\"Verifying network security configuration file contains user and system certificates...\");\n\n // Load the XML document\n Document doc = XmlUtils.loadDocument(new File(sTestNewDir, \"res/xml/network_security_config.xml\"));\n\n // Check if 'system' certificate exists\n String systemCertExpr = \"/network-security-config/base-config/trust-anchors/certificates[@src='system']\";\n NodeList systemCertNodes = XmlUtils.evaluateXPath(doc, systemCertExpr, NodeList.class);\n assertTrue(systemCertNodes.getLength() > 0);\n\n // Check if 'user' certificate exists\n String userCertExpr = \"/network-security-config/base-config/trust-anchors/certificates[@src='user']\";\n NodeList userCertNodes = XmlUtils.evaluateXPath(doc, userCertExpr, NodeList.class);\n assertTrue(userCertNodes.getLength() > 0);\n }\n\n @Test\n public void netSecConfInManifest() throws Exception {\n log(\"Validating network security config in Manifest...\");\n\n // Load the XML document\n Document doc = XmlUtils.loadDocument(new File(sTestNewDir, \"AndroidManifest.xml\"));\n\n // Check if network security config attribute is set correctly\n Node application = doc.getElementsByTagName(\"application\").item(0);\n NamedNodeMap attrs = application.getAttributes();\n Node netSecConfAttr = attrs.getNamedItem(\"android:networkSecurityConfig\");\n assertEquals(\"@xml/network_security_config\", netSecConfAttr.getNodeValue());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/NoNetworkConfigTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.xml.XmlUtils;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class NoNetworkConfigTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"network_config-orig\");\n sTestNewDir = new File(sTmpDir, \"network_config-new\");\n\n log(\"Unpacking network_config...\");\n copyResourceDir(NoNetworkConfigTest.class, \"network_config/none\", sTestOrigDir);\n\n sConfig.setNetSecConf(true);\n\n log(\"Building network_config.apk...\");\n File testApk = new File(sTmpDir, \"network_config.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(testApk);\n\n log(\"Decoding network_config.apk...\");\n new ApkDecoder(testApk, sConfig).decode(sTestNewDir);\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void netSecConfGeneric() throws Exception {\n log(\"Comparing network security configuration file...\");\n\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \" \\n\"\n + \" \\n\"\n + \" \\n\"\n + \" \\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(sTestNewDir, \"res/xml/network_security_config.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n\n @Test\n public void netSecConfInManifest() throws Exception {\n log(\"Validating network security config in Manifest...\");\n\n // Load the XML document\n Document doc = XmlUtils.loadDocument(new File(sTestNewDir, \"AndroidManifest.xml\"));\n\n // Check if network security config attribute is set correctly\n Node application = doc.getElementsByTagName(\"application\").item(0);\n NamedNodeMap attrs = application.getAttributes();\n Node netSecConfAttr = attrs.getNamedItem(\"android:networkSecurityConfig\");\n assertEquals(\"@xml/network_security_config\", netSecConfAttr.getNodeValue());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/NonStandardPkgIdTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\nimport brut.androlib.res.ResDecoder;\nimport brut.androlib.res.table.ResId;\nimport brut.androlib.res.table.ResTable;\nimport brut.directory.ExtFile;\nimport brut.util.OS;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class NonStandardPkgIdTest extends BaseTest {\n private static ExtFile sTestApk;\n private static ResTable sTable;\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n sTestOrigDir = new File(sTmpDir, \"pkgid8-orig\");\n sTestNewDir = new File(sTmpDir, \"pkgid8-new\");\n\n log(\"Unpacking pkgid8...\");\n copyResourceDir(NonStandardPkgIdTest.class, \"pkgid8\", sTestOrigDir);\n\n sConfig.setVerbose(true);\n\n log(\"Building pkgid8.apk...\");\n sTestApk = new ExtFile(sTmpDir, \"pkgid8.apk\");\n new ApkBuilder(sTestOrigDir, sConfig).build(sTestApk);\n\n log(\"Decoding pkgid8.apk...\");\n ApkInfo testInfo = new ApkInfo();\n testInfo.setApkFile(sTestApk);\n ResDecoder resDecoder = new ResDecoder(testInfo, sConfig);\n OS.mkdir(sTestNewDir);\n resDecoder.decodeResources(sTestNewDir);\n resDecoder.decodeManifest(sTestNewDir);\n sTable = resDecoder.getTable();\n }\n\n @AfterClass\n public static void afterClass() throws Exception {\n sTestApk.close();\n }\n\n @Test\n public void buildAndDecodeTest() {\n assertTrue(sTestNewDir.isDirectory());\n }\n\n @Test\n public void valuesStringsTest() throws Exception {\n compareValuesFiles(\"values/strings.xml\");\n }\n\n @Test\n public void confirmManifestStructureTest() throws Exception {\n compareXmlFiles(\"AndroidManifest.xml\");\n }\n\n @Test\n public void confirmResourcesAreFromPkgId8() throws Exception {\n assertEquals(0x80, sTable.getMainPackage().getId());\n\n assertEquals(0x80, sTable.resolve(ResId.of(0x80020000)).getPackage().getId());\n assertEquals(0x80, sTable.resolve(ResId.of(0x80020001)).getPackage().getId());\n assertEquals(0x80, sTable.resolve(ResId.of(0x80030000)).getPackage().getId());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/OutsideOfDirectoryEntryTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class OutsideOfDirectoryEntryTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(OutsideOfDirectoryEntryTest.class, \"issue1589\", sTmpDir);\n\n File testApk = new File(sTmpDir, \"issue1589.apk\");\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n sTestNewDir = testDir;\n }\n\n @Test\n public void skippedDecodingOfInvalidFileTest() {\n assertTrue(sTestNewDir.isDirectory());\n assertFalse(new File(sTestNewDir, \"assets\").isDirectory());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/ParentDirectoryTraversalTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ParentDirectoryTraversalTest extends BaseTest {\n private static final String apk = \"issue1498.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(ParentDirectoryTraversalTest.class, \"issue1498\", sTmpDir);\n }\n\n @Test\n public void checkIfDrawableFileDecodesProperly() throws Exception {\n sConfig.setDecodeResources(Config.DecodeResources.NONE);\n\n File testApk = new File(sTmpDir, apk);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/ProtectedChunksTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ProtectedChunksTest extends BaseTest {\n private static final String TEST_APK = \"protected_chunks.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(ProtectedChunksTest.class, \"protected_chunks\", sTmpDir);\n }\n\n @Test\n public void checkIfDecodeWorksWithoutCrash() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/values/strings.xml\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/ProviderAttributeTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\nimport static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;\n\npublic class ProviderAttributeTest extends BaseTest {\n private static final String TEST_APK = \"issue636.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(ProviderAttributeTest.class, \"issue636\", sTmpDir);\n }\n\n @Test\n public void isProviderStringReplacementWorking() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n new ApkBuilder(testDir, sConfig).build(null);\n\n File newApk = new File(testDir, \"dist/\" + testApk.getName());\n File newDir = new File(testApk + \".out.new\");\n new ApkDecoder(newApk, sConfig).decode(newDir);\n\n String expected =\n \"\\n\"\n + \"\\n\"\n + \" \\n\"\n + \" \\n\"\n + \" \\n\"\n + \" \\n\"\n + \"\";\n\n String obtained = readTextFile(new File(newDir, \"AndroidManifest.xml\"));\n\n assertXMLEqual(expected, obtained);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/ReferenceVersionCodeTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ReferenceVersionCodeTest extends BaseTest {\n private static final String TEST_APK = \"issue1234.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(ReferenceVersionCodeTest.class, \"issue1234\", sTmpDir);\n }\n\n @Test\n public void referenceBecomesLiteralTest() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n ApkInfo testInfo = ApkInfo.load(testDir);\n assertEquals(\"v1.0.0\", testInfo.getVersionInfo().getVersionName());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/ResourceDirectoryTraversalTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.res.table.ResEntrySpec;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ResourceDirectoryTraversalTest extends BaseTest {\n private static final String TEST_APK = \"GHSA-2hqv-2xv4-5h5w.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(ResourceDirectoryTraversalTest.class, \"arbitrary_write\", sTmpDir);\n }\n\n @Test\n public void checkIfMaliciousRawFileRenamed() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/raw/\" + ResEntrySpec.RENAMED_PREFIX + \"0x7f040000\").exists());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/SharedLibraryTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class SharedLibraryTest extends BaseTest {\n private static final String LIBRARY_APK = \"library.apk\";\n private static final String CLIENT_APK = \"client.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(SharedLibraryTest.class, \"shared_library\", sTmpDir);\n }\n\n @Test\n public void isSharedResourceDecodingAndRebuildingWorking() throws Exception {\n sConfig.setLibraryFiles(new String[] {\n \"com.google.android.test.shared_library:\" + new File(sTmpDir, LIBRARY_APK).getAbsolutePath()\n });\n\n // decode library.apk\n File libraryApk = new File(sTmpDir, LIBRARY_APK);\n File libraryDir = new File(libraryApk + \".out\");\n new ApkDecoder(libraryApk, sConfig).decode(libraryDir);\n\n // decode client.apk\n File clientApk = new File(sTmpDir, CLIENT_APK);\n File clientDir = new File(clientApk + \".out\");\n new ApkDecoder(clientApk, sConfig).decode(clientDir);\n\n // build library.apk\n new ApkBuilder(libraryDir, sConfig).build(null);\n\n assertTrue(new File(libraryDir, \"dist/\" + libraryApk.getName()).exists());\n\n // build client.apk\n new ApkBuilder(clientDir, sConfig).build(null);\n\n assertTrue(new File(clientDir, \"dist/\" + clientApk.getName()).exists());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/SkipAssetTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class SkipAssetTest extends BaseTest {\n private static final String TEST_APK = \"issue1605.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(SkipAssetTest.class, \"issue1605\", sTmpDir);\n }\n\n @Test\n public void checkIfEnablingSkipAssetWorks() throws Exception {\n sConfig.setDecodeAssets(Config.DecodeAssets.NONE);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.none\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertFalse(new File(testDir, \"assets/kotlin.kotlin_builtins\").isFile());\n assertFalse(new File(testDir, \"assets/ranges/ranges.kotlin_builtins\").isFile());\n }\n\n @Test\n public void checkControl() throws Exception {\n sConfig.setDecodeAssets(Config.DecodeAssets.FULL);\n\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out.full\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"assets/kotlin.kotlin_builtins\").isFile());\n assertTrue(new File(testDir, \"assets/ranges/ranges.kotlin_builtins\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/SparseFlagTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.androlib.meta.ApkInfo;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class SparseFlagTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n log(\"Unpacking sparse.apk && not-sparse.apk...\");\n copyResourceDir(SparseFlagTest.class, \"sparse\", sTmpDir);\n }\n\n @Test\n public void decodeWithExpectationOfSparseEntries() throws Exception {\n sConfig.setFrameworkTag(\"issue-3298\");\n\n log(\"Decoding sparse.apk...\");\n File testApk = new File(sTmpDir, \"sparse.apk\");\n File testDir = new File(testApk + \".out\");\n ApkDecoder apkDecoder = new ApkDecoder(testApk, sConfig);\n apkDecoder.decode(testDir);\n ApkInfo apkInfo = apkDecoder.getApkInfo();\n\n assertTrue(\"Expecting sparse entries\", apkInfo.getResourcesInfo().isSparseEntries());\n\n log(\"Building sparse.apk...\");\n new ApkBuilder(testDir, sConfig).build(null);\n }\n\n @Test\n public void decodeWithExpectationOfNoSparseEntries() throws Exception {\n sConfig.setFrameworkTag(\"issue-3298\");\n\n log(\"Decoding not-sparse.apk...\");\n File testApk = new File(sTmpDir, \"not-sparse.apk\");\n File testDir = new File(testApk + \".out\");\n ApkDecoder apkDecoder = new ApkDecoder(testApk, sConfig);\n apkDecoder.decode(testDir);\n ApkInfo apkInfo = apkDecoder.getApkInfo();\n\n assertFalse(\"Expecting not-sparse entries\", apkInfo.getResourcesInfo().isSparseEntries());\n\n log(\"Building not-sparse.apk...\");\n new ApkBuilder(testDir, sConfig).build(null);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/UnknownCompressionTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport brut.directory.ExtFile;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class UnknownCompressionTest extends BaseTest {\n private static ExtFile sTestApk;\n private static ExtFile sNewApk;\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(UnknownCompressionTest.class, \"unknown_compression\", sTmpDir);\n\n sConfig.setFrameworkDirectory(sTmpDir.getAbsolutePath());\n\n log(\"Building unknown_compression.apk...\");\n sTestApk = new ExtFile(sTmpDir, \"unknown_compression.apk\");\n ExtFile testDir = new ExtFile(sTestApk + \".out\");\n new ApkDecoder(sTestApk, sConfig).decode(testDir);\n\n log(\"Decoding unknown_compression.apk...\");\n new ApkBuilder(testDir, sConfig).build(null);\n sNewApk = new ExtFile(testDir, \"dist/\" + sTestApk.getName());\n }\n\n @AfterClass\n public static void afterClass() throws Exception {\n sTestApk.close();\n sNewApk.close();\n }\n\n @Test\n public void pkmExtensionDeflatedTest() throws Exception {\n String fileName = \"assets/bin/Data/test.pkm\";\n int control = sTestApk.getDirectory().getCompressionLevel(fileName);\n int rebuilt = sNewApk.getDirectory().getCompressionLevel(fileName);\n\n // Check that control = rebuilt (both deflated)\n // Add extra check for checking not equal to 0, just in case control gets broken\n assertEquals(control, rebuilt);\n assertNotEquals(0, rebuilt);\n }\n\n @Test\n public void doubleExtensionStoredTest() throws Exception {\n String fileName = \"assets/bin/Data/two.extension.file\";\n int control = sTestApk.getDirectory().getCompressionLevel(fileName);\n int rebuilt = sNewApk.getDirectory().getCompressionLevel(fileName);\n\n // Check that control = rebuilt (both stored)\n // Add extra check for checking = 0 to enforce check for stored just in case control breaks\n assertEquals(control, rebuilt);\n assertEquals(0, rebuilt);\n }\n\n @Test\n public void confirmJsonFileIsDeflatedTest() throws Exception {\n String fileName = \"test.json\";\n int control = sTestApk.getDirectory().getCompressionLevel(fileName);\n int rebuilt = sNewApk.getDirectory().getCompressionLevel(fileName);\n\n assertEquals(control, rebuilt);\n assertEquals(8, rebuilt);\n }\n\n @Test\n public void confirmPngFileIsStoredTest() throws Exception {\n String fileName = \"950x150.png\";\n int control = sTestApk.getDirectory().getCompressionLevel(fileName);\n int rebuilt = sNewApk.getDirectory().getCompressionLevel(fileName);\n\n assertNotEquals(control, rebuilt);\n assertEquals(0, rebuilt);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/VectorDrawableTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib;\n\nimport java.io.File;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class VectorDrawableTest extends BaseTest {\n private static final String TEST_APK = \"issue1456.apk\";\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(VectorDrawableTest.class, \"issue1456\", sTmpDir);\n }\n\n @Test\n public void checkIfDrawableFileDecodesProperly() throws Exception {\n File testApk = new File(sTmpDir, TEST_APK);\n File testDir = new File(testApk + \".out\");\n new ApkDecoder(testApk, sConfig).decode(testDir);\n\n assertTrue(new File(testDir, \"res/drawable/ic_arrow_drop_down_black_24dp.xml\").isFile());\n assertTrue(new File(testDir, \"res/drawable/ic_android_black_24dp.xml\").isFile());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/ApkInfoReaderTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ApkInfoReaderTest extends BaseTest {\n\n @Test\n public void testStandard() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/standard.yml\"));\n checkStandard(apkInfo);\n assertEquals(\"2.8.1\", apkInfo.getVersion());\n }\n\n @Test\n public void testUnknownFields() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/unknown_fields.yml\"));\n checkStandard(apkInfo);\n assertEquals(\"2.8.1\", apkInfo.getVersion());\n }\n\n @Test\n public void testSkipIncorrectIndent() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/skip_incorrect_indent.yml\"));\n checkStandard(apkInfo);\n assertNotEquals(\"2.0.0\", apkInfo.getVersion());\n }\n\n @Test\n public void testFirstIncorrectIndent() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/first_incorrect_indent.yml\"));\n checkStandard(apkInfo);\n assertNotEquals(\"2.0.0\", apkInfo.getVersion());\n }\n\n private void checkStandard(ApkInfo apkInfo) {\n assertEquals(\"standard.apk\", apkInfo.getApkFileName());\n assertEquals(1, apkInfo.getDoNotCompress().size());\n assertEquals(\"arsc\", apkInfo.getDoNotCompress().get(0));\n assertNotNull(apkInfo.getResourcesInfo());\n assertEquals(127, apkInfo.getResourcesInfo().getPackageId());\n assertNull(apkInfo.getResourcesInfo().getPackageName());\n assertFalse(apkInfo.getResourcesInfo().isSparseEntries());\n assertNotNull(apkInfo.getSdkInfo());\n assertEquals(\"25\", apkInfo.getSdkInfo().getMinSdkVersion());\n assertEquals(\"30\", apkInfo.getSdkInfo().getTargetSdkVersion());\n assertNotNull(apkInfo.getUsesFramework());\n assertNotNull(apkInfo.getUsesFramework().getIds());\n assertEquals(1, apkInfo.getUsesFramework().getIds().size());\n assertEquals(1, apkInfo.getUsesFramework().getIds().get(0).intValue());\n assertNull(apkInfo.getUsesFramework().getTag());\n assertNotNull(apkInfo.getVersionInfo());\n assertEquals(-1, apkInfo.getVersionInfo().getVersionCode());\n assertNull(apkInfo.getVersionInfo().getVersionName());\n }\n\n @Test\n public void testUnknownFiles() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/unknown_files.yml\"));\n assertEquals(\"2.0.0\", apkInfo.getVersion());\n assertEquals(\"testapp.apk\", apkInfo.getApkFileName());\n assertNotNull(apkInfo.getUsesFramework());\n assertEquals(1, apkInfo.getUsesFramework().getIds().size());\n assertEquals(1, apkInfo.getUsesFramework().getIds().get(0).intValue());\n assertNotNull(apkInfo.getResourcesInfo());\n assertEquals(127, apkInfo.getResourcesInfo().getPackageId());\n assertNotNull(apkInfo.getVersionInfo());\n assertEquals(1, apkInfo.getVersionInfo().getVersionCode());\n assertEquals(\"1.0\", apkInfo.getVersionInfo().getVersionName());\n assertNotNull(apkInfo.getDoNotCompress());\n assertEquals(5, apkInfo.getDoNotCompress().size());\n assertEquals(\"assets/0byte_file.jpg\", apkInfo.getDoNotCompress().get(0));\n assertEquals(\"arsc\", apkInfo.getDoNotCompress().get(1));\n assertEquals(\"png\", apkInfo.getDoNotCompress().get(2));\n assertEquals(\"mp3\", apkInfo.getDoNotCompress().get(3));\n assertEquals(\"stored.file\", apkInfo.getDoNotCompress().get(4));\n }\n\n @Test\n public void testListWithIndent() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/list_with_indent.yml\"));\n assertEquals(\"2.8.0\", apkInfo.getVersion());\n assertEquals(\"basic.apk\", apkInfo.getApkFileName());\n assertNotNull(apkInfo.getUsesFramework());\n assertEquals(1, apkInfo.getUsesFramework().getIds().size());\n assertEquals(1, apkInfo.getUsesFramework().getIds().get(0).intValue());\n assertEquals(\"tag\", apkInfo.getUsesFramework().getTag());\n assertNotNull(apkInfo.getResourcesInfo());\n assertEquals(127, apkInfo.getResourcesInfo().getPackageId());\n assertEquals(\"com.test.basic\", apkInfo.getResourcesInfo().getPackageName());\n assertTrue(apkInfo.getResourcesInfo().isSparseEntries());\n assertNotNull(apkInfo.getSdkInfo());\n assertEquals(\"4\", apkInfo.getSdkInfo().getMinSdkVersion());\n assertEquals(\"22\", apkInfo.getSdkInfo().getTargetSdkVersion());\n assertEquals(\"30\", apkInfo.getSdkInfo().getMaxSdkVersion());\n assertNotNull(apkInfo.getVersionInfo());\n assertEquals(71, apkInfo.getVersionInfo().getVersionCode());\n assertEquals(\"1.0.70\", apkInfo.getVersionInfo().getVersionName());\n assertNotNull(apkInfo.getDoNotCompress());\n assertEquals(2, apkInfo.getDoNotCompress().size());\n assertEquals(\"arsc\", apkInfo.getDoNotCompress().get(0));\n assertEquals(\"png\", apkInfo.getDoNotCompress().get(1));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/ApkInfoSerializationTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ApkInfoSerializationTest extends BaseTest {\n\n @Test\n public void checkApkInfoSerialization() throws Exception {\n ApkInfo control = ApkInfo.load(getClass().getResourceAsStream(\"/meta/unknown_files.yml\"));\n check(control);\n control.save(sTmpDir);\n\n check(ApkInfo.load(sTmpDir));\n }\n\n private void check(ApkInfo apkInfo) {\n assertEquals(\"2.0.0\", apkInfo.getVersion());\n assertEquals(\"testapp.apk\", apkInfo.getApkFileName());\n assertNotNull(apkInfo.getUsesFramework());\n assertEquals(1, apkInfo.getUsesFramework().getIds().size());\n assertEquals(1, apkInfo.getUsesFramework().getIds().get(0).intValue());\n assertNotNull(apkInfo.getResourcesInfo());\n assertEquals(127, apkInfo.getResourcesInfo().getPackageId());\n assertNotNull(apkInfo.getVersionInfo());\n assertEquals(1, apkInfo.getVersionInfo().getVersionCode());\n assertEquals(\"1.0\", apkInfo.getVersionInfo().getVersionName());\n assertNotNull(apkInfo.getDoNotCompress());\n assertEquals(5, apkInfo.getDoNotCompress().size());\n assertEquals(\"assets/0byte_file.jpg\", apkInfo.getDoNotCompress().get(0));\n assertEquals(\"arsc\", apkInfo.getDoNotCompress().get(1));\n assertEquals(\"png\", apkInfo.getDoNotCompress().get(2));\n assertEquals(\"mp3\", apkInfo.getDoNotCompress().get(3));\n assertEquals(\"stored.file\", apkInfo.getDoNotCompress().get(4));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/ConsistentPropertyTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class ConsistentPropertyTest extends BaseTest {\n\n @Test\n public void testAssertingAllKnownApkInfoProperties() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/basic.yml\"));\n assertEquals(\"2.8.0\", apkInfo.getVersion());\n assertEquals(\"basic.apk\", apkInfo.getApkFileName());\n assertEquals(1, apkInfo.getUsesFramework().getIds().size());\n assertEquals(\"tag\", apkInfo.getUsesFramework().getTag());\n assertEquals(\"4\", apkInfo.getSdkInfo().getMinSdkVersion());\n assertEquals(\"22\", apkInfo.getSdkInfo().getTargetSdkVersion());\n assertEquals(\"30\", apkInfo.getSdkInfo().getMaxSdkVersion());\n assertEquals(127, apkInfo.getResourcesInfo().getPackageId());\n assertEquals(\"com.test.basic\", apkInfo.getResourcesInfo().getPackageName());\n assertTrue(apkInfo.getResourcesInfo().isSparseEntries());\n assertEquals(71, apkInfo.getVersionInfo().getVersionCode());\n assertEquals(\"1.0.70\", apkInfo.getVersionInfo().getVersionName());\n assertEquals(2, apkInfo.getDoNotCompress().size());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/DoNotCompressHieroglyphTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class DoNotCompressHieroglyphTest extends BaseTest {\n\n @Test\n public void testHieroglyph() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/donotcompress_with_hieroglyph.yml\"));\n assertEquals(\"2.0.0\", apkInfo.getVersion());\n assertEquals(\"testapp.apk\", apkInfo.getApkFileName());\n assertEquals(2, apkInfo.getDoNotCompress().size());\n assertEquals(\"assets/AllAssetBundles/Andriod/tx_1001_\u51b0\u539f1\", apkInfo.getDoNotCompress().get(0));\n assertEquals(\"assets/AllAssetBundles/Andriod/tx_1001_\u51b0\u539f1.manifest\", apkInfo.getDoNotCompress().get(1));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/InvalidSdkBoundingTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class InvalidSdkBoundingTest extends BaseTest {\n\n @Test\n public void checkIfInvalidValuesPass() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setMinSdkVersion(\"15\");\n sdkInfo.setTargetSdkVersion(\"25\");\n sdkInfo.setMaxSdkVersion(\"19\");\n\n assertEquals(\"19\", sdkInfo.getTargetSdkVersionBounded());\n }\n\n @Test\n public void checkIfMissingMinPasses() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setTargetSdkVersion(\"25\");\n sdkInfo.setMaxSdkVersion(\"19\");\n\n assertEquals(\"19\", sdkInfo.getTargetSdkVersionBounded());\n }\n\n @Test\n public void checkIfMissingMaxPasses() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setMinSdkVersion(\"15\");\n sdkInfo.setTargetSdkVersion(\"25\");\n\n assertEquals(\"25\", sdkInfo.getTargetSdkVersionBounded());\n }\n\n @Test\n public void checkIfMissingBothPasses() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setTargetSdkVersion(\"25\");\n\n assertEquals(\"25\", sdkInfo.getTargetSdkVersionBounded());\n }\n\n @Test\n public void checkForSdkCodenameOTag() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setTargetSdkVersion(\"O\");\n\n assertEquals(\"26\", sdkInfo.getTargetSdkVersionBounded());\n }\n\n @Test\n public void checkForSdkCodenameSTag() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setTargetSdkVersion(\"S\");\n\n assertEquals(\"31\", sdkInfo.getTargetSdkVersionBounded());\n }\n\n @Test\n public void checkForSdkDevelopmentInsaneTestValue() {\n SdkInfo sdkInfo = new SdkInfo();\n sdkInfo.setTargetSdkVersion(\"SDK_CUR_DEVELOPMENT\");\n\n assertEquals(\"10000\", sdkInfo.getTargetSdkVersionBounded());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/MaliciousYamlTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class MaliciousYamlTest extends BaseTest {\n\n @Test\n public void testMaliciousYaml() throws Exception {\n ApkInfo apkInfo = ApkInfo.load(getClass().getResourceAsStream(\"/meta/cve20220476.yml\"));\n assertEquals(\"2.6.1-ddc4bb-SNAPSHOT\", apkInfo.getVersion());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/meta/YamlLineTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.meta;\n\nimport brut.androlib.BaseTest;\nimport brut.yaml.YamlLine;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class YamlLineTest extends BaseTest {\n\n @Test\n public void testEmptyLine() {\n YamlLine line = new YamlLine(\"\");\n assertEquals(0, line.indent);\n assertTrue(line.isEmpty);\n\n line = new YamlLine(\" \");\n assertEquals(0, line.indent);\n assertTrue(line.isEmpty);\n }\n\n @Test\n public void testComment() {\n YamlLine line = new YamlLine(\"!ApkInfo.class\");\n assertTrue(line.isComment);\n\n line = new YamlLine(\"# This is comment\");\n assertEquals(0, line.indent);\n assertTrue(line.isComment);\n assertEquals(\"\", line.getKey());\n assertEquals(\"This is comment\", line.getValue());\n\n line = new YamlLine(\" # This is comment\");\n assertEquals(2, line.indent);\n assertTrue(line.isComment);\n assertEquals(\"\", line.getKey());\n assertEquals(\"This is comment\", line.getValue());\n }\n\n @Test\n public void testKeyLine() {\n YamlLine line = new YamlLine(\"name:\");\n assertFalse(line.isComment);\n assertEquals(0, line.indent);\n assertEquals(\"name\", line.getKey());\n assertEquals(\"\", line.getValue());\n\n line = new YamlLine(\" name:\");\n assertFalse(line.isComment);\n assertEquals(2, line.indent);\n assertEquals(\"name\", line.getKey());\n assertEquals(\"\", line.getValue());\n\n line = new YamlLine(\":value\");\n assertFalse(line.isComment);\n assertEquals(0, line.indent);\n assertEquals(\"\", line.getKey());\n assertEquals(\"value\", line.getValue());\n\n line = new YamlLine(\" : value \");\n assertFalse(line.isComment);\n assertEquals(2, line.indent);\n assertEquals(\"\", line.getKey());\n assertEquals(\"value\", line.getValue());\n\n line = new YamlLine(\"name : value \");\n assertFalse(line.isComment);\n assertEquals(0, line.indent);\n assertEquals(\"name\", line.getKey());\n assertEquals(\"value\", line.getValue());\n\n line = new YamlLine(\" name : value \");\n assertFalse(line.isComment);\n assertEquals(2, line.indent);\n assertEquals(\"name\", line.getKey());\n assertEquals(\"value\", line.getValue());\n\n line = new YamlLine(\" name : value ::\");\n assertFalse(line.isComment);\n assertEquals(2, line.indent);\n assertEquals(\"name\", line.getKey());\n assertEquals(\"value\", line.getValue());\n\n // split this gives parts.length = 0!!\n line = new YamlLine(\":::\");\n assertFalse(line.isComment);\n assertEquals(0, line.indent);\n assertEquals(\"\", line.getKey());\n assertEquals(\"\", line.getValue());\n }\n\n @Test\n public void testItemLine() {\n YamlLine line = new YamlLine(\"- val1\");\n assertTrue(line.isItem);\n assertEquals(0, line.indent);\n assertEquals(\"\", line.getKey());\n assertEquals(\"val1\", line.getValue());\n\n line = new YamlLine(\" - val1: ff\");\n assertTrue(line.isItem);\n assertEquals(2, line.indent);\n assertEquals(\"\", line.getKey());\n assertEquals(\"val1: ff\", line.getValue());\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/res/AaptVersionTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class AaptVersionTest extends BaseTest {\n\n @Test\n public void testAapt2Iterations() throws Exception {\n assertEquals(2, AaptManager.getVersionFromString(\"Android Asset Packaging Tool (aapt) 2:17\"));\n assertEquals(2, AaptManager.getVersionFromString(\"Android Asset Packaging Tool (aapt) 2.17\"));\n assertEquals(1, AaptManager.getVersionFromString(\"Android Asset Packaging Tool, v0.9\"));\n assertEquals(1, AaptManager.getVersionFromString(\"Android Asset Packaging Tool, v0.2-2679779\"));\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/res/data/StringPoolWithSurrogatePairInUtf8Test.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.data;\n\nimport brut.androlib.BaseTest;\n\nimport java.nio.charset.StandardCharsets;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class StringPoolWithSurrogatePairInUtf8Test extends BaseTest {\n\n @Test\n public void decodeSingleOctet() {\n byte[] bytes = \"abcDEF123\".getBytes(StandardCharsets.UTF_8);\n String actual = new ResStringPool(bytes, true).decodeString(0, 9);\n assertEquals(\"Incorrect decoding\", \"abcDEF123\", actual);\n }\n\n @Test\n public void decodeTwoOctets() {\n byte[] bytes0 = { (byte) 0xC2, (byte) 0x80 };\n String actual0 = new ResStringPool(bytes0, true).decodeString(0, 2);\n assertEquals(\"Incorrect decoding\", \"\\u0080\", actual0);\n\n byte[] bytes1 = { (byte) 0xDF, (byte) 0xBF };\n String actual1 = new ResStringPool(bytes1, true).decodeString(0, 2);\n assertEquals(\"Incorrect decoding\", \"\\u07FF\", actual1);\n }\n\n @Test\n public void decodeThreeOctets() {\n byte[] bytes0 = { (byte) 0xE0, (byte) 0xA0, (byte) 0x80 };\n String actual0 = new ResStringPool(bytes0, true).decodeString(0, 3);\n assertEquals(\"Incorrect decoding\", \"\\u0800\", actual0);\n\n byte[] bytes1 = { (byte) 0xEF, (byte) 0xBF, (byte) 0xBF };\n String actual1 = new ResStringPool(bytes1, true).decodeString(0, 3);\n assertEquals(\"Incorrect decoding\", \"\\uFFFF\", actual1);\n }\n\n @Test\n public void decodeSurrogatePair_when_givesAsThreeOctetsFromInvalidRangeOfUtf8() {\n // See: https://github.com/iBotPeaches/Apktool/issues/2299\n byte[] bytes0 = { (byte) 0xED, (byte) 0xA0, (byte) 0xBD, (byte) 0xED, (byte) 0xB4, (byte) 0x86 };\n String actual0 = new ResStringPool(bytes0, true).decodeString(0, 6);\n assertEquals(\"Incorrect decoding\", \"\\uD83D\\uDD06\", actual0);\n\n // See: https://github.com/iBotPeaches/Apktool/issues/2546\n // Bytes with characters before surrogate pair\n byte[] bytes1 = {\n 'G', 'o', 'o', 'd', ' ', 'm', 'o', 'r', 'n', 'i', 'n', 'g', '!', ' ',\n (byte) 0xED, (byte) 0xA0, (byte) 0xBD, (byte) 0xED, (byte) 0xB1, (byte) 0x8B,\n ' ', 'S', 'u', 'n', ' ',\n (byte) 0xED, (byte) 0xA0, (byte) 0xBC, (byte) 0xED, (byte) 0xBC, (byte) 0x9E\n };\n String actual1 = new ResStringPool(bytes1, true).decodeString(0, 31);\n // D83D -> 0xED 0xA0 0xBD\n // DC4B -> 0xED 0xB1 0x8B\n // D83C -> 0xED 0xA0 0xBC\n // DF1E -> 0xED 0xBC 0x9E\n assertEquals(\"Incorrect decoding when there are valid characters before the surrogate pair\",\n \"Good morning! \\uD83D\\uDC4B Sun \\uD83C\\uDF1E\", actual1);\n }\n\n @Test\n public void decodeSurrogatePair_when_givesAsThreeOctetsFromTheValidRangeOfUtf8() {\n // \\u10FFFF is encoded in UTF-8 as \"0xDBFF 0xDFFF\" (4-byte encoding),\n // but when used in Android resources which are encoded in UTF-8, 3-byte encoding is used,\n // so each of these is encoded as 3-bytes\n byte[] bytes = { (byte) 0xED, (byte) 0xAF, (byte) 0xBF, (byte) 0xED, (byte) 0xBF, (byte) 0xBF };\n String actual = new ResStringPool(bytes, true).decodeString(0, 6);\n assertEquals(\"Incorrect decoding\", \"\\uDBFF\\uDFFF\", actual);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/res/decoder/MissingDiv9PatchTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.decoder;\n\nimport brut.androlib.BaseTest;\nimport brut.androlib.res.data.NinePatchData;\n\nimport javax.imageio.ImageIO;\nimport java.awt.image.BufferedImage;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.InputStream;\nimport java.io.File;\nimport java.nio.file.Files;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class MissingDiv9PatchTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(MissingDiv9PatchTest.class, \"res/decoder/issue1522\", sTmpDir);\n }\n\n @Test\n public void assertMissingDivAdded() throws Exception {\n File file = new File(sTmpDir, \"pip_dismiss_scrim.9.png\");\n byte[] data;\n\n try (InputStream in = Files.newInputStream(file.toPath())) {\n ResNinePatchStreamDecoder decoder = new ResNinePatchStreamDecoder();\n ByteArrayOutputStream out = new ByteArrayOutputStream();\n decoder.decode(in, out);\n data = out.toByteArray();\n }\n\n BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));\n int height = image.getHeight() - 1;\n\n // First and last pixel will be invisible, so let's check the first column and ensure its all black.\n for (int y = 1; y < height; y++) {\n assertEquals(\"y coordinate failed at: \" + y, NinePatchData.COLOR_TICK, image.getRGB(0, y));\n }\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/res/xml/EscapeXmlValueTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.xml;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class EscapeXmlValueTest extends BaseTest {\n\n @Test\n public void escapeXmlValueTest() {\n assertEquals(\"foo\", escape(\"foo\"));\n assertEquals(\"\\\"'foo'\\\"\", escape(\"'foo'\"));\n assertEquals(\"\\\\\\\"foo\\\\\\\"\", escape(\"\\\"foo\\\"\"));\n assertEquals(\"foo&bar\", escape(\"foo&bar\"));\n assertEquals(\"<foo>\", escape(\"\"));\n assertEquals(\"<![CDATA[foo]]>\", escape(\"\"));\n }\n\n private static String escape(String value) {\n return ResStringEncoder.encodeTextValue(value);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/res/xml/PositionalSpecifiersTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.res.xml;\n\nimport brut.androlib.BaseTest;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class PositionalSpecifiersTest extends BaseTest {\n\n @Test\n public void noSpecifiersTest() {\n assertEquals(\"test\", normalize(\"test\"));\n }\n\n @Test\n public void twoSpecifiersTest() {\n assertEquals(\"%1$s, %2$s, and 1 other.\", normalize(\"%s, %s, and 1 other.\"));\n }\n\n @Test\n public void twoPositionalSpecifiersTest() {\n assertEquals(\"%1$s, %2$s and 1 other\", normalize(\"%1$s, %2$s and 1 other\"));\n }\n\n @Test\n public void threeSpecifiersTest() {\n assertEquals(\"%1$s, %2$s, and %3$d other.\", normalize(\"%s, %s, and %d other.\"));\n }\n\n @Test\n public void threePositionalSpecifiersTest() {\n assertEquals(\" %1$s, %2$s and %3$d other\", normalize(\" %1$s, %2$s and %3$d other\"));\n }\n\n @Test\n public void fourSpecifiersTest() {\n assertEquals(\"%1$s, %2$s, and %3$d other and %4$d.\", normalize(\"%s, %s, and %d other and %d.\"));\n }\n\n @Test\n public void fourPositionalSpecifiersTest() {\n assertEquals(\" %1$s, %2$s and %3$d other and %4$d.\", normalize(\" %1$s, %2$s and %3$d other and %4$d.\"));\n }\n\n private String normalize(String value) {\n return ResStringEncoder.normalizeFormatSpecifiers(value);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/java/brut/androlib/util/InvalidDirectoryTraversalTest.java\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n/*\n * Copyright (C) 2010 Ryszard Wi\u015bniewski \n * Copyright (C) 2010 Connor Tumbleson \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage brut.androlib.util;\n\nimport brut.androlib.BaseTest;\nimport brut.util.BrutIO;\nimport brut.util.OSDetection;\n\nimport java.io.File;\nimport java.nio.file.InvalidPathException;\n\nimport org.junit.*;\nimport static org.junit.Assert.*;\n\npublic class InvalidDirectoryTraversalTest extends BaseTest {\n\n @BeforeClass\n public static void beforeClass() throws Exception {\n copyResourceDir(InvalidDirectoryTraversalTest.class, \"util/traversal\", sTmpDir);\n }\n\n @Test\n public void validFileTest() throws Exception {\n String validFileName = BrutIO.sanitizePath(sTmpDir, \"file\");\n assertEquals(validFileName, \"file\");\n assertTrue(new File(sTmpDir, validFileName).isFile());\n }\n\n @Test(expected = InvalidPathException.class)\n public void invalidBackwardFileTest() throws Exception {\n BrutIO.sanitizePath(sTmpDir, \"../file\");\n }\n\n @Test(expected = InvalidPathException.class)\n public void invalidRootFileTest() throws Exception {\n String rootLocation = OSDetection.isWindows() ? \"C:/\" : File.separator;\n BrutIO.sanitizePath(sTmpDir, rootLocation + \"file\");\n }\n\n @Test(expected = InvalidPathException.class)\n public void noFilePassedTest() throws Exception {\n BrutIO.sanitizePath(sTmpDir, \"\");\n }\n\n @Test(expected = InvalidPathException.class)\n public void invalidBackwardPathOnWindows() throws Exception {\n String invalidPath = OSDetection.isWindows() ? \"..\\\\..\\\\app.exe\" : \"../../app\";\n BrutIO.sanitizePath(sTmpDir, invalidPath);\n }\n\n @Test\n public void validDirectoryFileTest() throws Exception {\n String fileName = \"dir\" + File.separator + \"file\";\n String validFileName = BrutIO.sanitizePath(sTmpDir, fileName);\n assertEquals(fileName, validFileName);\n }\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/doctype/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n]>\n\n &e1;\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/issue2328/debuggable-false/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/issue2328/debuggable-false/res/values/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n Hello World\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/issue2328/debuggable-missing/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/issue2328/debuggable-missing/res/values/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n Hello World\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/issue2328/debuggable-true/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/issue2328/debuggable-true/res/values/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n Hello World\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/existing/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n android:networkSecurityConfig=\"@xml/network_security_config\"\n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/existing/res/values/public.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/existing/res/values/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n Hello World\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/existing/res/xml/network_security_config.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n example.com\n \n OEJax6JVAMiUP7wzOiLPU7KW38Cdx3afNZOYR2iOFZ4=\n \n \n \n \n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/none/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/none/res/values/public.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/network_config/none/res/values/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n Hello World\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/pkgid8/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/pkgid8/res/values/integers.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n 117\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/pkgid8/res/values/public.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n \n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/pkgid8/res/values/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n foo\n bar\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/AndroidManifest.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/drawable/$avd_hide_password__0.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/drawable/$avd_show_password__0.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/drawable/$avd_show_password__1.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/drawable/$avd_show_password__2.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/drawable/avd_show_password.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/font/lobster.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/layout/issue1040.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/layout/issue1063.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/layout/issue1157.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/layout/issue1274.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/layout/issue1674.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/navigation/nav_graph.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-ar-rXB/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \"\u200f\u202eForgot\u202c\u200f \u200f\u202eyour\u202c\u200f \u200f\u202eusername\u202c\u200f \u200f\u202eor\u202c\u200f \u200f\u202epassword?\u202c\u200f\\n\u200f\u202eVisit\u202c\u200f \u200f\u202egoogle.com/accounts/recover\u202c\u200f\u200f\u202ey\u202c\u200f\u200f\u202e.\u202c\u200f\"\n \u200f\u202eForgot\u202c\u200f \u200f\u202eyour\u202c\u200f \u200f\u202eusername\u202c\u200f \u200f\u202eor\u202c\u200f \u200f\u202epassword?\u202c\\n.\u200f\u202eVisit\u202c\u200f \u200f\u202egoogle.com/accounts/recover\u202c\u200f\u200f\u202ey\u202c\u200f\n (string8) \"\u200f\u202eForgot\u202c\u200f \u200f\u202eyour\u202c\u200f \u200f\u202eusername\u202c\u200f \u200f\u202eor\u202c\u200f \u200f\u202epassword?\u202c\u200f\\n\u200f\u202eVisit\u202c\u200f \u200f\u202egoogle.com/accounts/recover\u202c\u200f\u200f\u202ey\u202c\u200f\u200f\u202e.\u202c\u200f\"\n Forgot your username or password?\\nVisit google.com/accounts/recovery.\n \u200f\u202eForgot\u202c\u200f \u200f\u202eyour\u202c\u200f \u200f\u202eusername\u202c\u200f \u200f\u202eor\u202c\u200f \u200f\u202epassword?\u202c\u200f\n \u200f\u202eVisit\u202c\u200f \u200f\u202egoogle.com/accounts/recover\u202c\u200f\u200f\u202ey\u202c\u200f\u200f\u202e.\u202c\u200f\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-ast-rES/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-ast/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+ast+Hant+IT+arabext/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n testapp\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+ast+Latn+IT+arevela/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n testapp\n test1\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+de+CH+1901/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n testapp\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+en+Latn+419/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+en+Latn+US/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+en+US+posix/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+eng+419/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-b+iw+660/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n testapp\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-en-rUS/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-en/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n g7sVCIOAIBKwWDzQKE0ThAJKDCPzA5kurfUIPvIaDjX97kuv2lDFS75wF6GVYEMOSrMH0H1MfVMfMgpOXH4LBNuzeGTe8HstiRTzbOnw3wCT7HYsOvfUB11Lq2myfr9vzHCLAdx30m4DPJ2t0QRIk20I1GeF3PzynpQsY550uyYLuu4T7Xwna0eRS26wk02lIDM6eyVKkm4ZpXc6VkLL2p0ibXVjVkalf1f2x5OND5YdQlOOCaz1jMzXZS2xtOqegy74hJrl0UpNiRcyPs8P9wpf6KQS1yHUnUswGmTBsGEvEA39vFkWTgsOKKrVcYMzA4KhZYoeEotgUbVpiAUrcKfJDZtfCAzIVW2RXzPWwtiSYOXDO6oBfDphNQa4B0OwC6m9KmvTwWv2ezjUuwfdJHv2o8vr830PovzkNzwGG3CesyrQWLHalwgMq01UXJRz8zomyloxvan0GMDcj9Kfb8Eljair9AHnFxY2EM6c6E0M3Q0S0rMy8vzUzk9bbFoXcFcpW4yrL4Fdfu0TMbHi6rarFTe49pwwyCaLU8LKBnciumPtyt9dJsTcGdv8nKjBw8Zv3ofWvxuEh8ReLmfKFHrEGUA0wcLh8NkoMmKIqSor6pALhI4bowFfWPYzjiK52TgazGQhrJIkKWXVbZi8aRbkTy0uN7XjT4v1PXzWbpVnUJh80UeFrMO1jEZZFf03oKhi71vREnJb8wZ9JoLNgt9TVFZ6VHAvpFDRzbshSnEZm2P6G8TwmdxORJM1JIj8uvfMcB9fUgQj3Y32AuCcRPN6Xr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ical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-feminine/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-fr/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n http://www.foo.com\n http://www.foo.com\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-ldrtl/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-lowdr-v26/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n Hello World\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001-mnc00/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001-mnc01/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n test1\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/anims.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n @android:anim/bounce_interpolator\n @android:anim/cycle_interpolator\n @android:anim/decelerate_interpolator\n @android:anim/fade_in\n @android:anim/fade_out\n @android:anim/linear_interpolator\n @android:anim/overshoot_interpolator\n @android:anim/slide_in_left\n @android:anim/slide_out_right\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/arrays.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n TEST1\n TEST2\n TEST3\n %2$s foo %1$d\n http://google.com&boo=1&foo=2\n <b>Bolded Text</b>\n <font size=16 align=middle>Small</font>\n \n \n -1\n 0\n 1\n \n \n \n true\n TEST\n 5\n 5.5\n 10.0sp\n #ff123456\n \n \n @string/test1\n foo\n foo2\n \n \n res/\n view/\n \n \n MIICXAIBAAKBgQCjcGqTkOq0CR3rTx0ZSQSIdTrDrFAYl29611xN8aVgMQIWtDB/lD0W5TpKPuU9iaiG/sSn/VYt6EzN7Sr332jj7cyl2WrrHI6ujRswNy4HojMuqtfab5FFDpRmCuvl35fge18OvoQTJELhhJ1EvJ5KUeZiuJ3u3YyMnxxXzLuKbQIDAQABAoGAPrNDz7TKtaLBvaIuMaMXgBopHyQd3jFKbT/tg2Fu5kYm3PrnmCoQfZYXFKCoZUFIS/G1FBVWWGpD/MQ9tbYZkKpwuH+t2rGndMnLXiTC296/s9uix7gsjnT4Naci5N6EN9pVUBwQmGrYUTHFc58ThtelSiPARX7LSU2ibtJSv8ECQQDWBRrrAYmbCUN7ra0DFT6SppaDtvvuKtb+mUeKbg0B8U4y4wCIK5GH8EyQSwUWcXnNBO05rlUPbifsDLv/u82lAkEAw39sTJ0KmJJyaChqvqAJ8guulKlgucQJ0Et9ppZyet9iVwNKX/aW9UlwGBMQdafQ36nd1QMEA8AbAw4D+hw/KQJBANJbHDUGQtk2hrSmZNoV5HXB9Uiq7v4N71k5ER8XwgM5yVGs2tX8dMM3RhnBEtQXXs9LW1uJZSOQcv7JGXNnhN0CQBZenzrJAWxh3XtznHtBfsHWelyCYRIAj4rpCHCmaGUM6IjCVKFUawOYKp5mmAyObkUZf8ue87emJLEdynC1CLkCQHduNjP1hemAGWrd6v8BHhE3kKtcK6KHsPvJR5dOfzbdHAqVePERhISfN6cwZt5p8B3/JUwSR8el66DF7Jm57BM=\n \n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/bools.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n false\n true\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/colors.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n #ff123456\n @android:color/white\n #00000000\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/dimens.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n 10.0dp\n 10.0sp\n 10.0pt\n 10.0px\n 10.0mm\n 10.0in\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/drawables.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n @android:drawable/btn_default\n @drawable/ic_launcher\n #00000000\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/ids.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n @id/test_id1\n @id/test_id3\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/integers.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n -1\n 0\n 1\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/layouts.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n @android:layout/activity_list_item\n @android:layout/browser_link_context_header\n @android:layout/simple_list_item_1\n @android:layout/simple_spinner_item\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/plurals.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n %1$s, %2$d foo\n %1$s, %2$d foo(s)\n \n \n %d foo\n %d foos\n \n \n foo %d moo\n foo %d moos\n \n \n foo 1\n foo %d\n \n \n <b>%d</b> 1\n <b>%d</b> guide123\n \n \n Vous disposez de <font color=#8c593c>%1$d contenu</font> sur <font color=#8c593c>%2$d disponibles</font>\n Vous disposez de <font color=#8c593c>%1$d contenus</font> sur <font color=#8c593c>%2$d disponibles</font>\n \n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/strings.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n @null\n Lorem ipsum...\n \\@null\n \\?missing\n #ff123456\n &\n \"'\"\n \\\"\n \\u0005\n \" foo bar \"\n \"foo\nbar\"\n foobar baz foo\n foobarbaz\n foobarbaz\n foobarbaz\n foobar\"b\n az\"foo\n %d of %d\n foo %d bar %\n %2$s foo %1$d\n %-e foo %,d\n %2$-e foo %1$,d\n %02d foo %01d\n %d foo %1\n %1% foo %2%\n foo %s bar %2$s baz\n \u8cde\u91d1\u9b25\u58eb14\n {id:65538,v:2,tid:20003,mst:1,x:-1,y:-1,a:6000,b:3000,lm:{chp:1000,rep:0,bt:0,mp:[[101,0,1,0],[101,0,1,1],[101,0,1,2],[101,0,1,3],[101,0,1,4],[101,0,1,5],[100,0,0,0],[100,0,0,1],[100,0,0,2],[100,0,0,3],[100,0,0,4],[100,0,0,5]]},rm:{chp:1000,rep:0,bt:0,mp:[[100,0,1,0],[100,0,1,1],[100,0,1,2],[100,0,1,3],[100,0,1,4],[100,0,1,5],[101,0,0,0],[101,0,0,1],[101,0,0,2],[101,0,0,3],[101,0,0,4],[101,0,0,5]]}}\n {al:[[180,0,7,0,0,1000],[109,0,5,0,0],[109,0,5,2,0],[109,0,5,4,0],[100,0,3,0,0],[100,0,3,1,0],[100,0,3,2,0],[100,0,3,3,0],[100,0,3,4,0],[100,0,3,5,0],[103,0,1,0,0],[103,0,1,1,0],[103,0,1,2,0],[103,0,1,3,0],[103,0,1,4,0],[103,0,1,5,0],[106,0,2,0,0],[106,0,2,1,0],[106,0,2,2,0],[106,0,2,3,0],[106,0,2,4,0],[106,0,2,5,0],[800,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[850],[950],[900,0],[1000,0,0]],v:4,s:-1575044211,rl:[[180,0,7,0,0,1000],[103,0,0,0,0],[103,0,0,1,0],[103,0,0,2,0],[103,0,0,3,0],[103,0,0,4,0],[103,0,0,5,0],[111,0,3,0,0],[111,0,3,1,0],[111,0,3,2,0],[111,0,3,3,0],[111,0,3,4,0],[111,0,3,5,0],[102,0,4,0,0],[102,0,4,1,0],[102,0,4,2,0],[102,0,4,3,0],[102,0,4,4,0],[102,0,4,5,0],[107,0,5,0,0],[107,0,5,1,0],[107,0,5,2,0],[107,0,5,3,0],[107,0,5,4,0],[107,0,5,5,0],[106,0,2,0,0],[106,0,2,1,0],[106,0,2,2,0],[106,0,2,3,0],[106,0,2,4,0],[106,0,2,5,0],[900],[1000,0,0]],m:[]}\n category=temp%temp%foo\n res/foo/\n res/foo\n [TEST STRING]\n [TEST STRING]\n [TEST STRING]\n [TEST STRING]\n TEST STRING\n [\u0162\u00e5\u00fe \u0163\u00f6 \u0163\u00fd\u00fe\u00e9 \u00fe\u00e5\u0161\u0161\u0175\u00f6\u0155\u00f0 one two three]\n [\u0162\u00e5\u00fe \u0163\u00f6 \u0163\u00fd\u00fe\u00e9 \u00fe\u00e5\u0161\u0161\u0175\u00f6\u0155\u00f0 one two three]\n [\u0162\u00e5\u00fe \u0163\u00f6 \u0163\u00fd\u00fe\u00e9 \u00fe\u00e5\u0161\u0161\u0175\u00f6\u0155\u00f0 one two three]\n []\u0162\u00e5\u00fe \u0163\u00f6 \u0163\u00fd\u00fe\u00e9 \u00fe\u00e5\u0161\u0161\u0175\u00f6\u0155\u00f0 one two three\n [\u0162\u00e5\u00fe \u0163\u00f6 \u0163\u00fd\u00fe\u00e9 \u00fe\u00e5\u0161\u0161\u0175\u00f6\u0155\u00f0 one two three]\n \ud83d\udd06\n
\n

  • aaaaa aa aaaaa \u2013 aaaaaaa aaaaaaaaaa aa aaaaaaaa aaaaaa aaaaa (aaaa) aaaa aaaaaaaaa aaaaa aa aaaaaaaaa aaaaaaa aaaa
  • aaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaa \u2013 aaaaaaa aaaaaaaaaa aaaaaaaaa aaaa aaaaaa aa aaaa aaaa aaaa aaaa aaaaaaa aaaaaaaaaaaaa, aaaaaa aaa aaaaaaaaaa (aaa) aaaaaaaaaaaaaaa
  • aaaaaaaaaaa aaaaaa aaaaaaaaaa \u2013 aaaaaaaaaa aaaa aaaaaa aa a aaa aa aaaaaa aaa aaaaaaa (aaaaa aaaaaaaa) aaaaaaaa aa aaaaaa aaaaa aaa aaaa
\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'APKTOOL' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: brut.apktool/apktool-lib/src/test/resources/testapp/res/values-mcc001/styles.xml\n<|im_end|>\n<|im_start|>assistant\nREPO: APKTOOL\nCODE:\n\n\n \n \n