-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix baksmali without API version and various optimizations #2604
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
IgorEisberg
commented
Jul 3, 2021
•
edited
Loading
edited
- Organized a few "import" statements and renamed some of the variables/arguments for consistency across the code.
- setAnalysisMode was redesigned properly while ensuring the ResTable always has the up-to-date value of mAnalysisMode.
- Removed setTargetSdkVersion, as it was used before manifest was decoded, thus was doing basically nothing because targetSdkVersion was never available at that point. Even then, using targetSdkVersion for baksmali is incorrect, since dex version used when an APK/JAR was originally built is determined by minSdkVersion, else compatibility with defined minSdkVersion would not be possible in the first place.
- getResTable creates a new table if it doesn't already exist, thus should only be called if necessary (lazy initialization): either by ApkDecoder when decoding manifest and/or resources (and only when those are available), or explicitly by Test code. Otherwise, resource table is unnecessary. In the case of writeMetaFile and its putX methods: putX methods which depend on a ResTable are only called if mResTable is defined, thus the use of getResTable is redundant here.
- Unless the user forces an API level for decoding, let baksmali handle the proper opcodes to use automatically. When DexBackedDexFile gets opcodes==null, it calls getDefaultOpcodes(dexVersion) which returns the appropriate opcodes for the given dex version. No hints are required for baksmali, but of course still needed for smali.
When DexBackedDexFile gets opcodes==null, it calls getDefaultOpcodes(dexVersion) which returns the appropriate opcodes for the given dex version. No hints are required for baksmali, but only needed for smali. https://github.com/JesusFreke/smali/blob/master/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java#L83
iBotPeaches
reviewed
Jul 3, 2021
brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
Outdated
Show resolved
Hide resolved
iBotPeaches
approved these changes
Jul 3, 2021
thanks! |
iBotPeaches
added a commit
that referenced
this pull request
Jul 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.