├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── test │ ├── resources │ │ └── type_id_offset.apk │ └── java │ │ └── com │ │ └── reandroid │ │ ├── arsc │ │ ├── array │ │ │ └── SparseOffsetsArrayTest.java │ │ ├── value │ │ │ └── AttributeTypeTest.java │ │ ├── coder │ │ │ └── CoderTest.java │ │ └── chunk │ │ │ └── PackageBlockTest.java │ │ ├── TestUtils.java │ │ ├── xml │ │ └── SpanAttributesDecoderTest.java │ │ └── utils │ │ └── collection │ │ └── LinkedIteratorTest.java └── main │ ├── resources │ ├── frameworks │ │ └── android │ │ │ ├── android-23.apk │ │ │ ├── android-24.apk │ │ │ ├── android-25.apk │ │ │ ├── android-26.apk │ │ │ ├── android-27.apk │ │ │ ├── android-28.apk │ │ │ ├── android-29.apk │ │ │ ├── android-30.apk │ │ │ ├── android-31.apk │ │ │ ├── android-32.apk │ │ │ ├── android-33.apk │ │ │ ├── android-34.apk │ │ │ ├── android-35.apk │ │ │ └── android-36.apk │ └── arsclib.properties │ └── java │ ├── com │ └── reandroid │ │ ├── dex │ │ ├── ins │ │ │ ├── InsNop.java │ │ │ ├── Ins30t.java │ │ │ ├── LabelsSet.java │ │ │ ├── Size10Ins.java │ │ │ ├── ConstNumber.java │ │ │ ├── Size8Ins.java │ │ │ ├── PayloadEntry.java │ │ │ ├── Size2Ins.java │ │ │ ├── ExceptionLabel.java │ │ │ ├── Size6Ins.java │ │ │ ├── ConstNumberLong.java │ │ │ ├── ConstString.java │ │ │ ├── Ins22.java │ │ │ ├── Size4Ins.java │ │ │ ├── InsConst.java │ │ │ ├── Ins22s.java │ │ │ ├── SparseSwitchEntryKey.java │ │ │ ├── Ins22c.java │ │ │ ├── Ins22cs.java │ │ │ ├── InsConst16.java │ │ │ ├── InsConst16High.java │ │ │ ├── InsConstWideHigh16.java │ │ │ ├── Ins22x.java │ │ │ ├── InsSparseSwitch.java │ │ │ ├── Ins10x.java │ │ │ ├── Ins23x.java │ │ │ └── Ins22b.java │ │ ├── README.md │ │ ├── base │ │ │ ├── FixedSizeBlock.java │ │ │ ├── PositionAlignedItem.java │ │ │ ├── PositionedItem.java │ │ │ ├── OffsetReceiver.java │ │ │ ├── DexArraySupplier.java │ │ │ ├── DexPositionAlign.java │ │ │ └── DexBlockAlign.java │ │ ├── key │ │ │ ├── KeyItem.java │ │ │ ├── KeyReference.java │ │ │ ├── DualKeyReference.java │ │ │ ├── MemberKey.java │ │ │ ├── TypeKeyReference.java │ │ │ └── ProgramKey.java │ │ ├── common │ │ │ ├── FullRefresh.java │ │ │ ├── DefIndex.java │ │ │ └── EditableItem.java │ │ ├── smali │ │ │ ├── SmaliRegion.java │ │ │ ├── SmaliFormat.java │ │ │ ├── SmaliParser.java │ │ │ ├── model │ │ │ │ ├── SmaliCodeCatchAll.java │ │ │ │ ├── SmaliDebugElement.java │ │ │ │ ├── SmaliDebugEndLocal.java │ │ │ │ ├── SmaliDebugEpilogue.java │ │ │ │ ├── SmaliDebugRestartLocal.java │ │ │ │ ├── SmaliDebugPrologue.java │ │ │ │ ├── SmaliPackedSwitchEntry.java │ │ │ │ └── SmaliValue.java │ │ │ └── SmaliReaderSetting.java │ │ ├── io │ │ │ └── ByteReader.java │ │ ├── reference │ │ │ ├── DataReference.java │ │ │ └── DexReference.java │ │ ├── program │ │ │ ├── AccessibleProgram.java │ │ │ ├── ProgramElement.java │ │ │ ├── MethodParameter.java │ │ │ └── FieldProgram.java │ │ ├── debug │ │ │ ├── DebugEndLocal.java │ │ │ ├── DebugRestartLocal.java │ │ │ ├── DebugEndSequence.java │ │ │ └── DebugAdvanceLine.java │ │ ├── data │ │ │ ├── FixedDexContainerWithTool.java │ │ │ ├── FieldDefArray.java │ │ │ └── MethodDefArray.java │ │ ├── model │ │ │ ├── DexCode.java │ │ │ └── AccessibleDex.java │ │ ├── dexopt │ │ │ ├── ProfileData.java │ │ │ ├── LinkableProfileItem.java │ │ │ └── ProfileMetadataV1.java │ │ ├── header │ │ │ └── CountAndOffset.java │ │ ├── sections │ │ │ ├── IdSectionArray.java │ │ │ └── SpecialItem.java │ │ └── value │ │ │ ├── ProtoValue.java │ │ │ ├── FieldIdValue.java │ │ │ ├── MethodIdValue.java │ │ │ ├── MethodHandleValue.java │ │ │ └── TypeValue.java │ │ ├── xml │ │ ├── base │ │ │ ├── XmlReader.java │ │ │ ├── NodeFactory.java │ │ │ ├── Document.java │ │ │ ├── Comment.java │ │ │ ├── Text.java │ │ │ ├── Attribute.java │ │ │ ├── Element.java │ │ │ └── Node.java │ │ ├── SpanSet.java │ │ ├── source │ │ │ └── XMLParserSource.java │ │ └── StyleText.java │ │ ├── arsc │ │ ├── chunk │ │ │ ├── MainChunk.java │ │ │ ├── ParentChunk.java │ │ │ └── xml │ │ │ │ ├── ResXmlNamespace.java │ │ │ │ ├── ResXmlNodeList.java │ │ │ │ └── ResXmlChunkList.java │ │ ├── value │ │ │ └── bag │ │ │ │ └── Bag.java │ │ ├── base │ │ │ ├── BlockRefresh.java │ │ │ ├── BlockCreator.java │ │ │ ├── Creator.java │ │ │ ├── DirectStreamReader.java │ │ │ ├── BlockArrayCreator.java │ │ │ └── OffsetSupplier.java │ │ ├── item │ │ │ ├── WeakStringReference.java │ │ │ ├── IntegerReference.java │ │ │ ├── BooleanReference.java │ │ │ ├── StringCreator.java │ │ │ ├── StringReference.java │ │ │ ├── LongReference.java │ │ │ ├── ReferenceItem.java │ │ │ └── NumberIntegerReference.java │ │ ├── coder │ │ │ ├── xml │ │ │ │ ├── XmlCoderLogger.java │ │ │ │ ├── XmlStringDecoder.java │ │ │ │ ├── ValuesSerializerFactory.java │ │ │ │ └── XmlEncodeException.java │ │ │ ├── CoderColorRGB4.java │ │ │ ├── CoderColorRGB8.java │ │ │ ├── CoderColorARGB4.java │ │ │ ├── CoderColorARGB8.java │ │ │ └── CoderDimension.java │ │ ├── io │ │ │ └── BlockLoad.java │ │ └── array │ │ │ ├── OffsetArray.java │ │ │ ├── ResValueMapArray.java │ │ │ └── SpecBlockArray.java │ │ ├── json │ │ ├── JSONString.java │ │ ├── XMLXsiTypeConverter.java │ │ ├── JSONConvert.java │ │ ├── JSONStringer.java │ │ ├── JSONPointerException.java │ │ ├── JSONPropertyIgnore.java │ │ ├── JSONPropertyName.java │ │ ├── JSONException.java │ │ └── HTTPTokener.java │ │ ├── utils │ │ ├── collection │ │ │ ├── EmptyItem.java │ │ │ ├── SizedItem.java │ │ │ ├── Swappable.java │ │ │ ├── SizedIterator.java │ │ │ ├── SizedSupplier.java │ │ │ ├── SwapListener.java │ │ │ └── SingleIterator.java │ │ └── Checksum.java │ │ ├── common │ │ ├── CountSupplier.java │ │ ├── ArraySupplier.java │ │ └── DiagnosticsReporter.java │ │ ├── app │ │ └── AndroidApp.java │ │ ├── archive │ │ ├── io │ │ │ ├── ZipOutput.java │ │ │ ├── ZipInput.java │ │ │ ├── ReadOnlyStream.java │ │ │ ├── WriteOnlyStream.java │ │ │ ├── RandomStream.java │ │ │ └── ArchiveByteEntrySource.java │ │ ├── WriteProgress.java │ │ ├── ArchiveException.java │ │ ├── block │ │ │ ├── v2 │ │ │ │ └── V2Signature.java │ │ │ ├── v3 │ │ │ │ ├── SchemeV3.java │ │ │ │ └── SchemeV31.java │ │ │ ├── stamp │ │ │ │ ├── SchemeStampV1.java │ │ │ │ └── SchemeStampV2.java │ │ │ ├── CertificateBlockList.java │ │ │ ├── CertificateBlockV2.java │ │ │ ├── LengthPrefixedBytes.java │ │ │ ├── CertificateBlock.java │ │ │ └── BottomBlock.java │ │ └── writer │ │ │ ├── BufferFileOutput.java │ │ │ ├── HeaderInterceptor.java │ │ │ ├── RenamedArchiveSource.java │ │ │ ├── EntryBuffer.java │ │ │ └── ByteOutputSource.java │ │ ├── apk │ │ ├── APKLogger.java │ │ ├── DexProfileEncoder.java │ │ ├── DexProfileDecoder.java │ │ ├── DexEncoder.java │ │ ├── DecodeFilter.java │ │ ├── xmlencoder │ │ │ └── EncodeException.java │ │ └── DexDecoder.java │ │ └── graph │ │ └── BaseApkModuleProcessor.java │ └── android │ └── content │ └── res │ └── XmlResourceParser.java ├── .gitignore └── .github └── workflows └── gradle-test.yml /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ARSCLib' 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/test/resources/type_id_offset.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/test/resources/type_id_offset.apk -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /.gradle/ 3 | /build/ 4 | /test-apk/ 5 | /src/main/java/zorg/ 6 | /gradle/wrapper/gradle-wrapper.properties -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-23.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-23.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-24.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-24.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-25.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-25.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-26.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-26.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-27.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-27.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-28.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-28.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-29.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-29.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-30.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-30.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-31.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-31.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-32.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-32.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-33.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-33.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-34.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-34.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-35.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-35.apk -------------------------------------------------------------------------------- /src/main/resources/frameworks/android/android-36.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REAndroid/ARSCLib/HEAD/src/main/resources/frameworks/android/android-36.apk -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/InsNop.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.dex.ins; 2 | 3 | public class InsNop extends Ins10x{ 4 | public InsNop() { 5 | super(Opcode.NOP); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/arsclib.properties: -------------------------------------------------------------------------------- 1 | lib.name=ARSCLib 2 | lib.version=${version} 3 | lib.repo=https://github.com/REAndroid/ARSCLib 4 | lib.description=Android binary resources read/write library 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https://services.gradle.org/distributions/gradle-6.5.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/XmlReader.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.xml.base; 2 | 3 | import org.xmlpull.v1.XmlPullParser; 4 | import org.xmlpull.v1.XmlPullParserException; 5 | 6 | import java.io.IOException; 7 | 8 | public interface XmlReader { 9 | void parse(XmlPullParser parser) throws XmlPullParserException, IOException; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/chunk/MainChunk.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.arsc.chunk; 2 | 3 | import com.reandroid.arsc.ApkFile; 4 | import com.reandroid.arsc.pool.StringPool; 5 | 6 | public interface MainChunk { 7 | StringPool getStringPool(); 8 | ApkFile getApkFile(); 9 | void setApkFile(ApkFile apkFile); 10 | TableBlock getTableBlock(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | public interface JSONString { 9 | 10 | public String toJSONString(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/XMLXsiTypeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | public interface XMLXsiTypeConverter { 9 | T convert(String value); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONConvert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | public interface JSONConvert { 9 | public T toJson(); 10 | public void fromJson(T json); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/value/bag/Bag.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.arsc.value.bag; 2 | 3 | import com.reandroid.arsc.value.Entry; 4 | 5 | public interface Bag { 6 | Entry getEntry(); 7 | default String getName(){ 8 | Entry entry =getEntry(); 9 | if(entry ==null){ 10 | return null; 11 | } 12 | return entry.getName(); 13 | } 14 | default String getTypeName(){ 15 | Entry entry =getEntry(); 16 | if(entry ==null){ 17 | return null; 18 | } 19 | return entry.getTypeName(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONStringer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | import java.io.StringWriter; 9 | 10 | public class JSONStringer extends JSONWriter { 11 | 12 | public JSONStringer() { 13 | super(new StringWriter()); 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return this.mode == 'd' ? this.writer.toString() : null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONPointerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | public class JSONPointerException extends JSONException { 9 | private static final long serialVersionUID = 8872944667561856751L; 10 | 11 | public JSONPointerException(String message) { 12 | super(message); 13 | } 14 | 15 | public JSONPointerException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONPropertyIgnore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | import static java.lang.annotation.ElementType.METHOD; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | @Documented 16 | @Retention(RUNTIME) 17 | @Target({METHOD}) 18 | 19 | public @interface JSONPropertyIgnore { } 20 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONPropertyName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | import static java.lang.annotation.ElementType.METHOD; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.Documented; 12 | import java.lang.annotation.Retention; 13 | import java.lang.annotation.Target; 14 | 15 | @Documented 16 | @Retention(RUNTIME) 17 | @Target({METHOD}) 18 | 19 | public @interface JSONPropertyName { 20 | 21 | String value(); 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/gradle-test.yml: -------------------------------------------------------------------------------- 1 | name: Build Jar 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK 8 20 | uses: actions/setup-java@v4 21 | with: 22 | java-version: '8' 23 | distribution: 'temurin' 24 | - uses: gradle/actions/setup-gradle@v4 25 | - name: Test and build jar 26 | run: ./gradlew test jar 27 | - uses: actions/upload-artifact@v4 28 | with: 29 | name: ARSCLib 30 | path: build/libs 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/README.md: -------------------------------------------------------------------------------- 1 | ## Library for manipulating dex files 2 | 3 | ### The goal of this project 4 | 5 | - Fast and efficient dex read/write/edit 6 | - Create referenced-link between resources & dex classes. Like resource ids, class names ... 7 | - Easily search/replace/add/remove any dex code parts without the need to disassemble 8 | 9 | ### References 10 | 11 | - [dex_file_structs.h](https://cs.android.com/android/platform/superproject/main/+/refs/heads/main:art/libdexfile/dex/dex_file_structs.h) 12 | - [dex_file.h](https://cs.android.com/android/platform/superproject/main/+/refs/heads/main:art/libdexfile/dex/dex_file.h) 13 | - [JesusFreke/smali](https://github.com/JesusFreke/smali) 14 | 15 | #### _NB: This is just experimental, and not fully implemented yet._ 16 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/JSONException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | public class JSONException extends IllegalArgumentException { 9 | /** Serialization ID */ 10 | private static final long serialVersionUID = 0; 11 | 12 | public JSONException(final String message) { 13 | super(message); 14 | } 15 | 16 | public JSONException(final String message, final Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public JSONException(final Throwable cause) { 21 | super(cause.getMessage(), cause); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/FixedSizeBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | public interface FixedSizeBlock { 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/key/KeyItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.key; 17 | 18 | public interface KeyItem { 19 | Key getKey(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/EmptyItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | public interface EmptyItem { 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/common/CountSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.common; 17 | 18 | public interface CountSupplier { 19 | int getCount(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/base/BlockRefresh.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.base; 17 | 18 | public interface BlockRefresh { 19 | void refresh(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/app/AndroidApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.app; 17 | 18 | public interface AndroidApp { 19 | AndroidManifest getAndroidManifest(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/io/ZipOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.io; 17 | 18 | public abstract class ZipOutput implements WriteOnlyStream{ 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/SizedItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | public interface SizedItem { 19 | int size(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/WeakStringReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public interface WeakStringReference extends ReferenceItem{ 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/common/FullRefresh.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.reandroid.dex.common; 18 | 19 | public interface FullRefresh { 20 | void refreshFull(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/common/ArraySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.common; 17 | 18 | public interface ArraySupplier extends CountSupplier { 19 | T get(int i); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/key/KeyReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.key; 17 | 18 | public interface KeyReference extends KeyItem { 19 | void setKey(Key key); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/Swappable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | public interface Swappable { 19 | boolean swap(int i, int j); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/SizedIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | public interface SizedIterator { 19 | int getRemainingSize(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/NodeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | public interface NodeFactory { 19 | Element newElement(); 20 | Text newText(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/base/BlockCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.base; 17 | 18 | public interface BlockCreator { 19 | T newInstance(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/IntegerReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public interface IntegerReference { 19 | int get(); 20 | void set(int value); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/PositionAlignedItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | public interface PositionAlignedItem { 19 | DexPositionAlign getPositionAlign(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/BooleanReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public interface BooleanReference { 19 | boolean get(); 20 | void set(boolean value); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/StringCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public interface StringCreator { 19 | T newInstance(boolean utf8); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/StringReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public interface StringReference { 19 | String get(); 20 | void set(String value); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/SmaliRegion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali; 17 | 18 | public interface SmaliRegion extends SmaliFormat{ 19 | SmaliDirective getSmaliDirective(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/SizedSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | public interface SizedSupplier extends SizedItem{ 19 | T get(int index); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/SpanSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml; 17 | 18 | import java.util.Iterator; 19 | 20 | public interface SpanSet{ 21 | Iterator getSpans(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/Document.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | public interface Document> extends Node, NodeFactory{ 19 | E getDocumentElement(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/PositionedItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | public interface PositionedItem { 19 | void setPosition(int position); 20 | void removeLastAlign(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins30t.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Ins30t extends Size6Ins { 19 | public Ins30t(Opcode opcode) { 20 | super(opcode); 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/LabelsSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import java.util.Iterator; 19 | 20 | public interface LabelsSet { 21 | Iterator getLabels(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | public interface Comment extends Node{ 19 | 20 | String getText(); 21 | void setText(String text); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/key/DualKeyReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.key; 17 | 18 | public interface DualKeyReference extends KeyReference { 19 | Key getKey2(); 20 | void setKey2(Key key); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/WriteProgress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive; 17 | 18 | public interface WriteProgress { 19 | void onCompressFile(String path, int mode, long writtenBytes); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/LongReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public interface LongReference extends IntegerReference { 19 | long getLong(); 20 | void set(long value); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Size10Ins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Size10Ins extends SizeXIns { 19 | public Size10Ins(Opcode opcode) { 20 | super(opcode); 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/key/MemberKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.key; 17 | 18 | public interface MemberKey extends ProgramKey { 19 | 20 | String getName(); 21 | MemberKey changeName(String name); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/io/ByteReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.io; 17 | 18 | import java.io.IOException; 19 | 20 | public interface ByteReader { 21 | int read() throws IOException; 22 | int count(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/SmaliFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali; 17 | 18 | import java.io.IOException; 19 | 20 | public interface SmaliFormat { 21 | void append(SmaliWriter writer) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/SmaliParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali; 17 | 18 | import java.io.IOException; 19 | 20 | public interface SmaliParser { 21 | void parse(SmaliReader reader) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/arsc/array/SparseOffsetsArrayTest.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.arsc.array; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SparseOffsetsArrayTest { 7 | @Test 8 | public void testSetOffset() { 9 | //offsets are encoded is 16-bit, real_offset = offset * 4 10 | final SparseOffsetsArray sparseArr = new SparseOffsetsArray(); 11 | 12 | final int offset = 0x10; 13 | final int index = 0x0000; 14 | 15 | //put data 16 | final int data = ((offset / 4) << 16) | index; 17 | sparseArr.set(new int[]{ data }); 18 | Assert.assertEquals(offset, sparseArr.getOffset(0)); 19 | 20 | //test setOffset 21 | sparseArr.clear(); 22 | sparseArr.setSize(1); 23 | sparseArr.setOffset(0, offset); 24 | Assert.assertEquals(offset, sparseArr.getOffset(0)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/common/DefIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.common; 17 | 18 | import com.reandroid.dex.key.ProgramKey; 19 | 20 | public interface DefIndex { 21 | int getDefinitionIndex(); 22 | ProgramKey getKey(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/Text.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | public interface Text extends Node{ 19 | String getText(); 20 | void setText(String text); 21 | @Override 22 | NodeTree getParentNode(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/APKLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk; 17 | 18 | public interface APKLogger { 19 | void logMessage(String msg); 20 | void logError(String msg, Throwable tr); 21 | void logVerbose(String msg); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/xml/XmlCoderLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder.xml; 17 | 18 | public interface XmlCoderLogger { 19 | void logMessage(String tag, String message); 20 | void logVerbose(String tag, String message); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/OffsetReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | import com.reandroid.arsc.item.IntegerReference; 19 | 20 | public interface OffsetReceiver { 21 | void setOffsetReference(IntegerReference reference); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/key/TypeKeyReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.key; 17 | 18 | public interface TypeKeyReference extends KeyReference { 19 | @Override 20 | TypeKey getKey(); 21 | @Override 22 | void setKey(Key typeKey); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/key/ProgramKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.key; 17 | 18 | import java.lang.annotation.ElementType; 19 | 20 | public interface ProgramKey extends Key { 21 | TypeKey getDeclaring(); 22 | ElementType getElementType(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/DexProfileEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | 21 | public interface DexProfileEncoder { 22 | void encodeDexProfile(File mainDirectory) throws IOException; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/io/ZipInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.io; 17 | 18 | import java.io.IOException; 19 | 20 | public abstract class ZipInput implements ReadOnlyStream { 21 | public abstract byte[] getFooter(int minLength) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/common/EditableItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.reandroid.dex.common; 18 | 19 | import com.reandroid.arsc.base.Block; 20 | 21 | public interface EditableItem { 22 | void editInternal(Block user); 23 | default void edit(){ 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/TestUtils.java: -------------------------------------------------------------------------------- 1 | package com.reandroid; 2 | 3 | import com.reandroid.utils.io.FileUtil; 4 | import org.junit.Assert; 5 | 6 | import java.io.File; 7 | 8 | public class TestUtils { 9 | 10 | public static File getTesApkDirectory(){ 11 | return new File("test-apk"); 12 | } 13 | public static File getTempDir(){ 14 | File dir = null; 15 | Throwable throwable = null; 16 | try{ 17 | dir = FileUtil.getTempDir(); 18 | }catch (Throwable ex){ 19 | throwable = ex; 20 | } 21 | Assert.assertNotNull("Failed to create temp root directory: " + throwable, dir); 22 | dir = new File(dir, "test"); 23 | Assert.assertTrue("Failed to create temp sub dir: " + dir, dir.exists() || dir.mkdirs()); 24 | return dir; 25 | } 26 | public static void log(String message){ 27 | System.out.println(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/ArchiveException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive; 17 | 18 | import java.io.IOException; 19 | 20 | public class ArchiveException extends IOException { 21 | public ArchiveException(String message){ 22 | super(message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/base/Creator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.base; 17 | 18 | public interface Creator extends BlockCreator { 19 | T newInstance(); 20 | default T newInstanceAt(int index){ 21 | return newInstance(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/DexProfileDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | 21 | public interface DexProfileDecoder { 22 | void decodeDexProfile(ApkModule apkModule, File mainDirectory) throws IOException; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/base/DirectStreamReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.base; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | 21 | public interface DirectStreamReader { 22 | int readBytes(InputStream inputStream) throws IOException; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/reference/DataReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.reference; 17 | 18 | import com.reandroid.dex.data.DataItem; 19 | 20 | public interface DataReference extends DexReference{ 21 | T getOrCreate(); 22 | void unlink(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/ReferenceItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | import com.reandroid.arsc.base.Block; 19 | 20 | public interface ReferenceItem extends IntegerReference{ 21 | T1 getReferredParent(Class parentClass); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/ConstNumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.arsc.item.IntegerReference; 19 | 20 | public interface ConstNumber extends IntegerReference, RegistersSet { 21 | int getRegister(); 22 | void setRegister(int register); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/base/BlockArrayCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.base; 17 | 18 | public interface BlockArrayCreator extends BlockCreator{ 19 | default T[] newArrayInstance(int length) { 20 | throw new RuntimeException(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/v2/V2Signature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block.v2; 17 | 18 | import com.reandroid.archive.block.LengthPrefixedBytes; 19 | 20 | public class V2Signature extends LengthPrefixedBytes { 21 | public V2Signature() { 22 | super(false); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Size8Ins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Size8Ins extends SizeXIns { 19 | public Size8Ins(Opcode opcode) { 20 | super(opcode); 21 | } 22 | 23 | @Override 24 | public int getCodeUnits() { 25 | return 4; 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/program/AccessibleProgram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.program; 17 | 18 | 19 | import java.lang.annotation.ElementType; 20 | 21 | public interface AccessibleProgram extends AccessibleItem, ProgramElement { 22 | 23 | @Override 24 | ElementType getElementType(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/SwapListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | public interface SwapListener { 19 | 20 | void onSwap(int i, int j); 21 | 22 | static SwapListener redirectTo(Swappable swappable) { 23 | return swappable::swap; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/io/BlockLoad.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.io; 17 | 18 | import com.reandroid.arsc.base.Block; 19 | 20 | import java.io.IOException; 21 | 22 | public interface BlockLoad { 23 | public void onBlockLoaded(BlockReader reader, Block sender) throws IOException; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/chunk/ParentChunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.chunk; 17 | 18 | import com.reandroid.arsc.pool.StringPool; 19 | 20 | public interface ParentChunk { 21 | StringPool getSpecStringPool(); 22 | MainChunk getMainChunk(); 23 | PackageBlock getPackageBlock(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/PayloadEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.arsc.item.IntegerReference; 19 | import com.reandroid.dex.smali.SmaliFormat; 20 | 21 | public interface PayloadEntry extends IntegerReference, SmaliFormat { 22 | PayloadData getPayload(); 23 | int getIndex(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/program/ProgramElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.program; 17 | 18 | import com.reandroid.dex.key.ProgramKey; 19 | 20 | import java.lang.annotation.ElementType; 21 | 22 | public interface ProgramElement extends AnnotatedProgram { 23 | ProgramKey getKey(); 24 | ElementType getElementType(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/source/XMLParserSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.source; 17 | 18 | import org.xmlpull.v1.XmlPullParser; 19 | import org.xmlpull.v1.XmlPullParserException; 20 | 21 | 22 | public interface XMLParserSource { 23 | XmlPullParser getParser() throws XmlPullParserException; 24 | String getPath(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/io/ReadOnlyStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.io; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | 21 | public interface ReadOnlyStream extends RandomStream{ 22 | long getLength() throws IOException; 23 | InputStream getInputStream(long offset, long length) throws IOException; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/android/content/res/XmlResourceParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package android.content.res; 18 | 19 | import android.util.AttributeSet; 20 | import org.xmlpull.v1.XmlPullParser; 21 | 22 | public interface XmlResourceParser extends XmlPullParser, AttributeSet, AutoCloseable { 23 | String getAttributeNamespace (int index); 24 | void close(); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/array/OffsetArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.array; 17 | 18 | public interface OffsetArray { 19 | int getOffset(int i); 20 | void setOffset(int index, int value); 21 | int[] getOffsets(); 22 | int size(); 23 | void setSize(int count); 24 | void clear(); 25 | 26 | int NO_ENTRY = 0xFFFFFFFF; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/xml/SpanAttributesDecoderTest.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.xml; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SpanAttributesDecoderTest { 7 | @Test 8 | public void testDecoding() { 9 | StyleElement element = new StyleElement(); 10 | element.setName("tag"); 11 | testDecoding(element, "name1=;name2=value2"); 12 | testDecoding(element, "=name1=;name2=value2"); 13 | testDecoding(element, "name1"); 14 | testDecoding(element, "href=https://example.com/?bb=cc;qq=4;id=xyz;style=color:black; width:100%; nowrap;"); 15 | } 16 | public void testDecoding(StyleElement element, String attrs) { 17 | SpanAttributesDecoder decoder = new SpanAttributesDecoder(element, attrs); 18 | if (decoder.decode()) { 19 | Assert.assertEquals(attrs, element.getSpanAttributes()); 20 | } else { 21 | Assert.assertEquals(attrs, element.getSpanAttributes().substring(1)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/DexEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk; 17 | 18 | import com.reandroid.archive.InputSource; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | public interface DexEncoder { 25 | List buildDexFiles(ApkModuleEncoder encoder, File mainDirectory) throws IOException; 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/arsc/value/AttributeTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.arsc.value; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class AttributeTypeTest { 7 | private final static AttributeType[] PLURALS = new AttributeType[]{ 8 | AttributeType.OTHER, 9 | AttributeType.ZERO, 10 | AttributeType.ONE, 11 | AttributeType.TWO, 12 | AttributeType.FEW, 13 | AttributeType.MANY 14 | }; 15 | private final static AttributeType[] NON_PLURALS = new AttributeType[]{ 16 | AttributeType.FORMATS, 17 | AttributeType.MIN, 18 | AttributeType.MAX, 19 | AttributeType.L10N 20 | }; 21 | 22 | @Test 23 | public void testIsPlural() { 24 | for(AttributeType type : PLURALS) { 25 | Assert.assertTrue(type.isPlural()); 26 | } 27 | 28 | for(AttributeType type : NON_PLURALS) { 29 | Assert.assertFalse(type.isPlural()); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/v3/SchemeV3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block.v3; 17 | 18 | import com.reandroid.archive.block.SignatureId; 19 | import com.reandroid.archive.block.UnknownScheme; 20 | 21 | // TODO: implement structure 22 | public class SchemeV3 extends UnknownScheme { 23 | public SchemeV3() { 24 | super(SignatureId.V3); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/v3/SchemeV31.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block.v3; 17 | 18 | import com.reandroid.archive.block.SignatureId; 19 | import com.reandroid.archive.block.UnknownScheme; 20 | 21 | // TODO: implement structure 22 | public class SchemeV31 extends UnknownScheme { 23 | public SchemeV31() { 24 | super(SignatureId.V31); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/io/WriteOnlyStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.io; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.io.OutputStream; 21 | 22 | public interface WriteOnlyStream extends RandomStream{ 23 | void write(InputStream inputStream) throws IOException; 24 | OutputStream getOutputStream() throws IOException; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/writer/BufferFileOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.writer; 17 | 18 | import com.reandroid.archive.io.ZipFileOutput; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | 23 | public class BufferFileOutput extends ZipFileOutput { 24 | public BufferFileOutput(File file) throws IOException { 25 | super(file); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/DexArraySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | import com.reandroid.common.ArraySupplier; 19 | import com.reandroid.arsc.item.IntegerReference; 20 | 21 | import java.util.Iterator; 22 | 23 | public interface DexArraySupplier extends ArraySupplier { 24 | IntegerReference getOffsetReference(); 25 | Iterator iterator(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/base/OffsetSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.base; 17 | 18 | import com.reandroid.arsc.io.BlockReader; 19 | import com.reandroid.arsc.item.IntegerReference; 20 | 21 | import java.io.IOException; 22 | 23 | public interface OffsetSupplier { 24 | IntegerReference getOffsetReference(); 25 | void readBytes(BlockReader reader) throws IOException; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Size2Ins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Size2Ins extends SizeXIns { 19 | public Size2Ins(Opcode opcode) { 20 | super(opcode); 21 | } 22 | @Override 23 | public int getData(){ 24 | return getNibble(2); 25 | } 26 | 27 | @Override 28 | public int getCodeUnits() { 29 | return 1; 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/stamp/SchemeStampV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block.stamp; 17 | 18 | import com.reandroid.archive.block.SignatureId; 19 | import com.reandroid.archive.block.UnknownScheme; 20 | 21 | // TODO: implement structure 22 | public class SchemeStampV1 extends UnknownScheme { 23 | public SchemeStampV1() { 24 | super(SignatureId.STAMP_V1); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/stamp/SchemeStampV2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block.stamp; 17 | 18 | import com.reandroid.archive.block.SignatureId; 19 | import com.reandroid.archive.block.UnknownScheme; 20 | 21 | // TODO: implement structure 22 | public class SchemeStampV2 extends UnknownScheme { 23 | public SchemeStampV2() { 24 | super(SignatureId.STAMP_V2); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/debug/DebugEndLocal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.debug; 17 | 18 | public class DebugEndLocal extends DebugRegisterNumber { 19 | 20 | public DebugEndLocal() { 21 | super(0, DebugElementType.END_LOCAL); 22 | } 23 | 24 | @Override 25 | public DebugElementType getElementType() { 26 | return DebugElementType.END_LOCAL; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/CertificateBlockList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block; 17 | 18 | 19 | public class CertificateBlockList extends LengthPrefixedList{ 20 | public CertificateBlockList() { 21 | super(false); 22 | } 23 | @Override 24 | public CertificateBlockV2 newInstance() { 25 | return new CertificateBlockV2(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/data/FixedDexContainerWithTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.data; 17 | 18 | import com.reandroid.dex.base.FixedDexContainer; 19 | import com.reandroid.dex.common.SectionTool; 20 | 21 | public class FixedDexContainerWithTool extends FixedDexContainer implements SectionTool { 22 | public FixedDexContainerWithTool(int childesCount) { 23 | super(childesCount); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/ExceptionLabel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public interface ExceptionLabel extends Label{ 19 | ExceptionHandler getHandler(); 20 | 21 | @Override 22 | default boolean isRemoved() { 23 | return getHandler().isRemoved(); 24 | } 25 | 26 | @Override 27 | default int compareLabelName(Label label) { 28 | return 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/io/RandomStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.io; 17 | 18 | import java.io.IOException; 19 | import java.nio.channels.Channel; 20 | 21 | public interface RandomStream extends Channel { 22 | long position() throws IOException; 23 | void position(long pos) throws IOException; 24 | @Override 25 | void close() throws IOException; 26 | @Override 27 | boolean isOpen(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/array/ResValueMapArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.array; 17 | 18 | import com.reandroid.arsc.value.ResValueMap; 19 | 20 | public class ResValueMapArray extends CompoundItemArray { 21 | public ResValueMapArray(){ 22 | super(); 23 | } 24 | 25 | @Override 26 | public ResValueMap newInstance() { 27 | return new ResValueMap(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/chunk/xml/ResXmlNamespace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.chunk.xml; 17 | 18 | import com.reandroid.common.Namespace; 19 | 20 | public interface ResXmlNamespace extends Namespace { 21 | void setUri(String uri); 22 | void setPrefix(String uri); 23 | int getUriReference(); 24 | int getLineNumber(); 25 | void setLineNumber(int lineNumber); 26 | boolean isUnused(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/common/DiagnosticsReporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.common; 17 | 18 | public interface DiagnosticsReporter { 19 | void report(DiagnosticMessage message); 20 | default boolean isReportEnabled() { 21 | return true; 22 | } 23 | default boolean isVerboseEnabled() { 24 | return false; 25 | } 26 | default boolean isDebugEnabled() { 27 | return false; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/debug/DebugRestartLocal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.debug; 17 | 18 | public class DebugRestartLocal extends DebugRegisterNumber { 19 | 20 | public DebugRestartLocal() { 21 | super(0, DebugElementType.RESTART_LOCAL); 22 | } 23 | 24 | @Override 25 | public DebugElementType getElementType() { 26 | return DebugElementType.RESTART_LOCAL; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/io/ArchiveByteEntrySource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.io; 17 | 18 | import com.reandroid.archive.ArchiveEntry; 19 | 20 | public class ArchiveByteEntrySource extends ArchiveEntrySource { 21 | 22 | public ArchiveByteEntrySource(ZipByteInput zipInput, ArchiveEntry archiveEntry){ 23 | super(zipInput, archiveEntry); 24 | setSort(archiveEntry.getIndex()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/xml/XmlStringDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder.xml; 17 | 18 | import com.reandroid.arsc.item.StringItem; 19 | import org.xmlpull.v1.XmlSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public interface XmlStringDecoder { 24 | void serializeText(StringItem stringItem, XmlSerializer serializer) throws IOException; 25 | String decodeAttributeValue(StringItem stringItem); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliCodeCatchAll.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.smali.SmaliDirective; 19 | 20 | public class SmaliCodeCatchAll extends SmaliCodeExceptionHandler{ 21 | 22 | public SmaliCodeCatchAll(){ 23 | super(); 24 | } 25 | 26 | @Override 27 | public SmaliDirective getSmaliDirective() { 28 | return SmaliDirective.CATCH_ALL; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/chunk/xml/ResXmlNodeList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.chunk.xml; 17 | 18 | import com.reandroid.arsc.container.BlockList; 19 | 20 | public class ResXmlNodeList extends BlockList { 21 | 22 | public ResXmlNodeList() { 23 | super(); 24 | } 25 | 26 | @Override 27 | public void onPreRemove(ResXmlNode item) { 28 | super.onPreRemove(item); 29 | item.onPreRemove(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/CoderColorRGB4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder; 17 | 18 | import com.reandroid.arsc.value.ValueType; 19 | 20 | public class CoderColorRGB4 extends CoderColor{ 21 | public CoderColorRGB4() { 22 | super(4); 23 | } 24 | 25 | @Override 26 | public ValueType getValueType() { 27 | return ValueType.COLOR_RGB4; 28 | } 29 | public static final CoderColorRGB4 INS = new CoderColorRGB4(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/CoderColorRGB8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder; 17 | 18 | import com.reandroid.arsc.value.ValueType; 19 | 20 | public class CoderColorRGB8 extends CoderColor{ 21 | public CoderColorRGB8() { 22 | super(7); 23 | } 24 | 25 | @Override 26 | public ValueType getValueType(){ 27 | return ValueType.COLOR_RGB8; 28 | } 29 | 30 | public static final CoderColorRGB8 INS = new CoderColorRGB8(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/xml/ValuesSerializerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder.xml; 17 | 18 | import com.reandroid.arsc.chunk.TypeBlock; 19 | import org.xmlpull.v1.XmlSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public interface ValuesSerializerFactory { 24 | void onFinish(XmlSerializer serializer, int writtenEntries) throws IOException; 25 | XmlSerializer createSerializer(TypeBlock typeBlock) throws IOException; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/CoderColorARGB4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder; 17 | 18 | import com.reandroid.arsc.value.ValueType; 19 | 20 | public class CoderColorARGB4 extends CoderColor{ 21 | public CoderColorARGB4() { 22 | super(5); 23 | } 24 | 25 | @Override 26 | public ValueType getValueType() { 27 | return ValueType.COLOR_ARGB4; 28 | } 29 | public static final CoderColorARGB4 INS = new CoderColorARGB4(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/CoderColorARGB8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder; 17 | 18 | import com.reandroid.arsc.value.ValueType; 19 | 20 | public class CoderColorARGB8 extends CoderColor{ 21 | public CoderColorARGB8() { 22 | super(9); 23 | } 24 | 25 | @Override 26 | public ValueType getValueType() { 27 | return ValueType.COLOR_ARGB8; 28 | } 29 | public static final CoderColorARGB8 INS = new CoderColorARGB8(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Size6Ins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Size6Ins extends SizeXIns { 19 | public Size6Ins(Opcode opcode) { 20 | super(opcode); 21 | } 22 | @Override 23 | public int getData(){ 24 | return getShortUnsigned(2); 25 | } 26 | public void setData(int data){ 27 | setShort(2, data); 28 | } 29 | 30 | @Override 31 | public int getCodeUnits() { 32 | return 3; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/model/DexCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.model; 17 | 18 | public abstract class DexCode extends Dex { 19 | 20 | public DexCode(){ 21 | } 22 | 23 | public abstract DexMethod getDexMethod(); 24 | 25 | public DexClass getDexClass(){ 26 | return getDexMethod().getDexClass(); 27 | } 28 | @Override 29 | public DexClassRepository getClassRepository() { 30 | return getDexMethod().getClassRepository(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliDebugElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.debug.DebugElementType; 19 | import com.reandroid.dex.smali.SmaliDirective; 20 | 21 | public abstract class SmaliDebugElement extends SmaliDebug { 22 | 23 | public SmaliDirective getSmaliDirective() { 24 | return getDebugElementType().getSmaliDirective(); 25 | } 26 | public abstract DebugElementType getDebugElementType(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/writer/HeaderInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.writer; 17 | 18 | import com.reandroid.archive.block.CentralEntryHeader; 19 | import com.reandroid.archive.block.DataDescriptor; 20 | import com.reandroid.archive.block.LocalFileHeader; 21 | 22 | public interface HeaderInterceptor { 23 | void onWriteLfh(LocalFileHeader localFileHeader); 24 | void onWriteDD(DataDescriptor dataDescriptor); 25 | void onWriteCeh(CentralEntryHeader header); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/debug/DebugEndSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.debug; 17 | 18 | public class DebugEndSequence extends DebugElement{ 19 | 20 | private DebugEndSequence() { 21 | super(0, DebugElementType.END_SEQUENCE); 22 | } 23 | 24 | @Override 25 | public DebugElementType getElementType() { 26 | return DebugElementType.END_SEQUENCE; 27 | } 28 | 29 | public static final DebugEndSequence INSTANCE = new DebugEndSequence(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliDebugEndLocal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.debug.DebugElementType; 19 | import com.reandroid.dex.debug.DebugEndLocal; 20 | 21 | public class SmaliDebugEndLocal extends SmaliDebugRegister { 22 | 23 | public SmaliDebugEndLocal(){ 24 | super(); 25 | } 26 | 27 | @Override 28 | public DebugElementType getDebugElementType() { 29 | return DebugElementType.END_LOCAL; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliDebugEpilogue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.debug.DebugElementType; 19 | import com.reandroid.dex.debug.DebugEpilogue; 20 | 21 | public class SmaliDebugEpilogue extends SmaliDebugElement { 22 | 23 | public SmaliDebugEpilogue(){ 24 | super(); 25 | } 26 | 27 | @Override 28 | public DebugElementType getDebugElementType() { 29 | return DebugElementType.EPILOGUE; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/chunk/xml/ResXmlChunkList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.chunk.xml; 17 | 18 | import com.reandroid.arsc.container.BlockList; 19 | 20 | class ResXmlChunkList extends BlockList { 21 | 22 | ResXmlChunkList() { 23 | super(); 24 | } 25 | 26 | public void clear() { 27 | clearChildes(); 28 | } 29 | @Override 30 | public void onPreRemove(T item) { 31 | super.onPreRemove(item); 32 | item.onPreRemove(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/CertificateBlockV2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block; 17 | 18 | public class CertificateBlockV2 extends LengthPrefixedBytes implements CertificateBlock{ 19 | 20 | public CertificateBlockV2() { 21 | super(false); 22 | } 23 | @Override 24 | public byte[] getCertificateBytes() { 25 | return getByteArray().toArray().clone(); 26 | } 27 | @Override 28 | public void setCertificate(byte[] bytes){ 29 | getByteArray().set(bytes); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/ConstNumberLong.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public interface ConstNumberLong extends ConstNumber{ 19 | long getLong(); 20 | void set(long value); 21 | @Override 22 | default int get() { 23 | long l = getLong(); 24 | int i = (int) l; 25 | if((i & 0xffffffffL) != l){ 26 | return 0; 27 | } 28 | return i; 29 | } 30 | @Override 31 | default void set(int value) { 32 | set((long) value); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/array/SpecBlockArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.array; 17 | 18 | import com.reandroid.arsc.base.BlockArray; 19 | import com.reandroid.arsc.chunk.SpecBlock; 20 | 21 | public class SpecBlockArray extends BlockArray { 22 | public SpecBlockArray(){ 23 | super(); 24 | } 25 | @Override 26 | public SpecBlock newInstance() { 27 | return new SpecBlock(); 28 | } 29 | 30 | @Override 31 | protected void onRefreshed() { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliDebugRestartLocal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.debug.DebugElementType; 19 | import com.reandroid.dex.debug.DebugRestartLocal; 20 | 21 | public class SmaliDebugRestartLocal extends SmaliDebugRegister { 22 | 23 | public SmaliDebugRestartLocal(){ 24 | super(); 25 | } 26 | 27 | @Override 28 | public DebugElementType getDebugElementType() { 29 | return DebugElementType.RESTART_LOCAL; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/xml/XmlEncodeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder.xml; 17 | 18 | import com.reandroid.xml.XMLUtil; 19 | import org.xmlpull.v1.XmlPullParser; 20 | 21 | import java.io.IOException; 22 | 23 | public class XmlEncodeException extends IOException { 24 | 25 | public XmlEncodeException(String message) { 26 | super(message); 27 | } 28 | 29 | public XmlEncodeException(XmlPullParser parser, String message) { 30 | this(XMLUtil.getSimplePositionDescription(parser) + "\n" + message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/DecodeFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | public class DecodeFilter { 22 | private final Set mExcludePaths; 23 | public DecodeFilter(){ 24 | mExcludePaths = new HashSet<>(); 25 | } 26 | public void addExclude(String path){ 27 | if(path != null){ 28 | mExcludePaths.add(path); 29 | } 30 | } 31 | public boolean isExcluded(String path){ 32 | return mExcludePaths.contains(path); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/ConstString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.dex.id.StringId; 19 | import com.reandroid.dex.key.StringKey; 20 | 21 | public interface ConstString { 22 | 23 | String getString(); 24 | void setString(StringKey key); 25 | int getRegister(); 26 | void setRegister(int register); 27 | default void setString(String text){ 28 | setString(StringKey.create(text)); 29 | } 30 | default void setString(StringId id){ 31 | ((SizeXIns) this).setSectionId(id); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliDebugPrologue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.debug.DebugElementType; 19 | import com.reandroid.dex.debug.DebugPrologue; 20 | import com.reandroid.dex.smali.*; 21 | 22 | public class SmaliDebugPrologue extends SmaliDebugElement implements SmaliRegion { 23 | 24 | public SmaliDebugPrologue(){ 25 | super(); 26 | } 27 | 28 | @Override 29 | public DebugElementType getDebugElementType() { 30 | return DebugElementType.PROLOGUE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/program/MethodParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.program; 17 | 18 | import com.reandroid.dex.key.TypeKey; 19 | 20 | import java.lang.annotation.ElementType; 21 | 22 | public interface MethodParameter extends ProgramElement { 23 | 24 | @Override 25 | TypeKey getKey(); 26 | int getDefinitionIndex(); 27 | int getRegister(); 28 | 29 | String getDebugName(); 30 | void setDebugName(String name); 31 | 32 | @Override 33 | default ElementType getElementType() { 34 | return ElementType.PARAMETER; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/Attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | import com.reandroid.common.Namespace; 19 | 20 | public interface Attribute extends Node, NamedNode{ 21 | 22 | String getValueAsString(); 23 | Object getValueAsEncoded(); 24 | 25 | Namespace getNamespace(); 26 | void setNamespace(Namespace namespace); 27 | @Override 28 | Element getParentNode(); 29 | 30 | default Object getAttributeValue(){ 31 | return getValueAsString(); 32 | } 33 | default int getNameId() { 34 | return 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/dexopt/ProfileData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.dexopt; 17 | 18 | import com.reandroid.json.JSONConvert; 19 | import com.reandroid.json.JSONObject; 20 | import com.reandroid.utils.ObjectsUtil; 21 | 22 | public interface ProfileData extends LinkableProfileItem, JSONConvert { 23 | String getName(); 24 | void setName(String name); 25 | boolean isInitialized(); 26 | void setInitialized(boolean initialized); 27 | 28 | default boolean equalsName(String name) { 29 | return ObjectsUtil.equals(getName(), name); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/model/AccessibleDex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.model; 17 | 18 | import com.reandroid.dex.program.AccessibleProgram; 19 | 20 | public interface AccessibleDex extends AnnotatedDex, AccessibleProgram { 21 | @Override 22 | AccessibleProgram getProgramElement(); 23 | 24 | @Override 25 | default int getAccessFlagsValue() { 26 | return getProgramElement().getAccessFlagsValue(); 27 | } 28 | @Override 29 | default void setAccessFlagsValue(int value) { 30 | getProgramElement().setAccessFlagsValue(value); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins22.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public abstract class Ins22 extends Size4Ins implements RegistersSet { 19 | 20 | public Ins22(Opcode opcode) { 21 | super(opcode); 22 | } 23 | 24 | @Override 25 | public final int getRegistersCount() { 26 | return 2; 27 | } 28 | @Override 29 | public final void setRegistersCount(int count) { 30 | } 31 | @Override 32 | public abstract int getRegister(int index); 33 | @Override 34 | public abstract void setRegister(int index, int value); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/header/CountAndOffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.header; 17 | 18 | import com.reandroid.dex.base.BlockIntegerPair; 19 | 20 | public class CountAndOffset extends BlockIntegerPair { 21 | public CountAndOffset(){ 22 | super(); 23 | } 24 | public int getCount(){ 25 | return getFirst().get(); 26 | } 27 | public void setCount(int count){ 28 | getFirst().set(count); 29 | } 30 | public int getOffset(){ 31 | return getSecond().get(); 32 | } 33 | public void setOffset(int offset){ 34 | getSecond().set(offset); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Size4Ins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Size4Ins extends SizeXIns { 19 | public Size4Ins(Opcode opcode) { 20 | super(opcode); 21 | } 22 | public Size4Ins(Opcode opcode, boolean hasSectionData) { 23 | super(opcode, hasSectionData); 24 | } 25 | @Override 26 | public int getData(){ 27 | return getShortUnsigned(2); 28 | } 29 | @Override 30 | public void setData(int data){ 31 | setShort(2, data); 32 | } 33 | 34 | @Override 35 | public int getCodeUnits() { 36 | return 2; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/xmlencoder/EncodeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk.xmlencoder; 17 | 18 | import com.reandroid.xml.XMLUtil; 19 | import org.xmlpull.v1.XmlPullParser; 20 | 21 | public class EncodeException extends IllegalArgumentException { 22 | public EncodeException(String message) { 23 | super(message); 24 | } 25 | public EncodeException(XmlPullParser parser, String message) { 26 | this(XMLUtil.getSimplePositionDescription(parser) + "\n" + message); 27 | } 28 | public EncodeException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/InsConst.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class InsConst extends Ins31i implements ConstNumber { 19 | 20 | public InsConst() { 21 | super(Opcode.CONST); 22 | } 23 | 24 | @Override 25 | public int get() { 26 | return getData(); 27 | } 28 | @Override 29 | public void set(int value) { 30 | setData(value); 31 | } 32 | 33 | @Override 34 | public int getRegister() { 35 | return getRegister(0); 36 | } 37 | @Override 38 | public void setRegister(int register) { 39 | setRegister(0, register); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/arsc/coder/CoderTest.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.arsc.coder; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class CoderTest { 7 | @Test 8 | public void testCoder(){ 9 | for(String decoded : DECODED_VALUES){ 10 | EncodeResult encodeResult = ValueCoder.encode(decoded); 11 | Assert.assertNotNull("Fail to encode: " + decoded, encodeResult); 12 | String decoded2 = ValueCoder.decode(encodeResult.valueType, encodeResult.value); 13 | Assert.assertEquals(decoded, decoded2); 14 | } 15 | } 16 | private static final String[] DECODED_VALUES = new String[]{ 17 | "10.1dp", 18 | "-10.1dp", 19 | "100.0sp", 20 | "200.0pt", 21 | "-100.0mm", 22 | "400.0in", 23 | "100.0%p", 24 | "50.0%", 25 | "-50.0%", 26 | "#ffaa", 27 | "#ffaabb", 28 | "#ffaabbcc", 29 | "123456", 30 | "-123456", 31 | "123.45", 32 | "-123.45", 33 | "1.45E19", 34 | "1.45E-19", 35 | "0xdef01234", 36 | "true", 37 | "false", 38 | "@null", 39 | "@empty" 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/DexPositionAlign.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | import com.reandroid.arsc.io.BlockReader; 19 | import com.reandroid.arsc.item.AlignItem; 20 | 21 | import java.io.IOException; 22 | 23 | public class DexPositionAlign extends AlignItem { 24 | 25 | public DexPositionAlign() { 26 | super(); 27 | } 28 | 29 | public DexPositionAlign(int alignment) { 30 | super(alignment); 31 | } 32 | 33 | @Override 34 | public void onReadBytes(BlockReader reader) throws IOException { 35 | super.align(reader.getPosition()); 36 | super.onReadBytes(reader); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins22s.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Ins22s extends Ins22 { 19 | public Ins22s(Opcode opcode) { 20 | super(opcode); 21 | } 22 | 23 | @Override 24 | public int getRegister(int index) { 25 | return getNibble(2 + index); 26 | } 27 | @Override 28 | public void setRegister(int index, int value) { 29 | setNibble(2 + index, value); 30 | } 31 | 32 | @Override 33 | public int getData(){ 34 | return getShortSigned(); 35 | } 36 | @Override 37 | public void setData(int data){ 38 | setShort(2, data); 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/SparseSwitchEntryKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.arsc.base.Creator; 19 | import com.reandroid.arsc.item.IntegerItem; 20 | 21 | public class SparseSwitchEntryKey extends IntegerItem { 22 | private Ins targetIns; 23 | 24 | public SparseSwitchEntryKey() { 25 | super(); 26 | } 27 | 28 | public Ins getTargetIns() { 29 | return targetIns; 30 | } 31 | 32 | public void setTargetIns(Ins targetIns) { 33 | this.targetIns = targetIns; 34 | } 35 | 36 | public static final Creator CREATOR = SparseSwitchEntryKey::new; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/json/HTTPTokener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 JSON.org (now "Public Domain") 3 | * This is NOT property of REAndroid 4 | * This package is renamed from org.json.* to avoid class conflict when used on android platforms 5 | */ 6 | package com.reandroid.json; 7 | 8 | public class HTTPTokener extends JSONTokener { 9 | 10 | public HTTPTokener(String string) { 11 | super(string); 12 | } 13 | public String nextToken() throws JSONException { 14 | char c; 15 | char q; 16 | StringBuilder sb = new StringBuilder(); 17 | do { 18 | c = next(); 19 | } while (Character.isWhitespace(c)); 20 | if (c == '"' || c == '\'') { 21 | q = c; 22 | for (;;) { 23 | c = next(); 24 | if (c < ' ') { 25 | throw syntaxError("Unterminated string."); 26 | } 27 | if (c == q) { 28 | return sb.toString(); 29 | } 30 | sb.append(c); 31 | } 32 | } 33 | for (;;) { 34 | if (c == 0 || Character.isWhitespace(c)) { 35 | return sb.toString(); 36 | } 37 | sb.append(c); 38 | c = next(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/utils/collection/LinkedIteratorTest.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.utils.collection; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import java.io.File; 7 | import java.util.Iterator; 8 | import java.util.List; 9 | 10 | public class LinkedIteratorTest { 11 | 12 | @Test 13 | public void testFileParents() { 14 | File file = new File( 15 | File.separatorChar + "H" + 16 | File.separatorChar + "G" + 17 | File.separatorChar + "F" + 18 | File.separatorChar + "E" + 19 | File.separatorChar + "D" + 20 | File.separatorChar + "C" + 21 | File.separatorChar + "B" + 22 | File.separatorChar + "A"); 23 | 24 | Iterator iterator = LinkedIterator.of(file, File::getParentFile); 25 | List fileList = CollectionUtil.collect(iterator); 26 | Assert.assertEquals("itemList size", 8, fileList.size()); 27 | 28 | iterator = LinkedIterator.of(true, file, File::getParentFile); 29 | 30 | List fileListIncludingSelf = CollectionUtil.collect(iterator); 31 | Assert.assertEquals("fileListIncludingSelf size", 9, fileListIncludingSelf.size()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins22c.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Ins22c extends Ins22 { 19 | public Ins22c(Opcode opcode) { 20 | super(opcode); 21 | } 22 | 23 | @Override 24 | public int getRegister(int index) { 25 | return getNibble(2 + index); 26 | } 27 | @Override 28 | public void setRegister(int index, int value) { 29 | setNibble(2 + index, value); 30 | } 31 | 32 | @Override 33 | public int getData(){ 34 | return getShortUnsigned(2); 35 | } 36 | @Override 37 | public void setData(int data){ 38 | setShort(2, data); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins22cs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Ins22cs extends Ins22 { 19 | 20 | public Ins22cs(Opcode opcode) { 21 | super(opcode); 22 | } 23 | 24 | @Override 25 | public int getRegister(int index) { 26 | return getNibble(2 + index); 27 | } 28 | @Override 29 | public void setRegister(int index, int value) { 30 | setNibble(2 + index, value); 31 | } 32 | 33 | @Override 34 | public int getData(){ 35 | return getShortUnsigned(2); 36 | } 37 | @Override 38 | public void setData(int data){ 39 | setShort(2, data); 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/InsConst16.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class InsConst16 extends Ins21s implements RegistersSet, ConstNumber { 19 | 20 | public InsConst16() { 21 | super(Opcode.CONST_16); 22 | } 23 | 24 | @Override 25 | public int get() { 26 | return getData(); 27 | } 28 | @Override 29 | public void set(int value) { 30 | setData(value); 31 | } 32 | @Override 33 | public int getRegister() { 34 | return getRegister(0); 35 | } 36 | @Override 37 | public void setRegister(int register) { 38 | setRegister(0, register); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/LengthPrefixedBytes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block; 17 | 18 | import com.reandroid.arsc.item.ByteArray; 19 | 20 | public class LengthPrefixedBytes extends LengthPrefixedBlock{ 21 | private final ByteArray byteArray; 22 | public LengthPrefixedBytes(boolean is_long) { 23 | super(1, is_long); 24 | this.byteArray = new ByteArray(); 25 | addChild(this.byteArray); 26 | } 27 | 28 | public ByteArray getByteArray() { 29 | return byteArray; 30 | } 31 | @Override 32 | protected void onSizeLoaded(int dataSize){ 33 | this.byteArray.setSize(dataSize); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/coder/CoderDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.coder; 17 | 18 | import com.reandroid.arsc.value.ValueType; 19 | 20 | public class CoderDimension extends CoderComplexData { 21 | 22 | @Override 23 | ComplexUnit parseUnit(String text) { 24 | return UnitDimension.fromPostfix(text); 25 | } 26 | 27 | @Override 28 | public String decode(int data) { 29 | return ComplexUtil.decodeComplex(false, data); 30 | } 31 | @Override 32 | public ValueType getValueType() { 33 | return ValueType.DIMENSION; 34 | } 35 | 36 | public static final CoderDimension INS = new CoderDimension(); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/arsc/item/NumberIntegerReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.arsc.item; 17 | 18 | public class NumberIntegerReference implements IntegerReference { 19 | private int value; 20 | 21 | public NumberIntegerReference(int value){ 22 | this.value = value; 23 | } 24 | public NumberIntegerReference(){ 25 | this(0); 26 | } 27 | 28 | @Override 29 | public int get() { 30 | return this.value; 31 | } 32 | @Override 33 | public void set(int value) { 34 | this.value = value; 35 | } 36 | @Override 37 | public String toString() { 38 | return Integer.toString(get()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/sections/IdSectionArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.sections; 17 | 18 | import com.reandroid.arsc.base.Creator; 19 | import com.reandroid.arsc.io.BlockReader; 20 | import com.reandroid.dex.base.IntegerPair; 21 | import com.reandroid.dex.id.IdItem; 22 | 23 | import java.io.IOException; 24 | 25 | public class IdSectionArray extends SectionArray { 26 | 27 | public IdSectionArray(IntegerPair countAndOffset, Creator creator) { 28 | super(countAndOffset, creator); 29 | } 30 | 31 | public void readChild(BlockReader reader, T item) throws IOException{ 32 | item.onReadBytes(reader); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/Element.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | import com.reandroid.common.Namespace; 19 | 20 | import java.util.Iterator; 21 | 22 | public interface Element 23 | extends NodeTree, NamedNode, NodeFactory{ 24 | 25 | int getAttributeCount(); 26 | Attribute getAttributeAt(int i); 27 | Iterator getAttributes(); 28 | 29 | int getNamespaceCount(); 30 | Namespace getNamespaceAt(int i); 31 | Iterator getNamespaces(); 32 | Element newElement(); 33 | Attribute newAttribute(); 34 | Namespace newNamespace(String uri, String prefix); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/writer/RenamedArchiveSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.writer; 17 | 18 | import com.reandroid.archive.RenamedInputSource; 19 | import com.reandroid.archive.io.ArchiveFileEntrySource; 20 | 21 | public class RenamedArchiveSource extends ArchiveOutputSource{ 22 | public RenamedArchiveSource(RenamedInputSource inputSource) { 23 | super(inputSource); 24 | } 25 | @Override 26 | ArchiveFileEntrySource getArchiveSource(){ 27 | RenamedInputSource renamedInputSource = (RenamedInputSource) getInputSource(); 28 | return renamedInputSource.getParentInputSource(ArchiveFileEntrySource.class); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/data/FieldDefArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.data; 17 | 18 | import com.reandroid.arsc.base.Creator; 19 | import com.reandroid.arsc.item.IntegerReference; 20 | 21 | public class FieldDefArray extends DefArray { 22 | 23 | public FieldDefArray(IntegerReference itemCount){ 24 | super(itemCount, CREATOR); 25 | } 26 | 27 | @Override 28 | void sortAnnotations() { 29 | AnnotationsDirectory directory = getAnnotationsDirectory(); 30 | if (directory != null) { 31 | directory.sortFields(); 32 | } 33 | } 34 | 35 | private static final Creator CREATOR = FieldDef::new; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/data/MethodDefArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.data; 17 | 18 | import com.reandroid.arsc.base.Creator; 19 | import com.reandroid.arsc.item.IntegerReference; 20 | 21 | public class MethodDefArray extends DefArray { 22 | public MethodDefArray(IntegerReference itemCount){ 23 | super(itemCount, CREATOR); 24 | } 25 | 26 | @Override 27 | void sortAnnotations(){ 28 | AnnotationsDirectory directory = getAnnotationsDirectory(); 29 | if(directory != null){ 30 | directory.sortMethods(); 31 | } 32 | } 33 | 34 | private static final Creator CREATOR = MethodDef::new; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/debug/DebugAdvanceLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.debug; 17 | 18 | import com.reandroid.dex.base.Sle128Item; 19 | 20 | public class DebugAdvanceLine extends DebugAdvance{ 21 | 22 | public DebugAdvanceLine() { 23 | super(DebugElementType.ADVANCE_LINE, new Sle128Item()); 24 | } 25 | 26 | @Override 27 | public int getLineDiff() { 28 | return getAdvance(); 29 | } 30 | public void setLineDiff(int lineDiff) { 31 | setAdvance(lineDiff); 32 | } 33 | 34 | @Override 35 | public DebugElementType getElementType() { 36 | return DebugElementType.ADVANCE_LINE; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/InsConst16High.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class InsConst16High extends Ins21ih implements RegistersSet, ConstNumber { 19 | 20 | public InsConst16High() { 21 | super(Opcode.CONST_HIGH16); 22 | } 23 | 24 | @Override 25 | public int get() { 26 | return getData(); 27 | } 28 | @Override 29 | public void set(int value) { 30 | setData(value); 31 | } 32 | 33 | @Override 34 | public int getRegister() { 35 | return getRegister(0); 36 | } 37 | @Override 38 | public void setRegister(int register) { 39 | setRegister(0, register); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/value/ProtoValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.value; 17 | 18 | import com.reandroid.dex.id.ProtoId; 19 | import com.reandroid.dex.key.Key; 20 | import com.reandroid.dex.key.ProtoKey; 21 | import com.reandroid.dex.sections.SectionType; 22 | 23 | public class ProtoValue extends SectionIdValue { 24 | 25 | public ProtoValue() { 26 | super(SectionType.PROTO_ID, DexValueType.PROTO); 27 | } 28 | 29 | @Override 30 | public ProtoKey getKey() { 31 | return (ProtoKey) super.getKey(); 32 | } 33 | 34 | @Override 35 | public DexValueType getValueType() { 36 | return DexValueType.PROTO; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/base/DexBlockAlign.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.base; 17 | 18 | import com.reandroid.arsc.base.Block; 19 | import com.reandroid.arsc.io.BlockReader; 20 | import com.reandroid.arsc.item.AlignItem; 21 | 22 | import java.io.IOException; 23 | 24 | public class DexBlockAlign extends AlignItem { 25 | private final Block block; 26 | public DexBlockAlign(Block block){ 27 | this.block = block; 28 | } 29 | public void align(){ 30 | super.align(block); 31 | } 32 | @Override 33 | public void onReadBytes(BlockReader reader) throws IOException { 34 | super.align(block); 35 | super.onReadBytes(reader); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/reference/DexReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.reference; 17 | 18 | import com.reandroid.arsc.base.BlockRefresh; 19 | import com.reandroid.arsc.item.IntegerReference; 20 | import com.reandroid.dex.common.EditableItem; 21 | import com.reandroid.dex.common.SectionItem; 22 | import com.reandroid.dex.key.KeyReference; 23 | import com.reandroid.dex.sections.SectionType; 24 | 25 | public interface DexReference extends 26 | IntegerReference, KeyReference, BlockRefresh, EditableItem { 27 | 28 | T getItem(); 29 | 30 | void setItem(T item); 31 | 32 | SectionType getSectionType(); 33 | 34 | void pullItem(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/value/FieldIdValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.value; 17 | 18 | import com.reandroid.dex.id.FieldId; 19 | import com.reandroid.dex.key.FieldKey; 20 | import com.reandroid.dex.key.Key; 21 | import com.reandroid.dex.sections.SectionType; 22 | 23 | public class FieldIdValue extends SectionIdValue { 24 | 25 | public FieldIdValue() { 26 | super(SectionType.FIELD_ID, DexValueType.FIELD); 27 | } 28 | 29 | @Override 30 | public FieldKey getKey() { 31 | return (FieldKey) super.getKey(); 32 | } 33 | 34 | @Override 35 | public DexValueType getValueType() { 36 | return DexValueType.FIELD; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/CertificateBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block; 17 | 18 | import com.reandroid.json.JSONObject; 19 | 20 | import java.security.cert.X509Certificate; 21 | 22 | public interface CertificateBlock { 23 | 24 | byte[] getCertificateBytes(); 25 | void setCertificate(byte[] bytes); 26 | 27 | default X509Certificate getCertificate(){ 28 | return CertificateUtil.generateCertificate(getCertificateBytes()); 29 | } 30 | 31 | default String printCertificate(){ 32 | return CertificateUtil.printCertificate(this); 33 | } 34 | default JSONObject toJson(){ 35 | return CertificateUtil.toJson(this); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/InsConstWideHigh16.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class InsConstWideHigh16 extends Ins21lh implements ConstNumberLong{ 19 | 20 | public InsConstWideHigh16(){ 21 | super(Opcode.CONST_WIDE_HIGH16); 22 | } 23 | 24 | @Override 25 | public void set(long value) { 26 | setLong(value); 27 | } 28 | @Override 29 | public long getLong() { 30 | return getDataAsLong(); 31 | } 32 | 33 | @Override 34 | public int getRegister() { 35 | return getRegister(0); 36 | } 37 | @Override 38 | public void setRegister(int register) { 39 | setRegister(0, register); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/value/MethodIdValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.value; 17 | 18 | import com.reandroid.dex.id.MethodId; 19 | import com.reandroid.dex.key.Key; 20 | import com.reandroid.dex.key.MethodKey; 21 | import com.reandroid.dex.sections.SectionType; 22 | 23 | 24 | public class MethodIdValue extends SectionIdValue { 25 | 26 | public MethodIdValue() { 27 | super(SectionType.METHOD_ID, DexValueType.METHOD); 28 | } 29 | 30 | @Override 31 | public MethodKey getKey() { 32 | return (MethodKey) super.getKey(); 33 | } 34 | 35 | @Override 36 | public DexValueType getValueType() { 37 | return DexValueType.METHOD; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/SmaliReaderSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali; 17 | 18 | public class SmaliReaderSetting { 19 | 20 | private boolean fixGoto = true; 21 | private boolean validateRegisters = true; 22 | 23 | public SmaliReaderSetting() { 24 | 25 | } 26 | 27 | public boolean isFixGoto() { 28 | return fixGoto; 29 | } 30 | public void setFixGoto(boolean fixGoto) { 31 | this.fixGoto = fixGoto; 32 | } 33 | 34 | public boolean isValidateRegisters() { 35 | return validateRegisters; 36 | } 37 | public void setValidateRegisters(boolean validateRegisters) { 38 | this.validateRegisters = validateRegisters; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/value/MethodHandleValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.value; 17 | 18 | import com.reandroid.dex.id.MethodHandleId; 19 | import com.reandroid.dex.key.MethodHandleKey; 20 | import com.reandroid.dex.sections.SectionType; 21 | 22 | public class MethodHandleValue extends SectionIdValue { 23 | 24 | public MethodHandleValue() { 25 | super(SectionType.METHOD_HANDLE, DexValueType.METHOD_HANDLE); 26 | } 27 | 28 | @Override 29 | public MethodHandleKey getKey() { 30 | return (MethodHandleKey) super.getKey(); 31 | } 32 | @Override 33 | public DexValueType getValueType() { 34 | return DexValueType.METHOD_HANDLE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/sections/SpecialItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.sections; 17 | 18 | import com.reandroid.arsc.base.OffsetSupplier; 19 | import com.reandroid.dex.base.OffsetReceiver; 20 | import com.reandroid.dex.base.PositionedItem; 21 | import com.reandroid.dex.base.UsageMarker; 22 | import com.reandroid.dex.common.SectionItemContainer; 23 | 24 | public class SpecialItem extends SectionItemContainer 25 | implements PositionedItem, OffsetSupplier, OffsetReceiver { 26 | 27 | public SpecialItem(int childesCount) { 28 | super(childesCount); 29 | } 30 | 31 | @Override 32 | public boolean containsUsage(int usage) { 33 | return usage != UsageMarker.USAGE_NONE; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliPackedSwitchEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.smali.SmaliReader; 19 | import com.reandroid.dex.smali.SmaliWriter; 20 | import java.io.IOException; 21 | 22 | public class SmaliPackedSwitchEntry extends SmaliSwitchEntry { 23 | 24 | public SmaliPackedSwitchEntry() { 25 | super(); 26 | } 27 | 28 | @Override 29 | public void append(SmaliWriter writer) throws IOException { 30 | getLabel().append(writer); 31 | } 32 | @Override 33 | public void parse(SmaliReader reader) throws IOException { 34 | reader.skipWhitespacesOrComment(); 35 | getLabel().parse(reader); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/dexopt/LinkableProfileItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.dexopt; 17 | 18 | import com.reandroid.dex.model.DexFile; 19 | 20 | import java.util.Iterator; 21 | 22 | public interface LinkableProfileItem { 23 | void link(DexFile dexFile); 24 | void update(DexFile dexFile); 25 | 26 | static void linkAll(DexFile dexFile, Iterator iterator) { 27 | while (iterator.hasNext()) { 28 | iterator.next().link(dexFile); 29 | } 30 | } 31 | static void updateAll(DexFile dexFile, Iterator iterator) { 32 | while (iterator.hasNext()) { 33 | iterator.next().update(dexFile); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/program/FieldProgram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.program; 17 | 18 | import com.reandroid.dex.common.AccessFlag; 19 | import com.reandroid.dex.key.FieldKey; 20 | import com.reandroid.dex.key.Key; 21 | 22 | import java.lang.annotation.ElementType; 23 | 24 | public interface FieldProgram extends MemberProgram { 25 | 26 | @Override 27 | FieldKey getKey(); 28 | Key getStaticValue(); 29 | 30 | default boolean isEnum() { 31 | return AccessFlag.ENUM.isSet(getAccessFlagsValue()); 32 | } 33 | @Override 34 | default ElementType getElementType() { 35 | return ElementType.FIELD; 36 | } 37 | default boolean isInstance() { 38 | return !isStatic(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/value/TypeValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.value; 17 | 18 | import com.reandroid.dex.id.TypeId; 19 | import com.reandroid.dex.key.TypeKey; 20 | import com.reandroid.dex.sections.SectionType; 21 | 22 | public class TypeValue extends SectionIdValue { 23 | 24 | public TypeValue() { 25 | super(SectionType.TYPE_ID, DexValueType.TYPE); 26 | } 27 | 28 | @Override 29 | public TypeKey getKey() { 30 | return (TypeKey) super.getKey(); 31 | } 32 | 33 | @Override 34 | public DexValueType getValueType() { 35 | return DexValueType.TYPE; 36 | } 37 | @Override 38 | public TypeKey getDataTypeKey() { 39 | return TypeKey.CLASS; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/smali/model/SmaliValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.smali.model; 17 | 18 | import com.reandroid.dex.key.Key; 19 | import com.reandroid.dex.key.KeyReference; 20 | import com.reandroid.dex.smali.SmaliReader; 21 | import com.reandroid.dex.value.DexValueType; 22 | 23 | import java.io.IOException; 24 | 25 | public abstract class SmaliValue extends Smali implements KeyReference { 26 | 27 | public SmaliValue(){ 28 | super(); 29 | } 30 | 31 | public abstract DexValueType getValueType(); 32 | @Override 33 | public abstract Key getKey(); 34 | @Override 35 | public abstract void setKey(Key key); 36 | @Override 37 | public abstract void parse(SmaliReader reader) throws IOException; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/Checksum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils; 17 | 18 | public abstract class Checksum { 19 | 20 | private byte[] oneByte; 21 | 22 | public Checksum() { 23 | } 24 | 25 | public void update(byte data) { 26 | byte[] oneByte = this.oneByte; 27 | if (oneByte == null) { 28 | oneByte = new byte[1]; 29 | this.oneByte = oneByte; 30 | } 31 | oneByte[0] = data; 32 | this.update(oneByte, 0, 1); 33 | } 34 | public void update(byte[] data) { 35 | update(data, 0, data.length); 36 | } 37 | 38 | public abstract long getValue(); 39 | public abstract void reset(); 40 | public abstract void update(byte[] data, int offset, int length); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/graph/BaseApkModuleProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.graph; 17 | 18 | import com.reandroid.apk.ApkModule; 19 | import com.reandroid.archive.ZipEntryMap; 20 | import com.reandroid.dex.model.DexClassRepository; 21 | 22 | public abstract class BaseApkModuleProcessor extends BaseDexClassProcessor { 23 | 24 | private final ApkModule apkModule; 25 | 26 | public BaseApkModuleProcessor(ApkModule apkModule, DexClassRepository classRepository) { 27 | super(classRepository); 28 | this.apkModule = apkModule; 29 | } 30 | 31 | public ZipEntryMap getZipEntryMap() { 32 | return getApkModule().getZipEntryMap(); 33 | } 34 | public ApkModule getApkModule() { 35 | return apkModule; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/writer/EntryBuffer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.writer; 17 | 18 | import com.reandroid.archive.io.ZipFileInput; 19 | 20 | public class EntryBuffer { 21 | private final ZipFileInput zipFileInput; 22 | private final long offset; 23 | private final long length; 24 | public EntryBuffer(ZipFileInput zipFileInput, long offset, long length){ 25 | this.zipFileInput = zipFileInput; 26 | this.offset = offset; 27 | this.length = length; 28 | } 29 | 30 | public ZipFileInput getZipFileInput() { 31 | return zipFileInput; 32 | } 33 | public long getOffset() { 34 | return offset; 35 | } 36 | public long getLength() { 37 | return length; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/utils/collection/SingleIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.utils.collection; 17 | 18 | import java.util.Iterator; 19 | 20 | public class SingleIterator implements Iterator { 21 | private T mItem; 22 | public SingleIterator(T item){ 23 | this.mItem = item; 24 | } 25 | @Override 26 | public boolean hasNext() { 27 | return this.mItem != null; 28 | } 29 | @Override 30 | public T next() { 31 | T item = this.mItem; 32 | this.mItem = null; 33 | return item; 34 | } 35 | 36 | public static Iterator of(T1 item){ 37 | if(item == null){ 38 | return EmptyIterator.of(); 39 | } 40 | return new SingleIterator<>(item); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins22x.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.dex.smali.SmaliWriter; 19 | 20 | public class Ins22x extends Ins22 { 21 | 22 | public Ins22x(Opcode opcode) { 23 | super(opcode); 24 | } 25 | 26 | @Override 27 | public int getRegister(int index) { 28 | if(index == 0) { 29 | return getByteUnsigned(1); 30 | } 31 | return getShortUnsigned(2); 32 | } 33 | @Override 34 | public void setRegister(int index, int value) { 35 | if(index == 0){ 36 | setByte(1, value); 37 | }else { 38 | setShort(2, value); 39 | } 40 | } 41 | 42 | @Override 43 | void appendOperand(SmaliWriter writer) { 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/InsSparseSwitch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class InsSparseSwitch extends InsSwitch { 19 | 20 | public InsSparseSwitch() { 21 | super(Opcode.SPARSE_SWITCH); 22 | } 23 | 24 | @Override 25 | public InsSparseSwitchData getPayload() { 26 | return (InsSparseSwitchData) super.getPayload(); 27 | } 28 | @Override 29 | public Opcode getPayloadOpcode() { 30 | return Opcode.SPARSE_SWITCH_PAYLOAD; 31 | } 32 | 33 | @Override 34 | public void setTargetAddress(int targetAddress){ 35 | setData(targetAddress - getAddress()); 36 | } 37 | @Override 38 | String getLabelPrefix(){ 39 | return ":sswitch_data_"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/StyleText.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml; 17 | 18 | import java.io.IOException; 19 | 20 | public class StyleText extends XMLText { 21 | 22 | public StyleText(){ 23 | super(""); 24 | } 25 | 26 | void writeStyledText(Appendable appendable) throws IOException { 27 | appendable.append(getText(false)); 28 | } 29 | @Override 30 | public int getLength(){ 31 | return getTextLength(); 32 | } 33 | @Override 34 | public int getTextLength(){ 35 | String text = getText(); 36 | if(text != null){ 37 | return text.length(); 38 | } 39 | return 0; 40 | } 41 | 42 | @Override 43 | public boolean isIndent(){ 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/xml/base/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.xml.base; 17 | 18 | import java.io.IOException; 19 | 20 | public interface Node extends XmlSerializable, XmlReader { 21 | 22 | Node getParentNode(); 23 | 24 | int getLineNumber(); 25 | void setLineNumber(int lineNumber); 26 | default int getColumnNumber() { 27 | return 0; 28 | } 29 | default void setColumnNumber(int columnNumber) { 30 | 31 | } 32 | 33 | default String toXmlString() { 34 | return toXmlString(true); 35 | } 36 | default String toXmlString(boolean indent){ 37 | try { 38 | return XmlSerializable.toXmlString(this, indent); 39 | } catch (IOException ignored) { 40 | return null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/block/BottomBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.block; 17 | 18 | import com.reandroid.arsc.container.BlockList; 19 | import com.reandroid.arsc.io.BlockReader; 20 | 21 | import java.io.IOException; 22 | 23 | // General purpose block to consume the remaining bytes of BlockReader 24 | public class BottomBlock extends BlockList { 25 | public BottomBlock(){ 26 | super(); 27 | } 28 | @Override 29 | public void onReadBytes(BlockReader reader) throws IOException { 30 | while (reader.isAvailable()){ 31 | LengthPrefixedBytes prefixedBytes = new LengthPrefixedBytes(false); 32 | prefixedBytes.readBytes(reader); 33 | this.add(prefixedBytes); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/dexopt/ProfileMetadataV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.dexopt; 17 | 18 | import com.reandroid.arsc.item.StringReference; 19 | 20 | public class ProfileMetadataV1 extends ProfileMetadata { 21 | 22 | private final ProfileMetadataHeaderV1 header; 23 | private final ProfileClassList classList; 24 | 25 | public ProfileMetadataV1(ProfileMetadataHeaderV1 header) { 26 | super(1); 27 | this.header = header; 28 | this.classList = new ProfileClassList(header.classSetSize); 29 | 30 | addChild(0, classList); 31 | } 32 | 33 | @Override 34 | public StringReference name() { 35 | return header.name; 36 | } 37 | @Override 38 | public ProfileClassList classList() { 39 | return classList; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins10x.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.dex.smali.SmaliWriter; 19 | import com.reandroid.dex.smali.model.SmaliInstruction; 20 | 21 | import java.io.IOException; 22 | 23 | public class Ins10x extends Size2Ins { 24 | public Ins10x(Opcode opcode) { 25 | super(opcode); 26 | } 27 | @Override 28 | public int getData(){ 29 | return 0; 30 | } 31 | @Override 32 | public void setData(int data){ 33 | } 34 | @Override 35 | public void appendCode(SmaliWriter writer) throws IOException { 36 | writer.append(getOpcode().getName()); 37 | } 38 | @Override 39 | public void fromSmali(SmaliInstruction smaliInstruction) { 40 | validateOpcode(smaliInstruction); 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins23x.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | import com.reandroid.dex.smali.SmaliWriter; 19 | 20 | public class Ins23x extends Size4Ins implements RegistersSet { 21 | 22 | public Ins23x(Opcode opcode) { 23 | super(opcode); 24 | } 25 | 26 | @Override 27 | public int getRegistersCount() { 28 | return 3; 29 | } 30 | @Override 31 | public void setRegistersCount(int count) { 32 | } 33 | @Override 34 | public int getRegister(int index) { 35 | return getByteUnsigned(1 + index); 36 | } 37 | @Override 38 | public void setRegister(int index, int value) { 39 | setByte(1 + index, value); 40 | } 41 | 42 | @Override 43 | void appendOperand(SmaliWriter writer) { 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/apk/DexDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.apk; 17 | 18 | import com.reandroid.utils.ObjectsUtil; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | public interface DexDecoder { 25 | void decodeDex(DexFileInputSource dexFileInputSource, File mainDirectory) throws IOException; 26 | default void decodeDex(ApkModule apkModule, File mainDirectory) throws IOException { 27 | List dexList = apkModule.listDexFiles(); 28 | for(DexFileInputSource inputSource : dexList) { 29 | decodeDex(inputSource, mainDirectory); 30 | } 31 | } 32 | String DEX_DIRECTORY_NAME = DexFileInputSource.DEX_DIRECTORY_NAME; 33 | String SMALI_DIRECTORY_NAME = ObjectsUtil.of("smali"); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/reandroid/dex/ins/Ins22b.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.dex.ins; 17 | 18 | public class Ins22b extends Ins22 implements RegistersSet { 19 | 20 | public Ins22b(Opcode opcode) { 21 | super(opcode); 22 | } 23 | 24 | @Override 25 | public int getRegister(int index) { 26 | return getByteUnsigned(1 + index); 27 | } 28 | @Override 29 | public void setRegister(int index, int value) { 30 | setByte(1 + index, value); 31 | } 32 | 33 | @Override 34 | public int getData(){ 35 | return getByteUnsigned(3); 36 | } 37 | 38 | @Override 39 | public int getSignedData() { 40 | return toSigned(getData(), 0xff); 41 | } 42 | 43 | @Override 44 | public void setData(int data){ 45 | setByte(3, data); 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/com/reandroid/archive/writer/ByteOutputSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 github.com/REAndroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.reandroid.archive.writer; 17 | 18 | import com.reandroid.archive.InputSource; 19 | import com.reandroid.archive.io.ZipByteOutput; 20 | 21 | import java.io.IOException; 22 | 23 | class ByteOutputSource extends OutputSource{ 24 | ByteOutputSource(InputSource inputSource) { 25 | super(inputSource); 26 | } 27 | void writeApk(ZipByteOutput zipOutput, ZipAligner zipAligner) throws IOException { 28 | ZipByteOutput buffer = new ZipByteOutput(); 29 | writeBuffer(buffer); 30 | buffer.close(); 31 | writeLFH(zipOutput, zipAligner); 32 | getLocalFileHeader().setFileOffset(zipOutput.position()); 33 | zipOutput.write(buffer.toByteArray()); 34 | writeDD(zipOutput); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/reandroid/arsc/chunk/PackageBlockTest.java: -------------------------------------------------------------------------------- 1 | package com.reandroid.arsc.chunk; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class PackageBlockTest { 7 | 8 | @Test 9 | public void testIsResourceId() { 10 | Assert.assertFalse(PackageBlock.isResourceId(0x7f00ffff)); 11 | Assert.assertFalse(PackageBlock.isResourceId(0x00ff0000)); 12 | Assert.assertFalse(PackageBlock.isResourceId(0x00ffffff)); 13 | Assert.assertFalse(PackageBlock.isResourceId(0x0000ffff)); 14 | Assert.assertFalse(PackageBlock.isResourceId(0xff000000)); 15 | Assert.assertFalse(PackageBlock.isResourceId(0x0)); 16 | Assert.assertTrue(PackageBlock.isResourceId(0x0101ffff)); 17 | Assert.assertTrue(PackageBlock.isResourceId(0x01010000)); 18 | } 19 | 20 | @Test 21 | public void testIsPackageId() { 22 | Assert.assertFalse(PackageBlock.isPackageId(0x00)); 23 | Assert.assertFalse(PackageBlock.isPackageId(0xfff)); 24 | Assert.assertFalse(PackageBlock.isPackageId(0xffff)); 25 | Assert.assertFalse(PackageBlock.isPackageId(0xfffff)); 26 | Assert.assertFalse(PackageBlock.isPackageId(0xffffff)); 27 | Assert.assertFalse(PackageBlock.isPackageId(0xffffffff)); 28 | Assert.assertTrue(PackageBlock.isPackageId(0x01)); 29 | Assert.assertTrue(PackageBlock.isPackageId(0x11)); 30 | Assert.assertTrue(PackageBlock.isPackageId(0xff)); 31 | } 32 | 33 | } 34 | --------------------------------------------------------------------------------