├── .github
└── ISSUE_TEMPLATE.md
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── assets
└── tinker.png
├── build.gradle
├── checkstyle.xml
├── findbugs-exclude.xml
├── gradle.properties
├── gradle
├── PublishArtifact.gradle
├── WeChatPublish.gradle
├── check.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pmd-ruleset.xml
├── settings.gradle
├── suppressions.xml
├── third-party
├── aosp-dexutils
│ ├── .gitignore
│ ├── NOTICE
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── android
│ │ ├── dex
│ │ ├── Annotation.java
│ │ ├── AnnotationSet.java
│ │ ├── AnnotationSetRefList.java
│ │ ├── AnnotationsDirectory.java
│ │ ├── CallSiteId.java
│ │ ├── ClassData.java
│ │ ├── ClassDef.java
│ │ ├── Code.java
│ │ ├── DebugInfoItem.java
│ │ ├── Dex.java
│ │ ├── DexException.java
│ │ ├── DexFormat.java
│ │ ├── EncodedValue.java
│ │ ├── EncodedValueCodec.java
│ │ ├── EncodedValueReader.java
│ │ ├── FieldId.java
│ │ ├── Leb128.java
│ │ ├── MethodHandle.java
│ │ ├── MethodId.java
│ │ ├── Mutf8.java
│ │ ├── ProtoId.java
│ │ ├── SizeOf.java
│ │ ├── StringData.java
│ │ ├── TableOfContents.java
│ │ ├── TypeList.java
│ │ ├── io
│ │ │ └── DexDataBuffer.java
│ │ └── util
│ │ │ ├── ByteInput.java
│ │ │ ├── ByteOutput.java
│ │ │ ├── CompareUtils.java
│ │ │ ├── FileUtils.java
│ │ │ └── HashCodeHelper.java
│ │ ├── dx
│ │ ├── instruction
│ │ │ ├── CodeCursor.java
│ │ │ ├── InstructionCodec.java
│ │ │ ├── InstructionComparator.java
│ │ │ ├── InstructionPromoter.java
│ │ │ ├── InstructionReader.java
│ │ │ ├── InstructionVisitor.java
│ │ │ ├── InstructionWriter.java
│ │ │ ├── Opcodes.java
│ │ │ ├── ShortArrayCodeInput.java
│ │ │ └── ShortArrayCodeOutput.java
│ │ └── util
│ │ │ └── Hex.java
│ │ └── utils
│ │ ├── SparseBoolArray.java
│ │ └── SparseIntArray.java
├── bsdiff-util
│ ├── .gitignore
│ ├── LICENSE.txt
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── bsdiff
│ │ ├── BSDiff.java
│ │ ├── BSPatch.java
│ │ └── BSUtil.java
└── tinker-ziputils
│ ├── .gitignore
│ ├── NOTICE.txt
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ └── main
│ └── java
│ └── com
│ └── tencent
│ └── tinker
│ └── ziputils
│ └── ziputil
│ ├── AlignedZipOutputStream.java
│ ├── Arrays.java
│ ├── BufferIterator.java
│ ├── HeapBufferIterator.java
│ ├── Memory.java
│ ├── SizeOf.java
│ ├── StandardCharsets.java
│ ├── Streams.java
│ ├── TinkerZipEntry.java
│ ├── TinkerZipFile.java
│ ├── TinkerZipOutputStream.java
│ ├── TinkerZipUtil.java
│ └── ZipConstants.java
├── tinker-android
├── consumer-proguard.txt
├── tinker-android-anno-support
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── anno
│ │ ├── AnnotationProcessor.java
│ │ ├── DefaultLifeCycle.java
│ │ └── Keep.java
├── tinker-android-anno
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ │ ├── main
│ │ └── resources
│ │ │ ├── META-INF
│ │ │ └── services
│ │ │ │ └── javax.annotation.processing.Processor
│ │ │ └── TinkerAnnoApplication.tmpl
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── anno
│ │ └── test
│ │ └── TestLifeCycle.java
├── tinker-android-lib-no-op
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── lib
│ │ │ └── patch
│ │ │ └── ApplicationTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── lib
│ │ │ ├── library
│ │ │ └── TinkerLoadLibrary.java
│ │ │ ├── listener
│ │ │ ├── DefaultPatchListener.java
│ │ │ └── PatchListener.java
│ │ │ ├── patch
│ │ │ ├── AbstractPatch.java
│ │ │ └── UpgradePatch.java
│ │ │ ├── reporter
│ │ │ ├── DefaultLoadReporter.java
│ │ │ ├── DefaultPatchReporter.java
│ │ │ ├── LoadReporter.java
│ │ │ └── PatchReporter.java
│ │ │ ├── service
│ │ │ ├── AbstractResultService.java
│ │ │ ├── DefaultTinkerResultService.java
│ │ │ └── PatchResult.java
│ │ │ ├── tinker
│ │ │ ├── Tinker.java
│ │ │ ├── TinkerApplicationHelper.java
│ │ │ ├── TinkerInstaller.java
│ │ │ └── TinkerLoadResult.java
│ │ │ └── util
│ │ │ ├── TinkerLog.java
│ │ │ ├── TinkerServiceInternals.java
│ │ │ └── UpgradePatchRetry.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── recover
│ │ └── ExampleUnitTest.java
├── tinker-android-lib
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── lib
│ │ │ └── patch
│ │ │ └── ApplicationTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── aidl
│ │ │ └── com
│ │ │ │ └── tencent
│ │ │ │ └── tinker
│ │ │ │ └── lib
│ │ │ │ └── IForeService.aidl
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ ├── entry
│ │ │ ├── ApplicationLifeCycle.java
│ │ │ ├── ApplicationLike.java
│ │ │ ├── DefaultApplicationLike.java
│ │ │ └── TinkerApplicationInlineFence.java
│ │ │ └── lib
│ │ │ ├── filepatch
│ │ │ ├── AbstractFilePatch.java
│ │ │ ├── BsFilePatch.java
│ │ │ └── FilePatchFactory.java
│ │ │ ├── library
│ │ │ └── TinkerLoadLibrary.java
│ │ │ ├── listener
│ │ │ ├── DefaultPatchListener.java
│ │ │ └── PatchListener.java
│ │ │ ├── patch
│ │ │ ├── AbstractPatch.java
│ │ │ ├── ArkHotDiffPatchInternal.java
│ │ │ ├── BasePatchInternal.java
│ │ │ ├── DexDiffPatchInternal.java
│ │ │ ├── ResDiffPatchInternal.java
│ │ │ ├── SoDiffPatchInternal.java
│ │ │ └── UpgradePatch.java
│ │ │ ├── reporter
│ │ │ ├── DefaultLoadReporter.java
│ │ │ ├── DefaultPatchReporter.java
│ │ │ ├── LoadReporter.java
│ │ │ └── PatchReporter.java
│ │ │ ├── service
│ │ │ ├── AbstractResultService.java
│ │ │ ├── DefaultTinkerResultService.java
│ │ │ ├── PatchResult.java
│ │ │ ├── TinkerPatchForeService.java
│ │ │ └── TinkerPatchService.java
│ │ │ ├── tinker
│ │ │ ├── Tinker.java
│ │ │ ├── TinkerApplicationHelper.java
│ │ │ ├── TinkerInstaller.java
│ │ │ └── TinkerLoadResult.java
│ │ │ └── util
│ │ │ ├── TinkerLog.java
│ │ │ ├── TinkerServiceInternals.java
│ │ │ └── UpgradePatchRetry.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── recover
│ │ └── ExampleUnitTest.java
├── tinker-android-loader-no-op
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── loader
│ │ │ └── ApplicationTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ ├── entry
│ │ │ ├── ApplicationLifeCycle.java
│ │ │ ├── ApplicationLike.java
│ │ │ └── DefaultApplicationLike.java
│ │ │ └── loader
│ │ │ ├── TinkerRuntimeException.java
│ │ │ ├── app
│ │ │ └── TinkerApplication.java
│ │ │ └── shareutil
│ │ │ ├── ShareArkHotDiffPatchInfo.java
│ │ │ ├── ShareBsDiffPatchInfo.java
│ │ │ ├── ShareConstants.java
│ │ │ ├── ShareDexDiffPatchInfo.java
│ │ │ ├── ShareElfFile.java
│ │ │ ├── ShareFileLockHelper.java
│ │ │ ├── ShareIntentUtil.java
│ │ │ ├── ShareOatUtil.java
│ │ │ ├── SharePatchFileUtil.java
│ │ │ ├── SharePatchInfo.java
│ │ │ ├── ShareReflectUtil.java
│ │ │ ├── ShareResPatchInfo.java
│ │ │ ├── ShareSecurityCheck.java
│ │ │ ├── ShareTinkerInternals.java
│ │ │ ├── ShareTinkerLog.java
│ │ │ └── TinkerLogInlineFence.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── loader
│ │ └── ExampleUnitTest.java
└── tinker-android-loader
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ ├── src
│ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── loader
│ │ │ └── ApplicationTest.java
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── loader
│ │ │ ├── AbstractTinkerLoader.java
│ │ │ ├── AppInfoChangedBlocker.java
│ │ │ ├── NewClassLoaderInjector.java
│ │ │ ├── SystemClassLoaderAdder.java
│ │ │ ├── TinkerArkHotLoader.java
│ │ │ ├── TinkerClassLoader.java
│ │ │ ├── TinkerDexLoader.java
│ │ │ ├── TinkerDexOptimizer.java
│ │ │ ├── TinkerLoader.java
│ │ │ ├── TinkerResourceLoader.java
│ │ │ ├── TinkerResourcePatcher.java
│ │ │ ├── TinkerResourcesKey.java
│ │ │ ├── TinkerRuntimeException.java
│ │ │ ├── TinkerSoLoader.java
│ │ │ ├── TinkerTestDexLoad.java
│ │ │ ├── TinkerUncaughtHandler.java
│ │ │ ├── app
│ │ │ ├── TinkerApplication.java
│ │ │ └── TinkerInlineFenceAction.java
│ │ │ ├── hotplug
│ │ │ ├── ActivityStubManager.java
│ │ │ ├── ActivityStubs.java
│ │ │ ├── ComponentHotplug.java
│ │ │ ├── EnvConsts.java
│ │ │ ├── IncrementComponentManager.java
│ │ │ ├── UnsupportedEnvironmentException.java
│ │ │ ├── handler
│ │ │ │ ├── AMSInterceptHandler.java
│ │ │ │ ├── MHMessageHandler.java
│ │ │ │ └── PMSInterceptHandler.java
│ │ │ └── interceptor
│ │ │ │ ├── HandlerMessageInterceptor.java
│ │ │ │ ├── InterceptFailedException.java
│ │ │ │ ├── Interceptor.java
│ │ │ │ ├── ServiceBinderInterceptor.java
│ │ │ │ └── TinkerHackInstrumentation.java
│ │ │ └── shareutil
│ │ │ ├── ShareArkHotDiffPatchInfo.java
│ │ │ ├── ShareBsDiffPatchInfo.java
│ │ │ ├── ShareConstants.java
│ │ │ ├── ShareDexDiffPatchInfo.java
│ │ │ ├── ShareElfFile.java
│ │ │ ├── ShareFileLockHelper.java
│ │ │ ├── ShareIntentUtil.java
│ │ │ ├── ShareOatUtil.java
│ │ │ ├── SharePatchFileUtil.java
│ │ │ ├── SharePatchInfo.java
│ │ │ ├── ShareReflectUtil.java
│ │ │ ├── ShareResPatchInfo.java
│ │ │ ├── ShareSecurityCheck.java
│ │ │ ├── ShareTinkerInternals.java
│ │ │ ├── ShareTinkerLog.java
│ │ │ └── TinkerLogInlineFence.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── tencent
│ │ └── tinker
│ │ └── loader
│ │ └── ExampleUnitTest.java
│ └── stubs
│ └── sysapi-access-stub.jar
├── tinker-build
├── tinker-patch-cli
│ ├── .gitignore
│ ├── build.gradle
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── patch
│ │ │ ├── CliMain.java
│ │ │ └── Test.java
│ ├── tool_maple
│ │ ├── DexCmp.jar
│ │ └── build_patch_dexdiff.sh
│ └── tool_output
│ │ ├── merge_mapping.py
│ │ ├── proguard_warning.py
│ │ ├── release.keystore
│ │ ├── tinker_config.xml
│ │ ├── tinker_multidexkeep.pro
│ │ └── tinker_proguard.pro
├── tinker-patch-gradle-plugin
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ │ └── main
│ │ ├── groovy
│ │ └── com
│ │ │ └── tencent
│ │ │ └── tinker
│ │ │ └── build
│ │ │ └── gradle
│ │ │ ├── Compatibilities.groovy
│ │ │ ├── TinkerPatchPlugin.groovy
│ │ │ ├── common
│ │ │ └── TinkerBuildPath.groovy
│ │ │ ├── extension
│ │ │ ├── TinkerArkHotExtension.groovy
│ │ │ ├── TinkerBuildConfigExtension.groovy
│ │ │ ├── TinkerDexExtension.groovy
│ │ │ ├── TinkerLibExtension.groovy
│ │ │ ├── TinkerPackageConfigExtension.groovy
│ │ │ ├── TinkerPatchExtension.groovy
│ │ │ ├── TinkerResourceExtension.groovy
│ │ │ └── TinkerSevenZipExtension.groovy
│ │ │ ├── task
│ │ │ ├── TinkerManifestAction.groovy
│ │ │ ├── TinkerMultidexConfigTask.groovy
│ │ │ ├── TinkerPatchSchemaTask.groovy
│ │ │ ├── TinkerProguardConfigAction.groovy
│ │ │ └── TinkerResourceIdTask.groovy
│ │ │ └── transform
│ │ │ └── ImmutableDexTransform.groovy
│ │ └── resources
│ │ └── META-INF
│ │ └── gradle-plugins
│ │ └── com.tencent.tinker.patch.properties
└── tinker-patch-lib
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ └── src
│ └── main
│ ├── java
│ ├── com
│ │ └── tencent
│ │ │ └── tinker
│ │ │ └── build
│ │ │ ├── aapt
│ │ │ ├── AaptResourceCollector.java
│ │ │ ├── AaptUtil.java
│ │ │ ├── Constant.java
│ │ │ ├── FakeRDotTxtEntry.java
│ │ │ ├── FileCopyException.java
│ │ │ ├── FileUtil.java
│ │ │ ├── Generator.java
│ │ │ ├── JavaXmlUtil.java
│ │ │ ├── ObjectUtil.java
│ │ │ ├── PatchUtil.java
│ │ │ ├── RDotTxtEntry.java
│ │ │ ├── ResourceDirectory.java
│ │ │ ├── ResourceEntry.java
│ │ │ └── StringUtil.java
│ │ │ ├── apkparser
│ │ │ └── AndroidParser.java
│ │ │ ├── builder
│ │ │ └── PatchBuilder.java
│ │ │ ├── decoder
│ │ │ ├── ApkDecoder.java
│ │ │ ├── ArkHotDecoder.java
│ │ │ ├── BaseDecoder.java
│ │ │ ├── DexDiffDecoder.java
│ │ │ ├── ManifestDecoder.java
│ │ │ ├── ResDiffDecoder.java
│ │ │ ├── SoDiffDecoder.java
│ │ │ └── UniqueDexDiffDecoder.java
│ │ │ ├── dexpatcher
│ │ │ ├── DexPatchGenerator.java
│ │ │ ├── algorithms
│ │ │ │ └── diff
│ │ │ │ │ ├── AnnotationSectionDiffAlgorithm.java
│ │ │ │ │ ├── AnnotationSetRefListSectionDiffAlgorithm.java
│ │ │ │ │ ├── AnnotationSetSectionDiffAlgorithm.java
│ │ │ │ │ ├── AnnotationsDirectorySectionDiffAlgorithm.java
│ │ │ │ │ ├── CallSiteIdSectionDiffAlgorithm.java
│ │ │ │ │ ├── ClassDataSectionDiffAlgorithm.java
│ │ │ │ │ ├── ClassDefSectionDiffAlgorithm.java
│ │ │ │ │ ├── CodeSectionDiffAlgorithm.java
│ │ │ │ │ ├── DebugInfoItemSectionDiffAlgorithm.java
│ │ │ │ │ ├── DexSectionDiffAlgorithm.java
│ │ │ │ │ ├── FieldIdSectionDiffAlgorithm.java
│ │ │ │ │ ├── MethodHandleSectionDiffAlgorithm.java
│ │ │ │ │ ├── MethodIdSectionDiffAlgorithm.java
│ │ │ │ │ ├── ProtoIdSectionDiffAlgorithm.java
│ │ │ │ │ ├── StaticValueSectionDiffAlgorithm.java
│ │ │ │ │ ├── StringDataSectionDiffAlgorithm.java
│ │ │ │ │ ├── TypeIdSectionDiffAlgorithm.java
│ │ │ │ │ └── TypeListSectionDiffAlgorithm.java
│ │ │ └── util
│ │ │ │ ├── ChangedClassesDexClassInfoCollector.java
│ │ │ │ └── PatternUtils.java
│ │ │ ├── immutable
│ │ │ ├── ClassSimDef.java
│ │ │ └── DexRefData.java
│ │ │ ├── info
│ │ │ ├── InfoWriter.java
│ │ │ ├── PatchInfo.java
│ │ │ └── PatchInfoGen.java
│ │ │ ├── patch
│ │ │ ├── Configuration.java
│ │ │ ├── InputParam.java
│ │ │ └── Runner.java
│ │ │ └── util
│ │ │ ├── CustomDiff.java
│ │ │ ├── DexClassesComparator.java
│ │ │ ├── DiffFactory.java
│ │ │ ├── ExcludedClassModifiedChecker.java
│ │ │ ├── FileOperation.java
│ │ │ ├── Logger.java
│ │ │ ├── MD5.java
│ │ │ ├── TinkerPatchException.java
│ │ │ ├── TypedValue.java
│ │ │ └── Utils.java
│ └── org
│ │ └── jf
│ │ └── dexlib2
│ │ └── builder
│ │ └── BuilderMutableMethodImplementation.java
│ └── resources
│ ├── only_use_to_test_tinker_resource.txt
│ └── test.dex
├── tinker-commons
├── .gitignore
├── NOTICE.txt
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ └── java
│ └── com
│ └── tencent
│ └── tinker
│ └── commons
│ ├── dexpatcher
│ ├── DexPatchApplier.java
│ ├── DexPatcherLogger.java
│ ├── algorithms
│ │ └── patch
│ │ │ ├── AnnotationSectionPatchAlgorithm.java
│ │ │ ├── AnnotationSetRefListSectionPatchAlgorithm.java
│ │ │ ├── AnnotationSetSectionPatchAlgorithm.java
│ │ │ ├── AnnotationsDirectorySectionPatchAlgorithm.java
│ │ │ ├── CallSiteIdSectionPatchAlgorithm.java
│ │ │ ├── ClassDataSectionPatchAlgorithm.java
│ │ │ ├── ClassDefSectionPatchAlgorithm.java
│ │ │ ├── CodeSectionPatchAlgorithm.java
│ │ │ ├── DebugInfoItemSectionPatchAlgorithm.java
│ │ │ ├── DexSectionPatchAlgorithm.java
│ │ │ ├── FieldIdSectionPatchAlgorithm.java
│ │ │ ├── MethodHandleSectionPatchAlgorithm.java
│ │ │ ├── MethodIdSectionPatchAlgorithm.java
│ │ │ ├── ProtoIdSectionPatchAlgorithm.java
│ │ │ ├── StaticValueSectionPatchAlgorithm.java
│ │ │ ├── StringDataSectionPatchAlgorithm.java
│ │ │ ├── TypeIdSectionPatchAlgorithm.java
│ │ │ └── TypeListSectionPatchAlgorithm.java
│ ├── struct
│ │ ├── DexPatchFile.java
│ │ └── PatchOperation.java
│ └── util
│ │ ├── AbstractIndexMap.java
│ │ ├── InstructionTransformer.java
│ │ └── SparseIndexMap.java
│ └── util
│ ├── DigestUtil.java
│ └── IOHelper.java
└── tinker-sample-android
├── .gitignore
├── app
├── .gitignore
├── build.gradle
├── keystore
│ ├── debug.keystore
│ └── release.keystore
├── proguard-rules.pro
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── tinker
│ │ │ │ └── sample
│ │ │ │ └── android
│ │ │ │ ├── Log
│ │ │ │ └── MyLogImp.java
│ │ │ │ ├── app
│ │ │ │ ├── BaseBuildInfo.java
│ │ │ │ ├── BuildInfo.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── SampleApplicationLike.java
│ │ │ │ ├── crash
│ │ │ │ └── SampleUncaughtExceptionHandler.java
│ │ │ │ ├── reporter
│ │ │ │ ├── SampleLoadReporter.java
│ │ │ │ ├── SamplePatchListener.java
│ │ │ │ ├── SamplePatchReporter.java
│ │ │ │ └── SampleTinkerReport.java
│ │ │ │ ├── service
│ │ │ │ └── SampleResultService.java
│ │ │ │ └── util
│ │ │ │ ├── SampleApplicationContext.java
│ │ │ │ ├── TinkerManager.java
│ │ │ │ └── Utils.java
│ │ └── res
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ └── test
│ │ └── java
│ │ └── tinker
│ │ └── sample
│ │ └── android
│ │ └── ExampleUnitTest.java
└── tinker_multidexkeep.pro
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── updateTinkerLib.sh
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Issue/提问须知
2 | **在提交issue之前,我们应该先查询是否已经有相关的issue以及[常见问题](https://github.com/Tencent/tinker/wiki/Tinker-%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)。提交issue时,我们需要写明issue的原因,以及编译或运行过程的日志(加载进程以及Patch进程)。issue需要以下面的格式:**
3 |
4 | ```
5 | 异常类型:app运行时异常/编译异常
6 |
7 | 手机型号:如:Nexus 5(如是编译异常,则可以不填)
8 |
9 | 手机系统版本:如:Android 5.0 (如是编译异常,则可以不填)
10 |
11 | tinker版本:如:1.7.7
12 |
13 | gradle版本:如:2.10
14 |
15 | 是否使用热更新SDK: 如 TinkerPatch SDK 或者 Bugly SDK
16 |
17 | 系统:如:Mac
18 |
19 | 堆栈/日志:
20 | 1. 如是编译异常,请在执行gradle命令时,加上--stacktrace;
21 | 2. 日志我们需要过滤"Tinker."关键字;
22 | 3. 对于合成失败的情况,请给出:patch进程的日志,这里需要将Android Moniter右上角设为No Filter。
23 | ```
24 |
25 | 提问题时若使用`不能用/没效果/有问题/报错`此类模糊表达,但又没给出任何代码截图报错的,将绝对不会有任何反馈。这种issue也是一律直接关闭的,大家可以参阅[提问的智慧](https://github.com/tvvocold/How-To-Ask-Questions-The-Smart-Way)。
26 |
27 | Tinker是一个开源项目,希望大家遇到问题时要学会先思考,看看sample与Tinker的源码,更鼓励大家给我们提pr.
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
3 | # Ignore Gradle GUI config
4 | gradle-app.setting
5 |
6 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
7 | !gradle-wrapper.jar
8 |
9 | # Cache of project
10 | .gradletasknamecache
11 |
12 | .DS_Store
13 | node_modules
14 |
15 | # Built application files
16 | *.apk
17 | *.ap_
18 |
19 | # Java class files
20 | *.class
21 |
22 | # Generated files
23 | bin/
24 | gen/
25 |
26 | # Gradle files
27 | .gradle/
28 | *.iml
29 | .idea
30 |
31 | # Local configuration file (sdk path, etc)
32 | local.properties
33 | local.gradle
34 |
35 | # Proguard folder generated by Eclipse
36 | proguard/
37 |
38 | # Log Files
39 | *.log
40 |
41 | /buildSdk
42 |
43 |
44 |
--------------------------------------------------------------------------------
/assets/tinker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/assets/tinker.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | gradlePluginPortal()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:4.2.0'
11 | classpath "com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:4.0.4"
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | mavenLocal()
18 | mavenCentral()
19 | gradlePluginPortal()
20 | google()
21 | }
22 |
23 | tasks.withType(Javadoc).all {
24 | enabled = false
25 | options.setEncoding('UTF-8')
26 | }
27 | }
28 |
29 | ext {
30 | minSdkVersion = 10
31 | compileSdkVersion = 29
32 | targetSdkVersion = 23
33 | buildToolsVersion = '28.0.3'
34 | androidXAnnotationVersion = '1.1.0'
35 | javaVersion = JavaVersion.VERSION_1_8
36 |
37 | GROUP = 'com.tencent.tinker'
38 | VERSION_NAME = '1.9.15'
39 |
40 | POM_DESCRIPTION = 'Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk.'
41 | POM_URL = 'https://github.com/Tencent/tinker'
42 | POM_SCM_URL = 'https://github.com/Tencent/tinker.git'
43 |
44 | POM_LICENCE_NAME = 'BSD License'
45 | POM_LICENCE_URL = 'https://opensource.org/licenses/BSD-3-Clause'
46 | POM_LICENCE_DIST = 'repo'
47 |
48 | POM_DEVELOPER_ID = 'Tencent Wechat'
49 | POM_DEVELOPER_NAME = 'Tencent Wechat, Inc.'
50 | }
51 |
52 | apply from: rootProject.file('gradle/check.gradle')
53 |
--------------------------------------------------------------------------------
/findbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | android.useAndroidX=true
21 |
--------------------------------------------------------------------------------
/gradle/PublishArtifact.gradle:
--------------------------------------------------------------------------------
1 | apply from: rootProject.file('gradle/WeChatPublish.gradle')
2 |
3 | def checkAndGetOption(name) {
4 | if (!project.hasProperty(name)) {
5 | throw new GradleException("Please specify '$name' option in gradle project properties.")
6 | }
7 | return project[name]
8 | }
9 |
10 | wechatPublish {
11 | pom {
12 | name = checkAndGetOption('POM_NAME')
13 | description = checkAndGetOption('POM_DESCRIPTION')
14 | url = checkAndGetOption('POM_URL')
15 |
16 | scm {
17 | url = checkAndGetOption('POM_SCM_URL')
18 | }
19 |
20 | licenses {
21 | license {
22 | name = checkAndGetOption('POM_LICENCE_NAME')
23 | url = checkAndGetOption('POM_LICENCE_URL')
24 | }
25 | }
26 |
27 | developers {
28 | developer {
29 | id = checkAndGetOption('POM_DEVELOPER_ID')
30 | name = checkAndGetOption('POM_DEVELOPER_NAME')
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/pmd-ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | This ruleset was created from PMD.rul
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':tinker-commons'
2 | include ':tinker-android:tinker-android-loader'
3 | include ':tinker-android:tinker-android-loader-no-op'
4 | include ':tinker-android:tinker-android-lib'
5 | include ':tinker-android:tinker-android-lib-no-op'
6 | include ':tinker-android:tinker-android-anno'
7 | include ':tinker-android:tinker-android-anno-support'
8 | include ':tinker-build:tinker-patch-cli'
9 | include ':tinker-build:tinker-patch-lib'
10 | include ':tinker-build:tinker-patch-gradle-plugin'
11 | include ':third-party:aosp-dexutils'
12 | include ':third-party:bsdiff-util'
13 | include ':third-party:tinker-ziputils'
14 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | sourceCompatibility = rootProject.ext.javaVersion
9 | targetCompatibility = rootProject.ext.javaVersion
10 |
11 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
12 | group = "tinker"
13 | from('build/libs') {
14 | include '*.jar'
15 | exclude '*javadoc.jar'
16 | exclude '*-sources.jar'
17 | }
18 | into(rootProject.file("buildSdk/android"))
19 | }
20 |
21 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=aosp-dexutils
2 | POM_NAME=Dex Utils Lib From AOSP
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Annotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section.Item;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 | import com.tencent.tinker.android.dex.util.HashCodeHelper;
22 |
23 | import static com.tencent.tinker.android.dex.EncodedValueReader.ENCODED_ANNOTATION;
24 |
25 | /**
26 | * An annotation.
27 | */
28 | public final class Annotation extends Item {
29 | public byte visibility;
30 | public EncodedValue encodedAnnotation;
31 |
32 | public Annotation(int off, byte visibility, EncodedValue encodedAnnotation) {
33 | super(off);
34 | this.visibility = visibility;
35 | this.encodedAnnotation = encodedAnnotation;
36 | }
37 |
38 | public EncodedValueReader getReader() {
39 | return new EncodedValueReader(encodedAnnotation, ENCODED_ANNOTATION);
40 | }
41 |
42 | public int getTypeIndex() {
43 | EncodedValueReader reader = getReader();
44 | reader.readAnnotation();
45 | return reader.getAnnotationType();
46 | }
47 |
48 | @Override public int compareTo(Annotation other) {
49 | int cmpRes = encodedAnnotation.compareTo(other.encodedAnnotation);
50 | if (cmpRes != 0) return cmpRes;
51 | return CompareUtils.uCompare(visibility, other.visibility);
52 | }
53 |
54 | @Override
55 | public int hashCode() {
56 | return HashCodeHelper.hash(visibility, encodedAnnotation);
57 | }
58 |
59 | @Override
60 | public boolean equals(Object obj) {
61 | if (!(obj instanceof Annotation)) {
62 | return false;
63 | }
64 | return this.compareTo((Annotation) obj) == 0;
65 | }
66 |
67 | @Override
68 | public int byteCountInDex() {
69 | return SizeOf.UBYTE + encodedAnnotation.byteCountInDex();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/AnnotationSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 |
22 | import java.util.Arrays;
23 |
24 | /**
25 | * *** This file is NOT a part of AOSP. ***
26 | *
27 | * Structure of AnnotationSet element in Dex file.
28 | */
29 | public class AnnotationSet extends Section.Item {
30 | public int[] annotationOffsets;
31 |
32 | public AnnotationSet(int off, int[] annotationOffsets) {
33 | super(off);
34 | this.annotationOffsets = annotationOffsets;
35 | }
36 |
37 | @Override
38 | public int compareTo(AnnotationSet other) {
39 | int size = annotationOffsets.length;
40 | int oSize = other.annotationOffsets.length;
41 |
42 | if (size != oSize) {
43 | return CompareUtils.uCompare(size, oSize);
44 | }
45 |
46 | for (int i = 0; i < size; ++i) {
47 | if (annotationOffsets[i] != other.annotationOffsets[i]) {
48 | return CompareUtils.uCompare(annotationOffsets[i], other.annotationOffsets[i]);
49 | }
50 | }
51 |
52 | return 0;
53 | }
54 |
55 | @Override
56 | public int hashCode() {
57 | return Arrays.hashCode(annotationOffsets);
58 | }
59 |
60 | @Override
61 | public boolean equals(Object obj) {
62 | if (!(obj instanceof AnnotationSet)) {
63 | return false;
64 | }
65 | return this.compareTo((AnnotationSet) obj) == 0;
66 | }
67 |
68 | @Override
69 | public int byteCountInDex() {
70 | return SizeOf.UINT * (1 + annotationOffsets.length);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/AnnotationSetRefList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 |
22 | import java.util.Arrays;
23 |
24 | /**
25 | * *** This file is NOT a part of AOSP. ***
26 | *
27 | * Structure of AnnotationSetRefList element in Dex file.
28 | */
29 | public class AnnotationSetRefList extends Section.Item {
30 | public int[] annotationSetRefItems;
31 |
32 | public AnnotationSetRefList(int off, int[] annotationSetRefItems) {
33 | super(off);
34 | this.annotationSetRefItems = annotationSetRefItems;
35 | }
36 |
37 | @Override
38 | public int compareTo(AnnotationSetRefList other) {
39 | int size = annotationSetRefItems.length;
40 | int oSize = other.annotationSetRefItems.length;
41 |
42 | if (size != oSize) {
43 | return CompareUtils.uCompare(size, oSize);
44 | }
45 |
46 | for (int i = 0; i < size; ++i) {
47 | if (annotationSetRefItems[i] != other.annotationSetRefItems[i]) {
48 | return CompareUtils.uCompare(annotationSetRefItems[i], other.annotationSetRefItems[i]);
49 | }
50 | }
51 |
52 | return 0;
53 | }
54 |
55 | @Override
56 | public int hashCode() {
57 | return Arrays.hashCode(annotationSetRefItems);
58 | }
59 |
60 | @Override
61 | public boolean equals(Object obj) {
62 | if (!(obj instanceof AnnotationSetRefList)) {
63 | return false;
64 | }
65 | return this.compareTo((AnnotationSetRefList) obj) == 0;
66 | }
67 |
68 | @Override
69 | public int byteCountInDex() {
70 | return SizeOf.UINT * (1 + annotationSetRefItems.length);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/CallSiteId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section.Item;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 |
22 | public class CallSiteId extends Item {
23 | public int offset;
24 |
25 | public CallSiteId(int off, int offset) {
26 | super(off);
27 | this.offset = offset;
28 | }
29 |
30 | public void writeTo(Dex.Section out) {
31 | out.writeInt(offset);
32 | }
33 |
34 | @Override
35 | public int byteCountInDex() {
36 | return SizeOf.UINT;
37 | }
38 |
39 | @Override
40 | public int compareTo(CallSiteId o) {
41 | return CompareUtils.uCompare(offset, o.offset);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/DexException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | /**
20 | * Thrown when there's a format problem reading, writing, or generally
21 | * processing a dex file.
22 | */
23 | public class DexException extends RuntimeException {
24 | static final long serialVersionUID = 1L;
25 |
26 | public DexException(String message) {
27 | super(message);
28 | }
29 |
30 | public DexException(Throwable cause) {
31 | super(cause);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/EncodedValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.util.ByteInput;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 |
22 | import java.util.Arrays;
23 |
24 | import static com.tencent.tinker.android.dex.TableOfContents.Section.Item;
25 |
26 | /**
27 | * An encoded value or array.
28 | */
29 | public final class EncodedValue extends Item {
30 | public byte[] data;
31 |
32 | public EncodedValue(int off, byte[] data) {
33 | super(off);
34 | this.data = data;
35 | }
36 |
37 | public ByteInput asByteInput() {
38 | return new ByteInput() {
39 | private int position = 0;
40 |
41 | @Override
42 | public byte readByte() {
43 | return data[position++];
44 | }
45 | };
46 | }
47 |
48 | @Override public int compareTo(EncodedValue other) {
49 | return CompareUtils.uArrCompare(data, other.data);
50 | }
51 |
52 | @Override
53 | public int hashCode() {
54 | return Arrays.hashCode(data);
55 | }
56 |
57 | @Override
58 | public boolean equals(Object obj) {
59 | if (!(obj instanceof EncodedValue)) {
60 | return false;
61 | }
62 | return this.compareTo((EncodedValue) obj) == 0;
63 | }
64 |
65 | @Override
66 | public int byteCountInDex() {
67 | return SizeOf.UBYTE * data.length;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/FieldId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section.Item;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 | import com.tencent.tinker.android.dex.util.HashCodeHelper;
22 |
23 | public final class FieldId extends Item {
24 | public int declaringClassIndex;
25 | public int typeIndex;
26 | public int nameIndex;
27 |
28 | public FieldId(int off, int declaringClassIndex, int typeIndex, int nameIndex) {
29 | super(off);
30 | this.declaringClassIndex = declaringClassIndex;
31 | this.typeIndex = typeIndex;
32 | this.nameIndex = nameIndex;
33 | }
34 |
35 | public int compareTo(FieldId other) {
36 | if (declaringClassIndex != other.declaringClassIndex) {
37 | return CompareUtils.uCompare(declaringClassIndex, other.declaringClassIndex);
38 | }
39 | if (nameIndex != other.nameIndex) {
40 | return CompareUtils.uCompare(nameIndex, other.nameIndex);
41 | }
42 | return CompareUtils.uCompare(typeIndex, other.typeIndex); // should always be 0
43 | }
44 |
45 | @Override
46 | public int hashCode() {
47 | return HashCodeHelper.hash(declaringClassIndex, typeIndex, nameIndex);
48 | }
49 |
50 | @Override
51 | public boolean equals(Object obj) {
52 | if (!(obj instanceof FieldId)) {
53 | return false;
54 | }
55 | return this.compareTo((FieldId) obj) == 0;
56 | }
57 |
58 | @Override
59 | public int byteCountInDex() {
60 | return SizeOf.MEMBER_ID_ITEM;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/MethodId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section.Item;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 | import com.tencent.tinker.android.dex.util.HashCodeHelper;
22 |
23 | public final class MethodId extends Item {
24 | public int declaringClassIndex;
25 | public int protoIndex;
26 | public int nameIndex;
27 |
28 | public MethodId(int off, int declaringClassIndex, int protoIndex, int nameIndex) {
29 | super(off);
30 | this.declaringClassIndex = declaringClassIndex;
31 | this.protoIndex = protoIndex;
32 | this.nameIndex = nameIndex;
33 | }
34 |
35 | public int compareTo(MethodId other) {
36 | if (declaringClassIndex != other.declaringClassIndex) {
37 | return CompareUtils.uCompare(declaringClassIndex, other.declaringClassIndex);
38 | }
39 | if (nameIndex != other.nameIndex) {
40 | return CompareUtils.uCompare(nameIndex, other.nameIndex);
41 | }
42 | return CompareUtils.uCompare(protoIndex, other.protoIndex);
43 | }
44 |
45 | @Override
46 | public int hashCode() {
47 | return HashCodeHelper.hash(declaringClassIndex, protoIndex, nameIndex);
48 | }
49 |
50 | @Override
51 | public boolean equals(Object obj) {
52 | if (!(obj instanceof MethodId)) {
53 | return false;
54 | }
55 | return this.compareTo((MethodId) obj) == 0;
56 | }
57 |
58 | @Override
59 | public int byteCountInDex() {
60 | return SizeOf.MEMBER_ID_ITEM;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/ProtoId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.util.CompareUtils;
20 | import com.tencent.tinker.android.dex.util.HashCodeHelper;
21 |
22 | public final class ProtoId extends TableOfContents.Section.Item {
23 | public int shortyIndex;
24 | public int returnTypeIndex;
25 | public int parametersOffset;
26 |
27 | public ProtoId(int off, int shortyIndex, int returnTypeIndex, int parametersOffset) {
28 | super(off);
29 | this.shortyIndex = shortyIndex;
30 | this.returnTypeIndex = returnTypeIndex;
31 | this.parametersOffset = parametersOffset;
32 | }
33 |
34 | public int compareTo(ProtoId other) {
35 | int res = CompareUtils.uCompare(shortyIndex, other.shortyIndex);
36 | if (res != 0) {
37 | return res;
38 | }
39 | res = CompareUtils.uCompare(returnTypeIndex, other.returnTypeIndex);
40 | if (res != 0) {
41 | return res;
42 | }
43 | return CompareUtils.sCompare(parametersOffset, other.parametersOffset);
44 | }
45 |
46 |
47 | @Override
48 | public int hashCode() {
49 | return HashCodeHelper.hash(shortyIndex, returnTypeIndex, parametersOffset);
50 | }
51 |
52 | @Override
53 | public boolean equals(Object obj) {
54 | if (!(obj instanceof ProtoId)) {
55 | return false;
56 | }
57 | return this.compareTo((ProtoId) obj) == 0;
58 | }
59 |
60 | @Override
61 | public int byteCountInDex() {
62 | return SizeOf.PROTO_ID_ITEM;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/StringData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section.Item;
20 |
21 | import java.io.UTFDataFormatException;
22 |
23 | /**
24 | * *** This file is NOT a part of AOSP. ***
25 | *
26 | * Structure of StringData element in Dex file.
27 | */
28 | public class StringData extends Item {
29 | public String value;
30 |
31 | public StringData(int offset, String value) {
32 | super(offset);
33 | this.value = value;
34 | }
35 |
36 | @Override
37 | public int compareTo(StringData other) {
38 | return value.compareTo(other.value);
39 | }
40 |
41 | @Override
42 | public int hashCode() {
43 | return value.hashCode();
44 | }
45 |
46 | @Override
47 | public boolean equals(Object obj) {
48 | if (!(obj instanceof StringData)) {
49 | return false;
50 | }
51 | return this.compareTo((StringData) obj) == 0;
52 | }
53 |
54 | @Override
55 | public int byteCountInDex() {
56 | try {
57 | return Leb128.unsignedLeb128Size(value.length()) + (int) Mutf8.countBytes(value, false) + SizeOf.UBYTE;
58 | } catch (UTFDataFormatException e) {
59 | throw new DexException(e);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/TypeList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex;
18 |
19 | import com.tencent.tinker.android.dex.TableOfContents.Section.Item;
20 | import com.tencent.tinker.android.dex.util.CompareUtils;
21 |
22 | import java.util.Arrays;
23 |
24 | public final class TypeList extends Item {
25 | public static final TypeList EMPTY = new TypeList(0, Dex.EMPTY_SHORT_ARRAY);
26 |
27 | public short[] types;
28 |
29 | public TypeList(int off, short[] types) {
30 | super(off);
31 | this.types = types;
32 | }
33 |
34 | @Override public int compareTo(TypeList other) {
35 | return CompareUtils.uArrCompare(types, other.types);
36 | }
37 |
38 | @Override
39 | public int hashCode() {
40 | return Arrays.hashCode(types);
41 | }
42 |
43 | @Override
44 | public boolean equals(Object obj) {
45 | if (!(obj instanceof TypeList)) {
46 | return false;
47 | }
48 | return this.compareTo((TypeList) obj) == 0;
49 | }
50 |
51 | @Override
52 | public int byteCountInDex() {
53 | return SizeOf.UINT + types.length * SizeOf.USHORT;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/util/ByteInput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex.util;
18 |
19 | /**
20 | * A byte source.
21 | */
22 | public interface ByteInput {
23 |
24 | /**
25 | * Returns a byte.
26 | *
27 | * @throws IndexOutOfBoundsException if all bytes have been read.
28 | */
29 | byte readByte();
30 | }
31 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/util/ByteOutput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dex.util;
18 |
19 | /**
20 | * A byte sink.
21 | */
22 | public interface ByteOutput {
23 |
24 | /**
25 | * Writes a byte.
26 | *
27 | * @throws IndexOutOfBoundsException if all bytes have been written.
28 | */
29 | void writeByte(int i);
30 | }
31 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/util/HashCodeHelper.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.android.dex.util;
2 |
3 | import java.lang.reflect.Array;
4 | import java.util.Arrays;
5 |
6 | public final class HashCodeHelper {
7 | public static int hash(Object... values) {
8 | if (values == null || values.length == 0) {
9 | return 0;
10 | }
11 | int result = 0;
12 | for (Object v : values) {
13 | if (v == null) {
14 | continue;
15 | }
16 | if (v instanceof Number) {
17 | result += v.hashCode();
18 | } else if (v instanceof boolean[]) {
19 | result += Arrays.hashCode((boolean[]) v);
20 | } else if (v instanceof byte[]) {
21 | result += Arrays.hashCode((byte[]) v);
22 | } else if (v instanceof char[]) {
23 | result += Arrays.hashCode((char[]) v);
24 | } else if (v instanceof short[]) {
25 | result += Arrays.hashCode((short[]) v);
26 | } else if (v instanceof int[]) {
27 | result += Arrays.hashCode((int[]) v);
28 | } else if (v instanceof long[]) {
29 | result += Arrays.hashCode((long[]) v);
30 | } else if (v instanceof float[]) {
31 | result += Arrays.hashCode((float[]) v);
32 | } else if (v instanceof double[]) {
33 | result += Arrays.hashCode((double[]) v);
34 | } else if (v instanceof Object[]) {
35 | result += Arrays.hashCode((Object[]) v);
36 | } else if (v.getClass().isArray()) {
37 | for (int i = 0; i < Array.getLength(v); ++i) {
38 | result += hash(Array.get(v, i));
39 | }
40 | } else {
41 | result += v.hashCode();
42 | }
43 | }
44 | return result;
45 | }
46 |
47 | private HashCodeHelper() {
48 | throw new UnsupportedOperationException();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dx/instruction/InstructionReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dx.instruction;
18 |
19 | import java.io.EOFException;
20 |
21 | /**
22 | * *** This file is NOT a part of AOSP. ***
23 | *
24 | * Created by tangyinsheng on 2016/5/26.
25 | */
26 | public final class InstructionReader {
27 | private final ShortArrayCodeInput codeIn;
28 |
29 | public InstructionReader(ShortArrayCodeInput in) {
30 | this.codeIn = in;
31 | }
32 |
33 | public void accept(InstructionVisitor iv) throws EOFException {
34 | InstructionCodec.decode(codeIn, iv);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dx/instruction/ShortArrayCodeInput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 com.tencent.tinker.android.dx.instruction;
18 |
19 | import java.io.EOFException;
20 |
21 | /**
22 | * Reads code from a {@code short[]}.
23 | */
24 | public final class ShortArrayCodeInput extends CodeCursor {
25 | /** source array to read from */
26 | private final short[] array;
27 |
28 | /**
29 | * Constructs an instance.
30 | */
31 | public ShortArrayCodeInput(short[] array) {
32 | if (array == null) {
33 | throw new NullPointerException("array == null");
34 | }
35 |
36 | this.array = array;
37 | }
38 |
39 | /**
40 | * Returns whether there are any more code units to read. This
41 | * is analogous to {@code hasNext()} on an interator.
42 | */
43 | public boolean hasMore() {
44 | return cursor() < array.length;
45 | }
46 |
47 | /**
48 | * Reads a code unit.
49 | */
50 | public int read() throws EOFException {
51 | try {
52 | int value = array[cursor()];
53 | advance(1);
54 | return value & 0xffff;
55 | } catch (ArrayIndexOutOfBoundsException ex) {
56 | throw new EOFException();
57 | }
58 | }
59 |
60 | /**
61 | * Reads two code units, treating them as a little-endian {@code int}.
62 | */
63 | public int readInt() throws EOFException {
64 | int short0 = read();
65 | int short1 = read();
66 |
67 | return short0 | (short1 << 16);
68 | }
69 |
70 | /**
71 | * Reads four code units, treating them as a little-endian {@code long}.
72 | */
73 | public long readLong() throws EOFException {
74 | long short0 = read();
75 | long short1 = read();
76 | long short2 = read();
77 | long short3 = read();
78 |
79 | return short0 | (short1 << 16) | (short2 << 32) | (short3 << 48);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/third-party/bsdiff-util/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/third-party/bsdiff-util/LICENSE.txt:
--------------------------------------------------------------------------------
1 | BSD License
2 |
3 | Copyright (C) 2016 THL A29 Limited, a Tencent company.
4 | Copyright (c) 2005, Joe Desbonnet, (jdesbonnet@gmail.com)
5 | Copyright 2003-2005 Colin Percival
6 | All rights reserved
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted providing that the following conditions
10 | are met:
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | 2. Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/third-party/bsdiff-util/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | sourceCompatibility = rootProject.ext.javaVersion
9 | targetCompatibility = rootProject.ext.javaVersion
10 |
11 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
12 | group = "tinker"
13 | from('build/libs') {
14 | include '*.jar'
15 | exclude '*javadoc.jar'
16 | exclude '*-sources.jar'
17 | }
18 | into(rootProject.file("buildSdk/android"))
19 | }
20 |
21 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
--------------------------------------------------------------------------------
/third-party/bsdiff-util/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=bsdiff-util
2 | POM_NAME=BsDiff Util
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | sourceCompatibility = rootProject.ext.javaVersion
9 | targetCompatibility = rootProject.ext.javaVersion
10 |
11 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
12 | group = "tinker"
13 | from('build/libs') {
14 | include '*.jar'
15 | exclude '*javadoc.jar'
16 | exclude '*-sources.jar'
17 | }
18 | into(rootProject.file("buildSdk/android"))
19 | }
20 |
21 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Tencent is pleased to support the open source community by making Tinker available.
3 | #
4 | # Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | #
6 | # Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | # compliance with the License. You may obtain a copy of the License at
8 | #
9 | # https://opensource.org/licenses/BSD-3-Clause
10 | #
11 | # Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | # distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | # either express or implied. See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | POM_ARTIFACT_ID=tinker-ziputils
18 | POM_NAME=Tinker Zip Utils
19 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/Arrays.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.ziputils.ziputil;
18 |
19 | /**
20 | * modify by zhangshaowen on 16/6/7.
21 | */
22 | public class Arrays {
23 | public static void checkOffsetAndCount(int arrayLength, int offset, int count) {
24 | if ((offset | count) < 0 || offset > arrayLength || arrayLength - offset < count) {
25 | // throw new ArrayIndexOutOfBoundsException(arrayLength, offset,
26 | // count);
27 | throw new ArrayIndexOutOfBoundsException(offset);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/BufferIterator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.ziputils.ziputil;
18 |
19 | /**
20 | * modify by zhangshaowen on 16/6/7.
21 | */
22 | public abstract class BufferIterator {
23 | /**
24 | * Seeks to the absolute position {@code offset}, measured in bytes from the start.
25 | */
26 | public abstract void seek(int offset);
27 | /**
28 | * Skips forwards or backwards {@code byteCount} bytes from the current position.
29 | */
30 | public abstract void skip(int byteCount);
31 |
32 | public abstract int readInt();
33 |
34 | public abstract short readShort();
35 | }
36 |
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/SizeOf.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.ziputils.ziputil;
18 |
19 | /**
20 | * modify by zhangshaowen on 16/6/7.
21 | */
22 | public final class SizeOf {
23 | public static final int CHAR = 2;
24 | public static final int DOUBLE = 8;
25 | public static final int FLOAT = 4;
26 | public static final int INT = 4;
27 | public static final int LONG = 8;
28 | public static final int SHORT = 2;
29 | private SizeOf() {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/StandardCharsets.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.ziputils.ziputil;
18 |
19 | import java.nio.charset.Charset;
20 |
21 | /**
22 | * modify by zhangshaowen on 16/6/7.
23 | */
24 | public final class StandardCharsets {
25 | public static final Charset UTF_8 = Charset.forName("UTF-8");
26 |
27 | private StandardCharsets() {
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/ZipConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.ziputils.ziputil;
18 |
19 | /**
20 | * modify by zhangshaowen on 16/6/7.
21 | *
22 | * Do not add constants to this interface! It's implemented by the classes
23 | * in this package whose names start "Zip", and the constants are thereby
24 | * public API.
25 | */
26 | interface ZipConstants {
27 | long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
28 | CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
29 | int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
30 | LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
31 | LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
32 | EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
33 | CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
34 | CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
35 | CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
36 | ENDOFF = 16, ENDCOM = 20;
37 | }
38 |
--------------------------------------------------------------------------------
/tinker-android/consumer-proguard.txt:
--------------------------------------------------------------------------------
1 | # Understand the Tinker @Keep annotation.
2 | -keep class com.tencent.tinker.anno.Keep
3 |
4 | -keep @com.tencent.tinker.anno.Keep class * {*;}
5 |
6 | -keepclasseswithmembers class * {
7 | @com.tencent.tinker.anno.Keep ;
8 | }
9 |
10 | -keepclasseswithmembers class * {
11 | @com.tencent.tinker.anno.Keep ;
12 | }
13 |
14 | -keepclasseswithmembers class * {
15 | @com.tencent.tinker.anno.Keep (...);
16 | }
17 |
18 | -dontwarn android.content.pm.PackageManager$DexModuleRegisterCallback
19 |
20 | -keep class * extends android.content.pm.PackageManager$DexModuleRegisterCallback {
21 | ;
22 | ;
23 | }
24 |
25 | -keepclassmembernames class com.tencent.tinker.loader.** {
26 | ;
27 | ;
28 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno-support/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno-support/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | sourceCompatibility = rootProject.ext.javaVersion
9 | targetCompatibility = rootProject.ext.javaVersion
10 |
11 | dependencies {
12 | implementation fileTree(dir: 'libs', include: ['*.jar'])
13 | }
14 |
15 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
16 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno-support/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-android-anno-support
2 | POM_NAME=Tinker Android Annotation Support
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno-support/src/main/java/com/tencent/tinker/anno/DefaultLifeCycle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.anno;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Inherited;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Annotations
27 | *
28 | * Created by zhaoyuan on 16/3/31.
29 | */
30 | @Target(ElementType.TYPE)
31 | @Retention(RetentionPolicy.SOURCE)
32 | @Inherited
33 | public @interface DefaultLifeCycle {
34 |
35 | String application();
36 |
37 | String loaderClass() default "com.tencent.tinker.loader.TinkerLoader";
38 |
39 | int flags();
40 |
41 | boolean loadVerifyFlag() default false;
42 |
43 | boolean useDelegateLastClassLoader() default false;
44 |
45 | boolean useInterpretModeOnSupported32BitSystem() default false;
46 | }
47 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno-support/src/main/java/com/tencent/tinker/anno/Keep.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.anno;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by tangyinsheng on 2020-03-27.
10 | */
11 | @Retention(RetentionPolicy.CLASS)
12 | @Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.FIELD})
13 | public @interface Keep {
14 | }
15 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | dependencies {
9 | implementation fileTree(dir: 'libs', include: ['*.jar'])
10 | implementation project(':tinker-android:tinker-android-anno-support')
11 | }
12 |
13 | sourceSets {
14 | main {
15 | java {
16 | srcDir 'src/main/java'
17 | }
18 |
19 | resources {
20 | srcDir 'src/main/resources'
21 | }
22 | }
23 | }
24 |
25 | sourceCompatibility = rootProject.ext.javaVersion
26 | targetCompatibility = rootProject.ext.javaVersion
27 |
28 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
29 | group = "tinker"
30 | from('build/libs') {
31 | include '*.jar'
32 | exclude '*javadoc.jar'
33 | exclude '*-sources.jar'
34 | }
35 | into(rootProject.file("buildSdk/android"))
36 | }
37 |
38 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
39 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-android-anno
2 | POM_NAME=Tinker Android Anno
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | com.tencent.tinker.anno.AnnotationProcessor
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno/src/main/resources/TinkerAnnoApplication.tmpl:
--------------------------------------------------------------------------------
1 | package %PACKAGE%;
2 |
3 | import com.tencent.tinker.loader.app.TinkerApplication;
4 |
5 | /**
6 | *
7 | * Generated application for tinker life cycle
8 | *
9 | */
10 | public class %APPLICATION% extends TinkerApplication {
11 |
12 | public %APPLICATION%() {
13 | super(%TINKER_FLAGS%, "%APPLICATION_LIFE_CYCLE%", "%TINKER_LOADER_CLASS%", %TINKER_LOAD_VERIFY_FLAG%, %TINKER_USE_DLC%, %TINKER_USE_INTERPRET_MODE_ON_SUPPORTED_32BIT_SYSTEM%);
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-anno/src/test/java/com/tencent/tinker/anno/test/TestLifeCycle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.anno.test;
18 |
19 | //import com.tencent.tinker.anno.DefaultLifeCycle;
20 | //
21 | ///**
22 | // * Test LifeCycle
23 | // *
24 | // * Created by zhaoyuan on 16/4/1.
25 | // */
26 | //@DefaultLifeCycle(application = ".TestApplication", flags = 0x10, loaderClass="com.tencent.tinker.loader.TinkerLoader")
27 | //public class TestLifeCycle {
28 | //
29 | //}
30 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.minSdkVersion
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 |
14 | buildConfigField "String", "TINKER_VERSION", "\"${rootProject.ext.VERSION_NAME}\""
15 |
16 | manifestPlaceholders = [TINKER_VERSION: "${rootProject.ext.VERSION_NAME}"]
17 |
18 | consumerProguardFiles file('../consumer-proguard.txt')
19 | }
20 |
21 | lintOptions {
22 | disable 'LongLogTag'
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility rootProject.ext.javaVersion
27 | targetCompatibility rootProject.ext.javaVersion
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | testImplementation 'junit:junit:4.12'
34 | implementation project(':tinker-android:tinker-android-anno-support')
35 | api project(':tinker-android:tinker-android-loader-no-op')
36 | api project(':tinker-commons')
37 | }
38 |
39 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
40 | group = "tinker"
41 | from("$buildDir/outputs/aar/") {
42 | include "${project.getName()}-release.aar"
43 | }
44 |
45 | into(rootProject.file("buildSdk/android/"))
46 | rename { String fileName ->
47 | fileName.replace("release", "${version}")
48 | }
49 | }
50 |
51 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-android-lib-no-op
2 | POM_NAME=Tinker Android Lib
3 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangshaowen/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/androidTest/java/com/tencent/tinker/lib/patch/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.patch;
18 |
19 | import android.app.Application;
20 | import android.test.ApplicationTestCase;
21 |
22 | /**
23 | * Testing Fundamentals
24 | */
25 | public class ApplicationTest extends ApplicationTestCase {
26 | public ApplicationTest() {
27 | super(Application.class);
28 | }
29 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/listener/DefaultPatchListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.listener;
18 |
19 | import android.content.Context;
20 |
21 | import com.tencent.tinker.lib.tinker.Tinker;
22 | import com.tencent.tinker.loader.shareutil.ShareConstants;
23 |
24 | import java.io.File;
25 |
26 | /**
27 | * Created by zhangshaowen on 16/3/14.
28 | */
29 | public class DefaultPatchListener implements PatchListener {
30 | protected final Context context;
31 |
32 | public DefaultPatchListener(Context context) {
33 | this.context = context;
34 | }
35 |
36 | @Override
37 | public int onPatchReceived(String path) {
38 | return checkPackageAndRunPatchService(path, false);
39 | }
40 |
41 | protected int checkPackageAndRunPatchService(String path, boolean useEmergencyMode) {
42 | final int returnCode = patchCheck(path, null);
43 | Tinker.with(context).getLoadReporter().onLoadPatchListenerReceiveFail(new File(path), returnCode);
44 | return returnCode;
45 | }
46 |
47 | protected int patchCheck(String path, String patchMd5) {
48 | return ShareConstants.ERROR_PATCH_DISABLE;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/listener/PatchListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.listener;
18 |
19 | /**
20 | * Created by zhangshaowen on 16/3/14.
21 | */
22 | public interface PatchListener {
23 | int onPatchReceived(String path);
24 | }
25 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/patch/AbstractPatch.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.patch;
18 |
19 | import android.content.Context;
20 |
21 | import com.tencent.tinker.lib.service.PatchResult;
22 |
23 | /**
24 | * Created by zhangshaowen on 16/3/15.
25 | */
26 | public abstract class AbstractPatch {
27 |
28 | public abstract boolean tryPatch(Context context, String tempPatchPath, boolean useEmergencyMode, PatchResult patchResult);
29 | }
30 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/patch/UpgradePatch.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.patch;
18 |
19 | import android.content.Context;
20 |
21 | import com.tencent.tinker.lib.service.PatchResult;
22 | import com.tencent.tinker.lib.util.TinkerLog;
23 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
24 |
25 |
26 | /**
27 | * generate new patch, you can implement your own patch processor class
28 | * Created by zhangshaowen on 16/3/14.
29 | */
30 | public class UpgradePatch extends AbstractPatch {
31 | private static final String TAG = "Tinker.UpgradePatch";
32 |
33 | @Override
34 | public boolean tryPatch(Context context, String tempPatchPath, boolean useEmergencyMode, PatchResult patchResult) {
35 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
36 | return false;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/reporter/DefaultPatchReporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.reporter;
18 |
19 |
20 | import android.content.Context;
21 | import android.content.Intent;
22 |
23 | import com.tencent.tinker.loader.shareutil.SharePatchInfo;
24 |
25 | import java.io.File;
26 | import java.util.List;
27 |
28 | /**
29 | * Created by zhangshaowen on 16/3/14.
30 | */
31 | public class DefaultPatchReporter implements PatchReporter {
32 | protected final Context context;
33 |
34 | public DefaultPatchReporter(Context context) {
35 | this.context = context;
36 | // Ignored.
37 | }
38 |
39 | @Override
40 | public void onPatchServiceStart(Intent intent) {
41 | // Ignored.
42 | }
43 |
44 | @Override
45 | public void onPatchPackageCheckFail(File patchFile, int errorCode) {
46 | // Ignored.
47 | }
48 |
49 | @Override
50 | public void onPatchVersionCheckFail(File patchFile, SharePatchInfo oldPatchInfo, String patchFileVersion) {
51 | // Ignored.
52 | }
53 |
54 | @Override
55 | public void onPatchTypeExtractFail(File patchFile, File extractTo, String filename, int fileType) {
56 | // Ignored.
57 | }
58 |
59 | @Override
60 | public void onPatchDexOptFail(File patchFile, List dexFiles, Throwable t) {
61 | // Ignored.
62 | }
63 |
64 | @Override
65 | public void onPatchResult(File patchFile, boolean success, long cost) {
66 | // Ignored.
67 | }
68 |
69 | @Override
70 | public void onPatchInfoCorrupted(File patchFile, String oldVersion, String newVersion) {
71 | // Ignored.
72 | }
73 |
74 | @Override
75 | public void onPatchException(File patchFile, Throwable e) {
76 | // Ignored.
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/reporter/LoadReporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.reporter;
18 |
19 | import java.io.File;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/3/10.
23 | */
24 | public interface LoadReporter {
25 | void onLoadPatchListenerReceiveFail(File patchFile, int errorCode);
26 |
27 | void onLoadPatchVersionChanged(String oldVersion, String newVersion, File patchDirectoryFile, String currentPatchName);
28 |
29 | void onLoadInterpret(int type, Throwable e);
30 |
31 | void onLoadResult(File patchDirectory, int loadCode, long cost);
32 |
33 | void onLoadException(Throwable e, int errorCode);
34 |
35 | void onLoadFileNotFound(File file, int fileType, boolean isDirectory);
36 |
37 | void onLoadFileMd5Mismatch(File file, int fileType);
38 |
39 | void onLoadPatchInfoCorrupted(String oldVersion, String newVersion, File patchInfoFile);
40 |
41 | void onLoadPackageCheckFail(File patchFile, int errorCode);
42 | }
43 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/reporter/PatchReporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.reporter;
18 |
19 |
20 | import android.content.Intent;
21 |
22 | import com.tencent.tinker.lib.patch.UpgradePatch;
23 | import com.tencent.tinker.lib.service.DefaultTinkerResultService;
24 | import com.tencent.tinker.loader.shareutil.SharePatchInfo;
25 |
26 | import java.io.File;
27 | import java.util.List;
28 |
29 | /**
30 | * Created by zhangshaowen on 16/3/14.
31 | *
32 | * means that it is a newly patch, we would default use {@link UpgradePatch}
33 | * to do the job
34 | */
35 | public interface PatchReporter {
36 | void onPatchServiceStart(Intent intent);
37 |
38 | void onPatchPackageCheckFail(File patchFile, int errorCode);
39 |
40 | void onPatchVersionCheckFail(File patchFile, SharePatchInfo oldPatchInfo, String patchFileVersion);
41 |
42 | void onPatchTypeExtractFail(File patchFile, File extractTo, String filename, int fileType);
43 |
44 | void onPatchDexOptFail(File patchFile, List dexFiles, Throwable t);
45 |
46 | void onPatchResult(File patchFile, boolean success, long cost);
47 |
48 | void onPatchException(File patchFile, Throwable e);
49 |
50 | void onPatchInfoCorrupted(File patchFile, String oldVersion, String newVersion);
51 | }
52 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/service/AbstractResultService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.service;
18 |
19 | import android.app.IntentService;
20 | import android.content.Context;
21 | import android.content.Intent;
22 |
23 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
24 |
25 | /**
26 | * Created by zhangshaowen on 16/3/14.
27 | */
28 | public abstract class AbstractResultService extends IntentService {
29 | private static final String TAG = "Tinker.AbstractResultService";
30 |
31 | public AbstractResultService() {
32 | super("TinkerResultService");
33 | }
34 |
35 | public static void runResultService(Context context, PatchResult result, String resultServiceClass) {
36 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
37 | }
38 |
39 | @Override
40 | protected void onHandleIntent(Intent intent) {
41 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
42 | }
43 |
44 | public abstract void onPatchResult(PatchResult result);
45 | }
46 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/service/DefaultTinkerResultService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.service;
18 |
19 |
20 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
21 |
22 | import java.io.File;
23 |
24 | /**
25 | * Created by zhangshaowen on 16/3/19.
26 | */
27 | public class DefaultTinkerResultService extends AbstractResultService {
28 | private static final String TAG = "Tinker.DefaultTinkerResultService";
29 |
30 | @Override
31 | public void onPatchResult(PatchResult result) {
32 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
33 | }
34 |
35 | public void deleteRawPatchFile(File rawFile) {
36 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
37 | }
38 |
39 | public boolean checkIfNeedKill(PatchResult result) {
40 | return false;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/service/PatchResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.service;
18 |
19 | import java.io.Serializable;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/3/19.
23 | */
24 | public class PatchResult implements Serializable {
25 | public boolean isSuccess;
26 |
27 | public String rawPatchFilePath;
28 |
29 | public long costTime;
30 |
31 | public long dexoptTriggerTime;
32 |
33 | public boolean isOatGenerated;
34 |
35 | public Throwable e;
36 |
37 | //@Nullable
38 | public String patchVersion;
39 |
40 | @Override
41 | public String toString() {
42 | StringBuffer sb = new StringBuffer();
43 | sb.append("\nPatchResult: \n");
44 | sb.append("isSuccess:" + isSuccess + "\n");
45 | sb.append("rawPatchFilePath:" + rawPatchFilePath + "\n");
46 | sb.append("costTime:" + costTime + "\n");
47 | sb.append("dexoptTriggerTime:" + dexoptTriggerTime + "\n");
48 | sb.append("isOatGenerated:" + isOatGenerated + "\n");
49 | if (patchVersion != null) {
50 | sb.append("patchVersion:" + patchVersion + "\n");
51 | }
52 |
53 | if (e != null) {
54 | sb.append("Throwable:" + e.getMessage() + "\n");
55 | }
56 | return sb.toString();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/util/TinkerLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.util;
18 |
19 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/3/17.
23 | *
24 | * DEPRECATED. Use {@link com.tencent.tinker.loader.shareutil.ShareTinkerLog} instead.
25 | */
26 | @Deprecated
27 | public class TinkerLog {
28 | private static final String TAG = "Tinker.TinkerLog";
29 |
30 | public static void setTinkerLogImp(TinkerLogImp imp) {
31 | ShareTinkerLog.setTinkerLogImp(imp);
32 | }
33 |
34 | public static ShareTinkerLog.TinkerLogImp getImpl() {
35 | return ShareTinkerLog.getImpl();
36 | }
37 |
38 | public static void v(final String tag, final String msg, final Object... obj) {
39 | ShareTinkerLog.v(tag, msg, obj);
40 | }
41 |
42 | public static void e(final String tag, final String msg, final Object... obj) {
43 | ShareTinkerLog.v(tag, msg, obj);
44 | }
45 |
46 | public static void w(final String tag, final String msg, final Object... obj) {
47 | ShareTinkerLog.v(tag, msg, obj);
48 | }
49 |
50 | public static void i(final String tag, final String msg, final Object... obj) {
51 | ShareTinkerLog.v(tag, msg, obj);
52 | }
53 |
54 | public static void d(final String tag, final String msg, final Object... obj) {
55 | ShareTinkerLog.v(tag, msg, obj);
56 | }
57 |
58 | public static void printErrStackTrace(String tag, Throwable tr, final String format, final Object... obj) {
59 | ShareTinkerLog.printErrStackTrace(tag, tr, format, obj);
60 | }
61 |
62 | public static void printPendingLogs() {
63 | ShareTinkerLog.printPendingLogs();
64 | }
65 |
66 | public interface TinkerLogImp extends ShareTinkerLog.TinkerLogImp {}
67 | }
68 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/util/TinkerServiceInternals.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.util;
18 |
19 | import android.content.Context;
20 |
21 | import com.tencent.tinker.loader.shareutil.ShareTinkerInternals;
22 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
23 |
24 | /**
25 | * Created by zhangshaowen on 16/3/10.
26 | */
27 | public class TinkerServiceInternals extends ShareTinkerInternals {
28 | private static final String TAG = "Tinker.ServiceInternals";
29 |
30 | public static void killTinkerPatchServiceProcess(Context context) {
31 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
32 | }
33 |
34 | public static boolean isTinkerPatchServiceRunning(Context context) {
35 | return false;
36 | }
37 |
38 |
39 | public static String getTinkerPatchServiceName(final Context context) {
40 | return null;
41 | }
42 |
43 | public static boolean isInTinkerPatchServiceProcess(Context context) {
44 | return false;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/util/UpgradePatchRetry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.util;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 |
22 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
23 |
24 | /**
25 | * Created by zhangshaowen on 16/7/3.
26 | */
27 | public class UpgradePatchRetry {
28 | private static final String TAG = "Tinker.UpgradePatchRetry";
29 |
30 | private static UpgradePatchRetry sInstance;
31 |
32 | public UpgradePatchRetry(Context context) {
33 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
34 | }
35 |
36 | public static UpgradePatchRetry getInstance(Context context) {
37 | if (sInstance == null) {
38 | sInstance = new UpgradePatchRetry(context);
39 | }
40 | return sInstance;
41 | }
42 |
43 | public void setRetryEnable(boolean enable) {
44 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
45 | }
46 |
47 | public void setMaxRetryCount(int count) {
48 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
49 | }
50 |
51 | public boolean onPatchRetryLoad() {
52 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
53 | return false;
54 | }
55 |
56 | public void onPatchServiceStart(Intent intent) {
57 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
58 | }
59 |
60 | public boolean onPatchListenerCheck(String md5) {
61 | return true;
62 | }
63 |
64 | public boolean onPatchResetMaxCheck(String md5) {
65 | return true;
66 | }
67 |
68 | public void onPatchServiceResult() {
69 | ShareTinkerLog.e(TAG, "[-] Ignore this invocation since I'm no-op version.");
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib-no-op/src/test/java/com/tencent/tinker/recover/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.recover;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
25 | */
26 | public class ExampleUnitTest {
27 | @Test
28 | public void addition_isCorrect() throws Exception {
29 | assertEquals(4, 2 + 2);
30 | }
31 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.minSdkVersion
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 |
14 | buildConfigField "String", "TINKER_VERSION", "\"${rootProject.ext.VERSION_NAME}\""
15 |
16 | manifestPlaceholders = [TINKER_VERSION: "${rootProject.ext.VERSION_NAME}"]
17 |
18 | consumerProguardFiles file('../consumer-proguard.txt')
19 | }
20 |
21 | lintOptions {
22 | disable 'LongLogTag'
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility rootProject.ext.javaVersion
27 | targetCompatibility rootProject.ext.javaVersion
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | testImplementation 'junit:junit:4.12'
34 | implementation project(':tinker-android:tinker-android-anno-support')
35 | api project(':tinker-android:tinker-android-loader')
36 | api project(':tinker-commons')
37 | }
38 |
39 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
40 | group = "tinker"
41 | from("$buildDir/outputs/aar/") {
42 | include "${project.getName()}-release.aar"
43 | }
44 |
45 | into(rootProject.file("buildSdk/android/"))
46 | rename { String fileName ->
47 | fileName.replace("release", "${version}")
48 | }
49 | }
50 |
51 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-android-lib
2 | POM_NAME=Tinker Android Lib
3 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangshaowen/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/androidTest/java/com/tencent/tinker/lib/patch/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.patch;
18 |
19 | import android.app.Application;
20 | import android.test.ApplicationTestCase;
21 |
22 | /**
23 | * Testing Fundamentals
24 | */
25 | public class ApplicationTest extends ApplicationTestCase {
26 | public ApplicationTest() {
27 | super(Application.class);
28 | }
29 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
17 |
18 |
23 |
27 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/aidl/com/tencent/tinker/lib/IForeService.aidl:
--------------------------------------------------------------------------------
1 | // IForeService.aidl
2 | package com.tencent.tinker.lib;
3 |
4 |
5 | interface IForeService {
6 | void startme();
7 | }
8 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/ApplicationLifeCycle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.entry;
18 |
19 | /**
20 | * Created by zhangshaowen on 16/3/8.
21 | */
22 |
23 |
24 | import android.app.Application;
25 | import android.content.Context;
26 | import android.content.res.Configuration;
27 |
28 | /**
29 | * This interface is used to delegate calls from main Application object.
30 | *
31 | * Implementations of this interface must have a one-argument constructor that takes
32 | * an argument of type {@link Application}.
33 | */
34 | public interface ApplicationLifeCycle {
35 |
36 | /**
37 | * Same as {@link Application#onCreate()}.
38 | */
39 | void onCreate();
40 |
41 | /**
42 | * Same as {@link Application#onLowMemory()}.
43 | */
44 | void onLowMemory();
45 |
46 | /**
47 | * Same as {@link Application#onTrimMemory(int level)}.
48 | * @param level
49 | */
50 | void onTrimMemory(int level);
51 |
52 | /**
53 | * Same as {@link Application#onTerminate()}.
54 | */
55 | void onTerminate();
56 |
57 | /**
58 | * Same as {@link Application#onConfigurationChanged(Configuration newconfig)}.
59 | */
60 | void onConfigurationChanged(Configuration newConfig);
61 |
62 | /**
63 | * Same as {@link Application#attachBaseContext(Context context)}.
64 | */
65 | void onBaseContextAttached(Context base);
66 | }
67 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/filepatch/AbstractFilePatch.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.lib.filepatch;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 |
7 | public abstract class AbstractFilePatch {
8 |
9 | public abstract int patchFast(InputStream oldInputStream, InputStream diffInputStream, File newFile) throws IOException;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/filepatch/BsFilePatch.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.lib.filepatch;
2 |
3 | import com.tencent.tinker.bsdiff.BSPatch;
4 |
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 |
9 | public class BsFilePatch extends AbstractFilePatch{
10 |
11 | @Override
12 | public int patchFast(InputStream oldInputStream, InputStream diffInputStream, File newFile) throws IOException {
13 | return BSPatch.patchFast(oldInputStream, diffInputStream, newFile);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/filepatch/FilePatchFactory.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.lib.filepatch;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.tencent.tinker.lib.tinker.Tinker;
7 |
8 | public class FilePatchFactory {
9 | private static final String TAG = "MicroMsg.FilePatchFactory";
10 |
11 |
12 | public static AbstractFilePatch getFilePatcher(Context context, boolean useCustomPatcher) {
13 | if (Tinker.with(context).getCustomPatcher() == null || !useCustomPatcher) {
14 | Log.i(TAG, "BsFilePatch");
15 | return new BsFilePatch();
16 | }
17 | Log.i(TAG, "CustomPatcher");
18 | return Tinker.with(context).getCustomPatcher();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/listener/PatchListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.listener;
18 |
19 | /**
20 | * Created by zhangshaowen on 16/3/14.
21 | */
22 | public interface PatchListener {
23 | int onPatchReceived(String path);
24 | }
25 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/patch/AbstractPatch.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.patch;
18 |
19 | import android.content.Context;
20 |
21 | import com.tencent.tinker.lib.service.PatchResult;
22 |
23 | /**
24 | * Created by zhangshaowen on 16/3/15.
25 | */
26 | public abstract class AbstractPatch {
27 |
28 | public abstract boolean tryPatch(Context context, String tempPatchPath, boolean useEmergencyMode, PatchResult patchResult);
29 | }
30 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/PatchResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.service;
18 |
19 | import java.io.Serializable;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/3/19.
23 | */
24 | public class PatchResult implements Serializable {
25 | public static final int PATCH_TYPE_UNKNOWN = -1;
26 | public static final int PATCH_TYPE_BSDIFF = 0;
27 | public static final int PATCH_TYPE_CUSTOM = 1;
28 |
29 | public boolean isSuccess;
30 |
31 | public String rawPatchFilePath;
32 |
33 | public boolean useEmergencyMode;
34 |
35 | public long totalCostTime;
36 |
37 | public long dexCostTime;
38 |
39 | public long soCostTime;
40 |
41 | public long resCostTime;
42 |
43 | public int type = PATCH_TYPE_UNKNOWN;
44 |
45 | public long dexoptTriggerTime;
46 |
47 | public boolean isOatGenerated;
48 |
49 | public Throwable e;
50 |
51 | //@Nullable
52 | public String patchVersion;
53 |
54 | @Override
55 | public String toString() {
56 | StringBuffer sb = new StringBuffer();
57 | sb.append("\nPatchResult: \n");
58 | sb.append("isSuccess:" + isSuccess + "\n");
59 | sb.append("rawPatchFilePath:" + rawPatchFilePath + "\n");
60 | sb.append("useEmergencyMode:" + useEmergencyMode + "\n");
61 | sb.append("costTime:" + totalCostTime + "\n");
62 | sb.append("dexoptTriggerTime:" + dexoptTriggerTime + "\n");
63 | sb.append("isOatGenerated:" + isOatGenerated + "\n");
64 | if (patchVersion != null) {
65 | sb.append("patchVersion:" + patchVersion + "\n");
66 | }
67 |
68 | if (e != null) {
69 | sb.append("Throwable:" + e.getMessage() + "\n");
70 | }
71 | return sb.toString();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/TinkerPatchForeService.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.lib.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.os.RemoteException;
7 |
8 | import com.tencent.tinker.lib.IForeService;
9 |
10 | public class TinkerPatchForeService extends Service {
11 | public TinkerPatchForeService() {
12 | }
13 |
14 | @Override
15 | public int onStartCommand(Intent intent, int flags, int startId) {
16 | super.onStartCommand(intent, flags, startId);
17 | // It's unwelcome to restart owner process of this service automatically for users.
18 | // So return START_NOT_STICKY here to prevent this behavior.
19 | return START_NOT_STICKY;
20 | }
21 |
22 | @Override
23 | public IBinder onBind(Intent intent) {
24 | return new IForeService.Stub() {
25 | @Override
26 | public void startme() throws RemoteException {
27 | //占位使用,不做具体操作
28 | }
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/util/TinkerLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.lib.util;
18 |
19 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/3/17.
23 | *
24 | * DEPRECATED. Use {@link ShareTinkerLog} instead.
25 | */
26 | @Deprecated
27 | public class TinkerLog {
28 | private static final String TAG = "Tinker.TinkerLog";
29 |
30 | public static void setTinkerLogImp(TinkerLogImp imp) {
31 | ShareTinkerLog.setTinkerLogImp(imp);
32 | }
33 |
34 | public static ShareTinkerLog.TinkerLogImp getImpl() {
35 | return ShareTinkerLog.getImpl();
36 | }
37 |
38 | public static void v(final String tag, final String msg, final Object... obj) {
39 | ShareTinkerLog.v(tag, msg, obj);
40 | }
41 |
42 | public static void e(final String tag, final String msg, final Object... obj) {
43 | ShareTinkerLog.v(tag, msg, obj);
44 | }
45 |
46 | public static void w(final String tag, final String msg, final Object... obj) {
47 | ShareTinkerLog.v(tag, msg, obj);
48 | }
49 |
50 | public static void i(final String tag, final String msg, final Object... obj) {
51 | ShareTinkerLog.v(tag, msg, obj);
52 | }
53 |
54 | public static void d(final String tag, final String msg, final Object... obj) {
55 | ShareTinkerLog.v(tag, msg, obj);
56 | }
57 |
58 | public static void printErrStackTrace(String tag, Throwable tr, final String format, final Object... obj) {
59 | ShareTinkerLog.printErrStackTrace(tag, tr, format, obj);
60 | }
61 |
62 | public static void printPendingLogs() {
63 | ShareTinkerLog.printPendingLogs();
64 | }
65 |
66 | public interface TinkerLogImp extends ShareTinkerLog.TinkerLogImp {}
67 | }
68 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-lib/src/test/java/com/tencent/tinker/recover/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.recover;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
25 | */
26 | public class ExampleUnitTest {
27 | @Test
28 | public void addition_isCorrect() throws Exception {
29 | assertEquals(4, 2 + 2);
30 | }
31 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.minSdkVersion
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 |
14 | buildConfigField "String", "TINKER_VERSION", "\"${rootProject.ext.VERSION_NAME}\""
15 |
16 | manifestPlaceholders = [TINKER_VERSION: "${rootProject.ext.VERSION_NAME}"]
17 |
18 | consumerProguardFiles file('../consumer-proguard.txt')
19 | }
20 |
21 | lintOptions {
22 | disable 'LongLogTag'
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility rootProject.ext.javaVersion
27 | targetCompatibility rootProject.ext.javaVersion
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | testImplementation 'junit:junit:4.12'
34 | implementation project(':tinker-android:tinker-android-anno-support')
35 | }
36 |
37 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
38 | group = "tinker"
39 | from("$buildDir/outputs/aar/") {
40 | include "${project.getName()}-release.aar"
41 | }
42 |
43 | into(rootProject.file("buildSdk/android/"))
44 | rename { String fileName ->
45 | fileName.replace("release", "${version}")
46 | }
47 | }
48 |
49 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-android-loader-no-op
2 | POM_NAME=Tinker Android Loader
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangshaowen/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/src/androidTest/java/com/tencent/tinker/loader/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | import android.app.Application;
20 | import android.test.ApplicationTestCase;
21 |
22 | /**
23 | * Testing Fundamentals
24 | */
25 | public class ApplicationTest extends ApplicationTestCase {
26 | public ApplicationTest() {
27 | super(Application.class);
28 | }
29 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/entry/ApplicationLifeCycle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.entry;
18 |
19 | /**
20 | * Created by zhangshaowen on 16/3/8.
21 | */
22 |
23 |
24 | import android.app.Application;
25 | import android.content.Context;
26 | import android.content.res.Configuration;
27 |
28 | /**
29 | * This interface is used to delegate calls from main Application object.
30 | *
31 | * Implementations of this interface must have a one-argument constructor that takes
32 | * an argument of type {@link Application}.
33 | */
34 | public interface ApplicationLifeCycle {
35 |
36 | /**
37 | * Same as {@link Application#onCreate()}.
38 | */
39 | void onCreate();
40 |
41 | /**
42 | * Same as {@link Application#onLowMemory()}.
43 | */
44 | void onLowMemory();
45 |
46 | /**
47 | * Same as {@link Application#onTrimMemory(int level)}.
48 | * @param level
49 | */
50 | void onTrimMemory(int level);
51 |
52 | /**
53 | * Same as {@link Application#onTerminate()}.
54 | */
55 | void onTerminate();
56 |
57 | /**
58 | * Same as {@link Application#onConfigurationChanged(Configuration newconfig)}.
59 | */
60 | void onConfigurationChanged(Configuration newConfig);
61 |
62 | /**
63 | * Same as {@link Application#attachBaseContext(Context context)}.
64 | */
65 | void onBaseContextAttached(Context base);
66 | }
67 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/TinkerRuntimeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | /**
20 | * Created by zhangshaowen on 16/7/8.
21 | */
22 | public class TinkerRuntimeException extends RuntimeException {
23 | private static final String TINKER_RUNTIME_EXCEPTION_PREFIX = "Tinker Exception:";
24 | private static final long serialVersionUID = 1L;
25 |
26 | public TinkerRuntimeException(String detailMessage) {
27 | super(TINKER_RUNTIME_EXCEPTION_PREFIX + detailMessage);
28 | }
29 |
30 | public TinkerRuntimeException(String detailMessage, Throwable throwable) {
31 | super(TINKER_RUNTIME_EXCEPTION_PREFIX + detailMessage, throwable);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/ShareArkHotDiffPatchInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
3 | *
4 | * This program is free software; you can redistribute it and/or modify
5 | * it under the terms of the BSD 3-Clause License
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * the BSD 3-Clause License for more details.
11 | */
12 |
13 | package com.tencent.tinker.loader.shareutil;
14 |
15 | import java.util.ArrayList;
16 |
17 | public class ShareArkHotDiffPatchInfo {
18 | public String path;
19 | public String name;
20 | public String patchMd5;
21 |
22 | public ShareArkHotDiffPatchInfo(String path, String name, String md5) {
23 | this.name = name;
24 | this.patchMd5 = md5;
25 | this.path = path;
26 | }
27 |
28 | public static void parseDiffPatchInfo(String meta, ArrayList diffList) {
29 | if (meta == null || diffList == null) {
30 | return;
31 | }
32 |
33 | String[] lines = meta.split("\n");
34 | for (final String line : lines) {
35 | if (line == null || line.length() <= 0) {
36 | continue;
37 | }
38 |
39 | final String[] kv = line.split(",", 4);
40 | if (kv == null || kv.length < 3) {
41 | continue;
42 | }
43 |
44 | final String name = kv[0].trim();
45 | final String path = kv[1].trim();
46 | final String md5 = kv[2].trim();
47 |
48 | ShareArkHotDiffPatchInfo arkDiffInfo = new ShareArkHotDiffPatchInfo(path, name, md5);
49 | diffList.add(arkDiffInfo);
50 | }
51 | }
52 |
53 | public static boolean checkDiffPatchInfo(ShareArkHotDiffPatchInfo info) {
54 | if (info == null) {
55 | return false;
56 | }
57 | String name = info.name;
58 | String md5 = info.patchMd5;
59 | if (name == null || name.length() <= 0 || md5 == null || md5.length() != ShareConstants.MD5_LENGTH) {
60 | return false;
61 | }
62 | return true;
63 | }
64 |
65 | @Override
66 | public String toString() {
67 | StringBuffer sb = new StringBuffer();
68 | sb.append(name);
69 | sb.append(",");
70 | sb.append(path);
71 | sb.append(",");
72 | sb.append(patchMd5);
73 |
74 | return sb.toString();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader-no-op/src/test/java/com/tencent/tinker/loader/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
25 | */
26 | public class ExampleUnitTest {
27 | @Test
28 | public void addition_isCorrect() throws Exception {
29 | assertEquals(4, 2 + 2);
30 | }
31 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.minSdkVersion
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 |
14 | buildConfigField "String", "TINKER_VERSION", "\"${rootProject.ext.VERSION_NAME}\""
15 |
16 | manifestPlaceholders = [TINKER_VERSION: "${rootProject.ext.VERSION_NAME}"]
17 |
18 | consumerProguardFiles file('../consumer-proguard.txt')
19 | }
20 |
21 | lintOptions {
22 | disable 'LongLogTag'
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility rootProject.ext.javaVersion
27 | targetCompatibility rootProject.ext.javaVersion
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | compileOnly fileTree(dir: 'stubs', include: ['*.jar'])
34 | testImplementation 'junit:junit:4.12'
35 | implementation project(':tinker-android:tinker-android-anno-support')
36 | }
37 |
38 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
39 | group = "tinker"
40 | from("$buildDir/outputs/aar/") {
41 | include "${project.getName()}-release.aar"
42 | }
43 |
44 | into(rootProject.file("buildSdk/android/"))
45 | rename { String fileName ->
46 | fileName.replace("release", "${version}")
47 | }
48 | }
49 |
50 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
51 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-android-loader
2 | POM_NAME=Tinker Android Loader
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangshaowen/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/androidTest/java/com/tencent/tinker/loader/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | import android.app.Application;
20 | import android.test.ApplicationTestCase;
21 |
22 | /**
23 | * Testing Fundamentals
24 | */
25 | public class ApplicationTest extends ApplicationTestCase {
26 | public ApplicationTest() {
27 | super(Application.class);
28 | }
29 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/AbstractTinkerLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | import android.content.Intent;
20 |
21 | import com.tencent.tinker.loader.app.TinkerApplication;
22 |
23 |
24 | /**
25 | * Created by zhangshaowen on 16/4/30.
26 | */
27 | public abstract class AbstractTinkerLoader {
28 | abstract public Intent tryLoad(TinkerApplication app);
29 | }
30 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerResourcesKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | /**
20 | * Created by zhangshaowen on 17/1/12.
21 | *
22 | * TODO:
23 | * Thanks for Android Fragmentation
24 | * hold the issue https://github.com/Tencent/tinker/issues/302
25 | */
26 | public class TinkerResourcesKey {
27 |
28 | private static final class V24 {
29 |
30 |
31 | }
32 |
33 | private static final class V19 {
34 |
35 | }
36 |
37 | private static final class V17 {
38 |
39 | }
40 |
41 | private static final class V7 {
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerRuntimeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | /**
20 | * Created by zhangshaowen on 16/7/8.
21 | */
22 | public class TinkerRuntimeException extends RuntimeException {
23 | private static final String TINKER_RUNTIME_EXCEPTION_PREFIX = "Tinker Exception:";
24 | private static final long serialVersionUID = 1L;
25 |
26 | public TinkerRuntimeException(String detailMessage) {
27 | super(TINKER_RUNTIME_EXCEPTION_PREFIX + detailMessage);
28 | }
29 |
30 | public TinkerRuntimeException(String detailMessage, Throwable throwable) {
31 | super(TINKER_RUNTIME_EXCEPTION_PREFIX + detailMessage, throwable);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerTestDexLoad.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | import com.tencent.tinker.anno.Keep;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/9/18.
23 | */
24 | @Keep
25 | public class TinkerTestDexLoad {
26 | public static boolean isPatch = false;
27 | }
28 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/EnvConsts.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.loader.hotplug;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by tangyinsheng on 2017/8/3.
7 | */
8 |
9 | public final class EnvConsts {
10 | public static final String ACTIVITY_MANAGER_SRVNAME = Context.ACTIVITY_SERVICE;
11 | public static final String PACKAGE_MANAGER_SRVNAME = "package";
12 |
13 | public static final String INTENT_EXTRA_OLD_COMPONENT = "tinker_iek_old_component";
14 |
15 | // Please keep it synchronized with the other one defined in 'TypedValue' class
16 | public static final String INCCOMPONENT_META_FILE = "assets/inc_component_meta.txt";
17 |
18 | private EnvConsts() {
19 | throw new UnsupportedOperationException();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/UnsupportedEnvironmentException.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.loader.hotplug;
2 |
3 | /**
4 | * Created by tangyinsheng on 2017/7/31.
5 | */
6 |
7 | public class UnsupportedEnvironmentException extends UnsupportedOperationException {
8 |
9 | public UnsupportedEnvironmentException(String msg) {
10 | super(msg);
11 | }
12 |
13 | public UnsupportedEnvironmentException(Throwable thr) {
14 | super(thr);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/interceptor/InterceptFailedException.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.loader.hotplug.interceptor;
2 |
3 | /**
4 | * Created by tangyinsheng on 2017/7/31.
5 | */
6 |
7 | public class InterceptFailedException extends Exception {
8 |
9 | public InterceptFailedException(Throwable thr) {
10 | super(thr);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/interceptor/Interceptor.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.loader.hotplug.interceptor;
2 |
3 | import android.util.Log;
4 |
5 | import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
6 |
7 | /**
8 | * Created by tangyinsheng on 2017/7/31.
9 | */
10 |
11 | public abstract class Interceptor {
12 | private static final String TAG = "Tinker.Interceptor";
13 |
14 | private T_TARGET mTarget = null;
15 | private volatile boolean mInstalled = false;
16 |
17 | protected abstract T_TARGET fetchTarget() throws Throwable;
18 |
19 | protected T_TARGET decorate(T_TARGET target) throws Throwable {
20 | return target;
21 | }
22 |
23 | protected abstract void inject(T_TARGET decorated) throws Throwable;
24 |
25 | public synchronized void install() throws InterceptFailedException {
26 | try {
27 | final T_TARGET target = fetchTarget();
28 | mTarget = target;
29 | final T_TARGET decorated = decorate(target);
30 | if (decorated != target) {
31 | inject(decorated);
32 | } else {
33 | ShareTinkerLog.w(TAG, "target: " + target + " was already hooked.");
34 | }
35 | mInstalled = true;
36 | } catch (Throwable thr) {
37 | mTarget = null;
38 | throw new InterceptFailedException(thr);
39 | }
40 | }
41 |
42 | public synchronized void uninstall() throws InterceptFailedException {
43 | if (mInstalled) {
44 | try {
45 | inject(mTarget);
46 | mTarget = null;
47 | mInstalled = false;
48 | } catch (Throwable thr) {
49 | throw new InterceptFailedException(thr);
50 | }
51 | }
52 | }
53 |
54 | protected interface ITinkerHotplugProxy {
55 | // Marker interface for proxy objects created by tinker.
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareArkHotDiffPatchInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
3 | *
4 | * This program is free software; you can redistribute it and/or modify
5 | * it under the terms of the BSD 3-Clause License
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * the BSD 3-Clause License for more details.
11 | */
12 |
13 | package com.tencent.tinker.loader.shareutil;
14 |
15 | import java.util.ArrayList;
16 |
17 | public class ShareArkHotDiffPatchInfo {
18 | public String path;
19 | public String name;
20 | public String patchMd5;
21 |
22 | public ShareArkHotDiffPatchInfo(String path, String name, String md5) {
23 | this.name = name;
24 | this.patchMd5 = md5;
25 | this.path = path;
26 | }
27 |
28 | public static void parseDiffPatchInfo(String meta, ArrayList diffList) {
29 | if (meta == null || diffList == null) {
30 | return;
31 | }
32 |
33 | String[] lines = meta.split("\n");
34 | for (final String line : lines) {
35 | if (line == null || line.length() <= 0) {
36 | continue;
37 | }
38 |
39 | final String[] kv = line.split(",", 4);
40 | if (kv == null || kv.length < 3) {
41 | continue;
42 | }
43 |
44 | final String name = kv[0].trim();
45 | final String path = kv[1].trim();
46 | final String md5 = kv[2].trim();
47 |
48 | ShareArkHotDiffPatchInfo arkDiffInfo = new ShareArkHotDiffPatchInfo(path, name, md5);
49 | diffList.add(arkDiffInfo);
50 | }
51 | }
52 |
53 | public static boolean checkDiffPatchInfo(ShareArkHotDiffPatchInfo info) {
54 | if (info == null) {
55 | return false;
56 | }
57 | String name = info.name;
58 | String md5 = info.patchMd5;
59 | if (name == null || name.length() <= 0 || md5 == null || md5.length() != ShareConstants.MD5_LENGTH) {
60 | return false;
61 | }
62 | return true;
63 | }
64 |
65 | @Override
66 | public String toString() {
67 | StringBuffer sb = new StringBuffer();
68 | sb.append(name);
69 | sb.append(",");
70 | sb.append(path);
71 | sb.append(",");
72 | sb.append(patchMd5);
73 |
74 | return sb.toString();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/src/test/java/com/tencent/tinker/loader/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.loader;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
25 | */
26 | public class ExampleUnitTest {
27 | @Test
28 | public void addition_isCorrect() throws Exception {
29 | assertEquals(4, 2 + 2);
30 | }
31 | }
--------------------------------------------------------------------------------
/tinker-android/tinker-android-loader/stubs/sysapi-access-stub.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-android/tinker-android-loader/stubs/sysapi-access-stub.jar
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /tool_output/*.apk
3 | /tool_output/TinkerPatch
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | apply plugin: "com.github.johnrengelman.shadow"
3 |
4 | version rootProject.ext.VERSION_NAME
5 | group rootProject.ext.GROUP
6 |
7 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
8 |
9 | sourceCompatibility = rootProject.ext.javaVersion
10 | targetCompatibility = rootProject.ext.javaVersion
11 |
12 | dependencies {
13 | implementation fileTree(dir: 'libs', include: ['*.jar'])
14 | implementation project(':tinker-build:tinker-patch-lib')
15 | }
16 |
17 | jar {
18 | manifest {
19 | attributes 'Main-Class': 'com.tencent.tinker.patch.CliMain'
20 | attributes 'Manifest-Version': version
21 | }
22 | }
23 |
24 | // copy the jar to work directory
25 | task buildTinkerSdk(type: Copy, dependsOn: [clean, shadowJar]) {
26 | group = "tinker"
27 | from('build/libs') {
28 | include '*.jar'
29 | exclude '*-javadoc.jar'
30 | exclude '*-sources.jar'
31 | }
32 | from('./tool_output') {
33 | include '*.*'
34 | }
35 | into(rootProject.file("buildSdk/build"))
36 | }
37 |
38 | defaultTasks 'buildTinkerSdk'
39 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/src/main/java/com/tencent/tinker/patch/Test.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.patch;
2 |
3 | import com.tencent.tinker.build.dexpatcher.DexPatchGenerator;
4 | import com.tencent.tinker.build.util.DexClassesComparator;
5 | import com.tencent.tinker.commons.dexpatcher.DexPatchApplier;
6 |
7 | import java.io.File;
8 |
9 | public class Test {
10 | public static void main(String[] args) throws Throwable {
11 | final File oldDexFile = new File("/Users/tomystang/dexdiff_test/base.dex");
12 | final File newDexFile = new File("/Users/tomystang/dexdiff_test/new.dex");
13 | final File patchFile = new File("/Users/tomystang/dexdiff_test/patch.dexdiff");
14 | final File patchedDexFile = new File("/Users/tomystang/dexdiff_test/new_patched.dex");
15 |
16 | final DexPatchGenerator dg = new DexPatchGenerator(oldDexFile, newDexFile);
17 | dg.addAdditionalRemovingClassPattern("com.tencent.tinker.loader.*");
18 | dg.executeAndSaveTo(patchFile);
19 |
20 | final DexPatchApplier da = new DexPatchApplier(oldDexFile, patchFile);
21 | da.executeAndSaveTo(patchedDexFile);
22 |
23 | final DexClassesComparator dcc = new DexClassesComparator("*");
24 | dcc.setIgnoredRemovedClassDescPattern("com.tencent.tinker.loader.*");
25 | dcc.setCompareMode(DexClassesComparator.COMPARE_MODE_NORMAL);
26 | dcc.startCheck(newDexFile, patchedDexFile);
27 | System.out.println("add classes: " + dcc.getAddedClassInfos());
28 | System.out.println("del classes: " + dcc.getDeletedClassInfos());
29 | System.out.println("changed classes: " + dcc.getChangedClassDescToInfosMap());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/tool_maple/DexCmp.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-build/tinker-patch-cli/tool_maple/DexCmp.jar
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/tool_maple/build_patch_dexdiff.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | helpme()
3 | {
4 | echo "Build patch zip"
5 | echo "USAGE:"
6 | echo " ./build_patch_dexdiff.sh [old=old.apk path] [new=new.apk path]"
7 | echo "EXAMPLE:"
8 | echo " ./build_patch_dexdiff.sh old=/old.apk new=/new.apk"
9 | exit 1
10 | }
11 |
12 | parse_cmdline()
13 | {
14 | while [[ -n "$1" ]]
15 | do
16 | OPTIONS=`echo "$1" | sed 's/\(.*\)=\(.*\)/\1/'`
17 | PARAM=`echo "$1" | sed 's/.*=//'`
18 | if [[ "$1" != *=* ]];then
19 | helpme
20 | CHECK_FLAG=0
21 | fi
22 | case "$OPTIONS" in
23 | old) OLD_APK_PATH=${PARAM};;
24 | new) NEW_APK_PATH=${PARAM};;
25 | #please add extra parameter here!
26 | *) if [[ `echo "$1" | sed -n "/.*=/p"` ]];then
27 | echo "Error, the pattem \"$OPTIONS=${PARAM}\" can not be recognized!!!"
28 | helpme
29 | fi
30 | break;;
31 | esac
32 | shift
33 | done
34 | COMMAND_ARGS=$@
35 | }
36 |
37 | initParameter()
38 | {
39 | OLD_FILE=`pwd`/old_file
40 | NEW_FILE=`pwd`/new_file
41 | }
42 |
43 | dexdiff()
44 | {
45 | mkdir ${OLD_FILE}
46 | pushd ${OLD_FILE}
47 | unzip -o ${OLD_APK_PATH} -d ${OLD_FILE}
48 | OLD_DEX_COUNT=`ls | grep classes | wc -l`
49 | OLD_DEX_SET=${OLD_FILE}/classes.dex
50 | for count in `seq 2 ${OLD_DEX_COUNT}`
51 | do
52 | OLD_DEX_SET="${OLD_DEX_SET} ${OLD_FILE}/classes$count.dex"
53 | done
54 | popd
55 |
56 | mkdir ${NEW_FILE}
57 | pushd ${NEW_FILE}
58 | unzip -o ${NEW_APK_PATH} -d ${NEW_FILE}
59 | NEW_DEX_COUNT=`ls | grep classes | wc -l`
60 | NEW_DEX_SET=${NEW_FILE}/classes.dex
61 | for count in `seq 2 ${NEW_DEX_COUNT}`
62 | do
63 | NEW_DEX_SET="${NEW_DEX_SET} ${NEW_FILE}/classes$count.dex"
64 | done
65 | popd
66 |
67 | dexcmp -n ${NEW_DEX_SET} -o ${OLD_DEX_SET} -f `pwd`/patch.dex
68 | }
69 |
70 | dexcmp()
71 | {
72 | java -cp "./DexCmp.jar" "io.qivaz.dex.cmp.DexCmp" "$@"
73 | }
74 |
75 | zipPatch()
76 | {
77 | zip -m0 patch.apk ./patch.dex
78 | zip -m0 patch.apk ./new_file/classes.dex
79 | for count in `seq 2 ${NEW_DEX_COUNT}`
80 | do
81 | zip -m0 patch.apk ./new_file/classes${count}.dex
82 | done
83 | }
84 |
85 | parse_cmdline $@
86 | initParameter
87 | dexdiff
88 | zipPatch
89 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/tool_output/release.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-build/tinker-patch-cli/tool_output/release.keystore
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/tool_output/tinker_multidexkeep.pro:
--------------------------------------------------------------------------------
1 | #tinker multidex keep patterns:
2 | -keep public class * implements com.tencent.tinker.entry.ApplicationLifeCycle {
3 | ();
4 | void onBaseContextAttached(android.content.Context);
5 | }
6 |
7 | -keep public class * implements com.tencent.tinker.loader.app.ITinkerInlineFenceBridge {
8 | (...);
9 | void attachBaseContext(com.tencent.tinker.loader.app.TinkerApplication, android.content.Context);
10 | }
11 |
12 | -keep public class * extends com.tencent.tinker.loader.TinkerLoader {
13 | ();
14 | }
15 |
16 | -keep public class * extends android.app.Application {
17 | ();
18 | void attachBaseContext(android.content.Context);
19 | }
20 |
21 | -keep public class com.tencent.tinker.loader.NewClassLoaderInjector {
22 | *;
23 | }
24 |
25 | -keep class com.tencent.tinker.loader.NewClassLoaderInjector$DispatchClassLoader {
26 | *;
27 | }
28 |
29 | -keep class com.tencent.tinker.entry.TinkerApplicationInlineFence {
30 | *;
31 | }
32 |
33 | -keep class com.tencent.tinker.loader.app.TinkerInlineFenceAction {
34 | *;
35 | }
36 |
37 | #your dex.loader patterns here
38 | -keep class tinker.sample.android.app.SampleApplication {
39 | ();
40 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-cli/tool_output/tinker_proguard.pro:
--------------------------------------------------------------------------------
1 | #-applymapping "old apk mapping here"
2 |
3 | -keepattributes *Annotation*
4 | -dontwarn com.tencent.tinker.anno.AnnotationProcessor
5 | -keep @com.tencent.tinker.anno.DefaultLifeCycle public class *
6 | -keep public class * extends android.app.Application {
7 | *;
8 | }
9 |
10 | -keep public class com.tencent.tinker.entry.ApplicationLifeCycle {
11 | *;
12 | }
13 | -keep public class * implements com.tencent.tinker.entry.ApplicationLifeCycle {
14 | *;
15 | }
16 |
17 | -keep public class com.tencent.tinker.loader.TinkerLoader {
18 | *;
19 | }
20 | -keep public class * extends com.tencent.tinker.loader.TinkerLoader {
21 | *;
22 | }
23 |
24 | -keep public class com.tencent.tinker.loader.TinkerTestDexLoad {
25 | *;
26 | }
27 |
28 | -keep public class com.tencent.tinker.loader.TinkerTestDexLoad {
29 | *;
30 | }
31 |
32 | -keep public class com.tencent.tinker.entry.TinkerApplicationInlineFence {
33 | *;
34 | }
35 |
36 | #for command line version, we must keep all the loader class to avoid proguard mapping conflict
37 | #your dex.loader pattern here
38 | -keep public class com.tencent.tinker.loader.** {
39 | *;
40 | }
41 |
42 | -keep class tinker.sample.android.app.SampleApplication {
43 | *;
44 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'groovy'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | sourceCompatibility = rootProject.ext.javaVersion
7 | targetCompatibility = rootProject.ext.javaVersion
8 |
9 | dependencies {
10 | implementation gradleApi()
11 | implementation localGroovy()
12 | // implementation fileTree(dir: 'libs', include: ['*.jar'])
13 | implementation project(':tinker-build:tinker-patch-lib')
14 | implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.0'
15 | implementation 'commons-codec:commons-codec:1.10'
16 | compileOnly 'com.android.tools.build:gradle:4.2.0'
17 | }
18 |
19 | repositories {
20 | mavenCentral()
21 | }
22 |
23 | sourceSets {
24 | main {
25 | groovy {
26 | srcDir 'src/main/groovy'
27 | }
28 |
29 | resources {
30 | srcDir 'src/main/resources'
31 | }
32 | }
33 | }
34 |
35 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
36 |
37 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-patch-gradle-plugin
2 | POM_NAME=Tinker Patch Gradle Plugin
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/src/main/groovy/com/tencent/tinker/build/gradle/extension/TinkerArkHotExtension.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
3 | *
4 | * This program is free software; you can redistribute it and/or modify
5 | * it under the terms of the BSD 3-Clause License
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * the BSD 3-Clause License for more details.
11 | */
12 |
13 | package com.tencent.tinker.build.gradle.extension
14 |
15 | public class TinkerArkHotExtension {
16 | String path;
17 | String name;
18 |
19 | public TinkerArkHotExtension() {
20 | path = "arkHot";
21 | name = "patch.apk";
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | """| path= ${path}
27 | | name= ${name}
28 | """.stripMargin()
29 | }
30 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/src/main/groovy/com/tencent/tinker/build/gradle/extension/TinkerDexExtension.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.gradle.extension
18 |
19 | import org.gradle.api.GradleException
20 | import org.gradle.api.Project
21 |
22 | /**
23 | * The configuration properties.
24 | *
25 | * @author zhangshaowen
26 | */
27 |
28 | public class TinkerDexExtension {
29 | /**
30 | * raw or jar, if you want to support below 4.0, you should use jar
31 | * default: raw, keep the orginal file type
32 | */
33 | String dexMode;
34 |
35 | /**
36 | * the dex file patterns, which dex or jar files will be deal to gen patch
37 | * such as [classes.dex, classes-*.dex, assets/multiDex/*.jar]
38 | */
39 | Iterable pattern;
40 | /**
41 | * the loader files, they will be removed during gen patch main dex
42 | * and they should be at the primary dex
43 | * such as [com.tencent.tinker.loader.*, com.tinker.sample.MyApplication]
44 | */
45 | Iterable loader;
46 |
47 | Iterable ignoreWarningLoader;
48 |
49 | private Project project;
50 |
51 | public TinkerDexExtension(Project project) {
52 | dexMode = "jar"
53 | pattern = []
54 | loader = []
55 | ignoreWarningLoader = []
56 | this.project = project
57 | }
58 |
59 | void checkDexMode() {
60 | if (!dexMode.equals("raw") && !dexMode.equals("jar")) {
61 | throw new GradleException("dexMode can be only one of 'jar' or 'raw'!")
62 | }
63 | }
64 |
65 | @Override
66 | public String toString() {
67 | """| dexMode = ${dexMode}
68 | | pattern = ${pattern}
69 | | loader = ${loader}
70 | | ignoreWarningLoader = ${ignoreWarningLoader}
71 | """.stripMargin()
72 | }
73 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/src/main/groovy/com/tencent/tinker/build/gradle/extension/TinkerLibExtension.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.gradle.extension
18 | /**
19 | * The configuration properties.
20 | *
21 | * @author zhangshaowen
22 | */
23 |
24 | public class TinkerLibExtension {
25 | /**
26 | * the library file patterns, which files will be deal to gen patch
27 | * such as [lib/armeabi/*.so, assets/libs/*.so]
28 | */
29 | Iterable pattern;
30 |
31 |
32 | public TinkerLibExtension() {
33 | pattern = []
34 | }
35 |
36 | @Override
37 | public String toString() {
38 | """| pattern = ${pattern}
39 | """.stripMargin()
40 | }
41 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/src/main/groovy/com/tencent/tinker/build/gradle/extension/TinkerResourceExtension.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.gradle.extension
18 |
19 | import org.gradle.api.GradleException
20 |
21 | /**
22 | * The configuration properties.
23 | *
24 | * @author liangwenxiang
25 | */
26 |
27 | public class TinkerResourceExtension {
28 | /**
29 | * the resource file patterns, which files will be deal to gen patch
30 | * such as [res/*, assets/*, resources.arsc]
31 | */
32 | Iterable pattern
33 | /**
34 | * the resource file ignoreChange patterns, ignore add, delete or modify resource change
35 | * Warning, we can only use for files no relative with resources.arsc
36 | */
37 | Iterable ignoreChange
38 |
39 | /**
40 | * the resource file ignoreChangeWarning patterns, ignore any warning caused by add, delete or
41 | * modify resource change.
42 | */
43 | Iterable ignoreChangeWarning
44 |
45 | /**
46 | * default 100kb
47 | * for modify resource, if it is larger than 'largeModSize'
48 | * we would like to use bsdiff algorithm to reduce patch file size
49 | */
50 | int largeModSize
51 |
52 | public TinkerResourceExtension() {
53 | pattern = []
54 | ignoreChange = []
55 | ignoreChangeWarning = []
56 | largeModSize = 100
57 | }
58 | void checkParameter() {
59 | if (largeModSize <= 0) {
60 | throw new GradleException("largeModSize must be larger than 0")
61 | }
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | """| pattern = ${pattern}
67 | | exclude = ${ignoreChange}
68 | | ignoreWarning = ${ignoreChangeWarning}
69 | | largeModSize = ${largeModSize}kb
70 | """.stripMargin()
71 | }
72 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.tencent.tinker.patch.properties:
--------------------------------------------------------------------------------
1 | implementation-class=com.tencent.tinker.build.gradle.TinkerPatchPlugin
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | sourceCompatibility = rootProject.ext.javaVersion
9 | targetCompatibility = rootProject.ext.javaVersion
10 |
11 | dependencies {
12 | implementation fileTree(dir: 'libs', include: ['*.jar'])
13 | api project(':tinker-commons')
14 | api group: 'com.tencent.mm', name: 'apk-parser-lib', version: '1.2.3'
15 | implementation group: 'com.google.guava', name: 'guava', version: '14.0.1'
16 | implementation group: 'org.ow2.asm', name: 'asm', version: '6.0'
17 | implementation (group: 'org.smali', name: 'dexlib2', version: '2.3.1') {
18 | exclude group: 'com.google.guava'
19 | }
20 | implementation group: 'dom4j', name: 'dom4j', version: '1.6.1'
21 | }
22 |
23 | sourceSets {
24 | main {
25 | java {
26 | srcDir 'src/main/java'
27 | }
28 |
29 | resources {
30 | srcDir 'src/main/resources'
31 | }
32 | }
33 | }
34 |
35 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
36 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-patch-lib
2 | POM_NAME=Tinker Patch Lib
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/aapt/FakeRDotTxtEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-present Facebook, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 | * not use this file except in compliance with the License. You may obtain
6 | * 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, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.aapt;
18 |
19 | /**
20 | * An {@link RDotTxtEntry} with fake {@link #idValue}, useful for comparing two resource entries for
21 | * equality, since {@link RDotTxtEntry#compareTo(RDotTxtEntry)} ignores the id value.
22 | */
23 | public class FakeRDotTxtEntry extends RDotTxtEntry {
24 |
25 | private static final String FAKE_ID = "0x00000000";
26 |
27 | public FakeRDotTxtEntry(IdType idType, RType type, String name) {
28 | super(idType, type, name, FAKE_ID);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/aapt/FileCopyException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-present Facebook, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 | * not use this file except in compliance with the License. You may obtain
6 | * 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, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.aapt;
18 |
19 | public class FileCopyException extends RuntimeException {
20 |
21 | /**
22 | * serialVersionUID
23 | */
24 | private static final long serialVersionUID = -6670157031514003361L;
25 |
26 | /**
27 | * @param message
28 | */
29 | public FileCopyException(String message) {
30 | super(message);
31 | }
32 |
33 | /**
34 | * @param cause
35 | */
36 | public FileCopyException(Throwable cause) {
37 | super(cause);
38 | }
39 |
40 | /**
41 | * @param message
42 | * @param cause
43 | */
44 | public FileCopyException(String message, Throwable cause) {
45 | super(message, cause);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/aapt/ResourceDirectory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-present Facebook, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 | * not use this file except in compliance with the License. You may obtain
6 | * 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, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.aapt;
18 |
19 | import java.util.Arrays;
20 | import java.util.HashSet;
21 | import java.util.Set;
22 |
23 | public class ResourceDirectory {
24 |
25 | public String directoryName = null;
26 | public String resourceFullFilename = null;
27 | public Set resourceEntrySet = new HashSet();
28 |
29 | public ResourceDirectory(String directoryName, String resourceFullFilename) {
30 | this.directoryName = directoryName;
31 | this.resourceFullFilename = resourceFullFilename;
32 | }
33 |
34 | public int hashCode() {
35 | return Arrays.hashCode(new Object[]{this.directoryName, this.resourceFullFilename});
36 | }
37 |
38 |
39 | public boolean equals(Object object) {
40 | if (!(object instanceof ResourceDirectory)) {
41 | return false;
42 | }
43 | ResourceDirectory that = (ResourceDirectory) object;
44 | return ObjectUtil.equal(this.directoryName, that.directoryName) && ObjectUtil.equal(this.resourceFullFilename, that.resourceFullFilename);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/aapt/ResourceEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-present Facebook, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 | * not use this file except in compliance with the License. You may obtain
6 | * 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, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.aapt;
18 |
19 | import java.util.Arrays;
20 |
21 | public class ResourceEntry {
22 |
23 | public String name = null;
24 | public String value = null;
25 |
26 | public ResourceEntry(String name, String value) {
27 | this.name = name;
28 | this.value = value;
29 | }
30 |
31 | public int hashCode() {
32 | return Arrays.hashCode(new Object[]{this.name});
33 | }
34 |
35 |
36 | public boolean equals(Object object) {
37 | if (!(object instanceof ResourceEntry)) {
38 | return false;
39 | }
40 | ResourceEntry that = (ResourceEntry) object;
41 | return ObjectUtil.equal(this.name, that.name);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/decoder/UniqueDexDiffDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.decoder;
18 |
19 | import com.tencent.tinker.build.patch.Configuration;
20 | import com.tencent.tinker.build.util.TinkerPatchException;
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 | import java.util.ArrayList;
25 |
26 | /**
27 | * Created by zhangshaowen on 16/3/9.
28 | */
29 | public class UniqueDexDiffDecoder extends DexDiffDecoder {
30 | private ArrayList addedDexFiles;
31 |
32 | public UniqueDexDiffDecoder(Configuration config, String metaPath, String logPath) throws IOException {
33 | super(config, metaPath, logPath);
34 | addedDexFiles = new ArrayList<>();
35 | }
36 |
37 | @Override
38 | public boolean patch(File oldFile, File newFile) throws IOException, TinkerPatchException {
39 | boolean added = super.patch(oldFile, newFile);
40 | if (added) {
41 | String name = newFile.getName();
42 | if (addedDexFiles.contains(name)) {
43 | throw new TinkerPatchException("illegal dex name, dex name should be unique, dex:" + name);
44 | } else {
45 | addedDexFiles.add(name);
46 | }
47 | }
48 | return added;
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/dexpatcher/algorithms/diff/CallSiteIdSectionDiffAlgorithm.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.build.dexpatcher.algorithms.diff;
2 |
3 | import com.tencent.tinker.android.dex.CallSiteId;
4 | import com.tencent.tinker.android.dex.Dex;
5 | import com.tencent.tinker.android.dex.TableOfContents;
6 | import com.tencent.tinker.android.dex.io.DexDataBuffer;
7 | import com.tencent.tinker.commons.dexpatcher.util.AbstractIndexMap;
8 | import com.tencent.tinker.commons.dexpatcher.util.SparseIndexMap;
9 |
10 | public class CallSiteIdSectionDiffAlgorithm extends DexSectionDiffAlgorithm {
11 | public CallSiteIdSectionDiffAlgorithm(Dex oldDex, Dex newDex, SparseIndexMap oldToNewIndexMap,
12 | SparseIndexMap oldToPatchedIndexMap, SparseIndexMap newToPatchedIndexMap,
13 | SparseIndexMap selfIndexMapForSkip) {
14 | super(oldDex, newDex, oldToNewIndexMap, oldToPatchedIndexMap, newToPatchedIndexMap, selfIndexMapForSkip);
15 | }
16 |
17 | @Override
18 | protected TableOfContents.Section getTocSection(Dex dex) {
19 | return dex.getTableOfContents().callSiteIds;
20 | }
21 |
22 | @Override
23 | protected CallSiteId nextItem(DexDataBuffer section) {
24 | return section.readCallSiteId();
25 | }
26 |
27 | @Override
28 | protected int getItemSize(CallSiteId item) {
29 | return item.byteCountInDex();
30 | }
31 |
32 | @Override
33 | protected CallSiteId adjustItem(AbstractIndexMap indexMap, CallSiteId item) {
34 | return indexMap.adjust(item);
35 | }
36 |
37 | @Override
38 | protected void updateIndexOrOffset(SparseIndexMap sparseIndexMap, int oldIndex, int oldOffset, int newIndex, int newOffset) {
39 | sparseIndexMap.mapCallsiteIds(oldIndex, newIndex);
40 | }
41 |
42 | @Override
43 | protected void markDeletedIndexOrOffset(SparseIndexMap sparseIndexMap, int deletedIndex, int deletedOffset) {
44 | sparseIndexMap.markCallsiteDeleted(deletedIndex);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/dexpatcher/algorithms/diff/MethodHandleSectionDiffAlgorithm.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.build.dexpatcher.algorithms.diff;
2 |
3 | import com.tencent.tinker.android.dex.Dex;
4 | import com.tencent.tinker.android.dex.MethodHandle;
5 | import com.tencent.tinker.android.dex.TableOfContents;
6 | import com.tencent.tinker.android.dex.io.DexDataBuffer;
7 | import com.tencent.tinker.commons.dexpatcher.util.AbstractIndexMap;
8 | import com.tencent.tinker.commons.dexpatcher.util.SparseIndexMap;
9 |
10 | public class MethodHandleSectionDiffAlgorithm extends DexSectionDiffAlgorithm {
11 | public MethodHandleSectionDiffAlgorithm(Dex oldDex, Dex newDex, SparseIndexMap oldToNewIndexMap,
12 | SparseIndexMap oldToPatchedIndexMap, SparseIndexMap newToPatchedIndexMap,
13 | SparseIndexMap selfIndexMapForSkip) {
14 | super(oldDex, newDex, oldToNewIndexMap, oldToPatchedIndexMap, newToPatchedIndexMap, selfIndexMapForSkip);
15 | }
16 |
17 | @Override
18 | protected TableOfContents.Section getTocSection(Dex dex) {
19 | return dex.getTableOfContents().methodHandles;
20 | }
21 |
22 | @Override
23 | protected MethodHandle nextItem(DexDataBuffer section) {
24 | return section.readMethodHandle();
25 | }
26 |
27 | @Override
28 | protected int getItemSize(MethodHandle item) {
29 | return item.byteCountInDex();
30 | }
31 |
32 | @Override
33 | protected MethodHandle adjustItem(AbstractIndexMap indexMap, MethodHandle item) {
34 | return indexMap.adjust(item);
35 | }
36 |
37 | @Override
38 | protected void updateIndexOrOffset(SparseIndexMap sparseIndexMap, int oldIndex, int oldOffset, int newIndex, int newOffset) {
39 | sparseIndexMap.mapMethodHandleIds(oldIndex, newIndex);
40 | }
41 |
42 | @Override
43 | protected void markDeletedIndexOrOffset(SparseIndexMap sparseIndexMap, int deletedIndex, int deletedOffset) {
44 | sparseIndexMap.markMethodHandleDeleted(deletedIndex);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/immutable/DexRefData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.immutable;
18 |
19 | import java.util.HashSet;
20 | import java.util.Set;
21 |
22 | public class DexRefData {
23 | int methodNum;
24 | int fieldNum;
25 | public Set refFields;
26 | public Set refMtds;
27 |
28 | DexRefData() {
29 | this(0, 0);
30 | }
31 |
32 | DexRefData(int methodNum, int fieldNum) {
33 | this.methodNum = methodNum;
34 | this.fieldNum = fieldNum;
35 | refFields = new HashSet<>();
36 | refMtds = new HashSet<>();
37 | }
38 | }
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/info/PatchInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.info;
18 |
19 | import com.tencent.tinker.build.patch.Configuration;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/3/8.
23 | */
24 | public class PatchInfo {
25 |
26 | private final PatchInfoGen infoGen;
27 |
28 |
29 | public PatchInfo(Configuration config) {
30 | infoGen = new PatchInfoGen(config);
31 | }
32 |
33 |
34 | /**
35 | * gen the meta file txt
36 | * such as rev, version ...
37 | * file version, hotpatch version class
38 | */
39 | public void gen() throws Exception {
40 | infoGen.gen();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/util/DiffFactory.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.build.util;
2 |
3 | import com.tencent.tinker.bsdiff.BSDiff;
4 | import com.tencent.tinker.build.patch.Configuration;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.io.InputStreamReader;
10 |
11 | public class DiffFactory {
12 |
13 | private static boolean diffShellPermission = false;
14 |
15 | public static void diffFile(Configuration config, File oldFile, File newFile, File diffFile) throws IOException {
16 | Logger.d("path:" + config.mCustomDiffPath + " oldFile:" + oldFile.getPath());
17 | if (CustomDiff.checkHasCustomDiff(config)) {
18 | if (!diffShellPermission) {
19 | diffShellPermission = true;
20 | makeSurePermission(config.mCustomDiffPath);
21 | }
22 | CustomDiff.diffFile(config.mCustomDiffPath, config.mCustomDiffPathArgs, oldFile, newFile, diffFile);
23 | } else {
24 | BSDiff.bsdiff(oldFile, newFile, diffFile);
25 | }
26 | }
27 |
28 | private static void makeSurePermission(String path) throws IOException {
29 | try {
30 | Process process = new ProcessBuilder("chmod", "777", path.split(" ")[0]).start();
31 | BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
32 | String line;
33 | while ((line = br.readLine()) != null) {
34 | Logger.d(line);
35 | }
36 | int exitCode = process.waitFor();
37 | Logger.d("run makeSurePermission done, exitCode: " + exitCode);
38 | process.destroy();
39 | } catch (InterruptedException e) {
40 | e.printStackTrace();
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/util/Logger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.util;
18 |
19 | import com.tencent.tinker.build.info.InfoWriter;
20 | import com.tencent.tinker.build.patch.Configuration;
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 |
25 | /**
26 | * Created by zhangshaowen on 16/4/7.
27 | */
28 | public class Logger {
29 | private static InfoWriter logWriter;
30 |
31 | public static void initLogger(Configuration config) throws IOException {
32 | String logPath = config.mOutFolder + File.separator + TypedValue.FILE_LOG;
33 | logWriter = new InfoWriter(config, logPath);
34 | }
35 |
36 | public static void closeLogger() {
37 | if (logWriter != null) {
38 | logWriter.close();
39 | }
40 | }
41 |
42 | public static void d(final String msg) {
43 | Logger.d("%s", msg);
44 | }
45 |
46 | public static void d(final String format, final Object... obj) {
47 |
48 | String log = obj.length == 0 ? format : String.format(format, obj);
49 | if (log == null) {
50 | log = "";
51 | }
52 | System.out.println(log);
53 | System.out.flush();
54 |
55 | logWriter.writeLineToInfoFile(log);
56 | }
57 |
58 | public static void e(final String msg) {
59 | Logger.e("%s", msg);
60 | }
61 |
62 | public static void e(final String format, final Object... obj) {
63 | String log = obj.length == 0 ? format : String.format(format, obj);
64 | if (log == null) {
65 | log = "";
66 | }
67 | System.err.println(log);
68 | System.err.flush();
69 |
70 | logWriter.writeLineToInfoFile(log);
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/util/TinkerPatchException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.build.util;
18 |
19 |
20 | /**
21 | * @author zhangshaowen
22 | */
23 | public class TinkerPatchException extends RuntimeException {
24 | private static final long serialVersionUID = 1L;
25 |
26 | public TinkerPatchException() {
27 | }
28 |
29 | public TinkerPatchException(String message) {
30 | super(message);
31 | }
32 |
33 | public TinkerPatchException(String message, Throwable cause) {
34 | super(message, cause);
35 | }
36 |
37 | public TinkerPatchException(Throwable cause) {
38 | super(cause);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/resources/only_use_to_test_tinker_resource.txt:
--------------------------------------------------------------------------------
1 | #tinker resource changed
--------------------------------------------------------------------------------
/tinker-build/tinker-patch-lib/src/main/resources/test.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-build/tinker-patch-lib/src/main/resources/test.dex
--------------------------------------------------------------------------------
/tinker-commons/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tinker-commons/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | version rootProject.ext.VERSION_NAME
4 | group rootProject.ext.GROUP
5 |
6 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
7 |
8 | sourceCompatibility = rootProject.ext.javaVersion
9 | targetCompatibility = rootProject.ext.javaVersion
10 |
11 | dependencies {
12 | implementation fileTree(dir: 'libs', include: ['*.jar'])
13 | api project(':third-party:aosp-dexutils')
14 | api project(':third-party:bsdiff-util')
15 | api project(':third-party:tinker-ziputils')
16 | }
17 |
18 | task buildTinkerSdk(type: Copy, dependsOn: [build]) {
19 | group = "tinker"
20 | from('build/libs') {
21 | include '*.jar'
22 | exclude '*javadoc.jar'
23 | exclude '*-sources.jar'
24 | }
25 | into(rootProject.file("buildSdk/android"))
26 | }
27 |
28 | apply from: rootProject.file('gradle/PublishArtifact.gradle')
--------------------------------------------------------------------------------
/tinker-commons/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_ARTIFACT_ID=tinker-commons
2 | POM_NAME=Tinker Common libs
3 | POM_PACKAGING=jar
--------------------------------------------------------------------------------
/tinker-commons/src/main/java/com/tencent/tinker/commons/dexpatcher/DexPatcherLogger.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.commons.dexpatcher;
2 |
3 | /**
4 | * Created by tangyinsheng on 2016/9/18.
5 | */
6 |
7 | public final class DexPatcherLogger {
8 | private IDexPatcherLogger loggerImpl = null;
9 |
10 | public IDexPatcherLogger getLoggerImpl() {
11 | return this.loggerImpl;
12 | }
13 |
14 | public void setLoggerImpl(IDexPatcherLogger dexPatcherLogger) {
15 | this.loggerImpl = dexPatcherLogger;
16 | }
17 |
18 | public void v(String tag, String fmt, Object... vals) {
19 | if (this.loggerImpl != null) {
20 | fmt = "[V][" + tag + "] " + fmt;
21 | this.loggerImpl.v((vals == null || vals.length == 0) ? fmt : String.format(fmt, vals));
22 | }
23 | }
24 |
25 | public void d(String tag, String fmt, Object... vals) {
26 | if (this.loggerImpl != null) {
27 | fmt = "[D][" + tag + "] " + fmt;
28 | this.loggerImpl.d((vals == null || vals.length == 0) ? fmt : String.format(fmt, vals));
29 | }
30 | }
31 |
32 | public void i(String tag, String fmt, Object... vals) {
33 | if (this.loggerImpl != null) {
34 | fmt = "[I][" + tag + "] " + fmt;
35 | this.loggerImpl.i((vals == null || vals.length == 0) ? fmt : String.format(fmt, vals));
36 | }
37 | }
38 |
39 | public void w(String tag, String fmt, Object... vals) {
40 | if (this.loggerImpl != null) {
41 | fmt = "[W][" + tag + "] " + fmt;
42 | this.loggerImpl.w((vals == null || vals.length == 0) ? fmt : String.format(fmt, vals));
43 | }
44 | }
45 |
46 | public void e(String tag, String fmt, Object... vals) {
47 | if (this.loggerImpl != null) {
48 | fmt = "[E][" + tag + "] " + fmt;
49 | this.loggerImpl.e((vals == null || vals.length == 0) ? fmt : String.format(fmt, vals));
50 | }
51 | }
52 |
53 |
54 | public interface IDexPatcherLogger {
55 | void v(String msg);
56 |
57 | void d(String msg);
58 |
59 | void i(String msg);
60 |
61 | void w(String msg);
62 |
63 | void e(String msg);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/tinker-commons/src/main/java/com/tencent/tinker/commons/dexpatcher/struct/PatchOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tencent.tinker.commons.dexpatcher.struct;
18 |
19 | /**
20 | * Created by tangyinsheng on 2016/6/29.
21 | */
22 | public final class PatchOperation {
23 | public static final int OP_DEL = 0;
24 | public static final int OP_ADD = 1;
25 | public static final int OP_REPLACE = 2;
26 |
27 | public int op;
28 | public int index;
29 | public T newItem;
30 |
31 | public PatchOperation(int op, int index) {
32 | this(op, index, null);
33 | }
34 |
35 | public PatchOperation(int op, int index, T newItem) {
36 | this.op = op;
37 | this.index = index;
38 | this.newItem = newItem;
39 | }
40 |
41 | public static String translateOpToString(int op) {
42 | switch (op) {
43 | case OP_DEL:
44 | return "OP_DEL";
45 | case OP_ADD:
46 | return "OP_ADD";
47 | case OP_REPLACE:
48 | return "OP_REPLACE";
49 | default:
50 | return "OP_UNKNOWN";
51 | }
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | StringBuilder sb = new StringBuilder();
57 | String opDesc = translateOpToString(op);
58 | sb.append('{');
59 | sb.append("op: ").append(opDesc).append(", index: ").append(index).append(", newItem: ").append(newItem);
60 | sb.append('}');
61 | return sb.toString();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/tinker-commons/src/main/java/com/tencent/tinker/commons/util/DigestUtil.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.commons.util;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.util.zip.CRC32;
9 |
10 | /**
11 | * Created by tangyinsheng on 2019-09-18.
12 | */
13 | public final class DigestUtil {
14 | public static long getCRC32(File file) throws IOException {
15 | InputStream is = null;
16 | try {
17 | is = new BufferedInputStream(new FileInputStream(file));
18 | return getCRC32(is);
19 | } finally {
20 | IOHelper.closeQuietly(is);
21 | }
22 | }
23 |
24 | public static long getCRC32(byte[] data, int off, int length) {
25 | final CRC32 crc32 = new CRC32();
26 | crc32.update(data, off, length);
27 | return crc32.getValue();
28 | }
29 |
30 | public static long getCRC32(InputStream is) throws IOException {
31 | final CRC32 crc32 = new CRC32();
32 | final byte[] buffer = new byte[4096];
33 | int bytesRead = 0;
34 | while ((bytesRead = is.read(buffer)) > 0) {
35 | crc32.update(buffer, 0, bytesRead);
36 | }
37 | return crc32.getValue();
38 | }
39 |
40 | private DigestUtil() {
41 | throw new UnsupportedOperationException();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tinker-commons/src/main/java/com/tencent/tinker/commons/util/IOHelper.java:
--------------------------------------------------------------------------------
1 | package com.tencent.tinker.commons.util;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.OutputStream;
7 | import java.util.zip.ZipFile;
8 |
9 | /**
10 | * Created by tangyinsheng on 2017/11/16.
11 | */
12 |
13 | public final class IOHelper {
14 | public static void copyStream(InputStream is, OutputStream os) throws IOException {
15 | final byte[] buffer = new byte[4096];
16 | int bytesRead = 0;
17 | while ((bytesRead = is.read(buffer)) > 0) {
18 | os.write(buffer, 0, bytesRead);
19 | }
20 | os.flush();
21 | }
22 |
23 | /**
24 | * Closes the given {@code obj}. Suppresses any exceptions.
25 | */
26 | @SuppressWarnings("NewApi")
27 | public static void closeQuietly(Object obj) {
28 | if (obj == null) return;
29 | try {
30 | if (obj instanceof Closeable) {
31 | ((Closeable) obj).close();
32 | } else if (obj instanceof AutoCloseable) {
33 | ((AutoCloseable) obj).close();
34 | } else if (obj instanceof ZipFile) {
35 | ((ZipFile) obj).close();
36 | }
37 | } catch (Throwable ignored) {
38 | // ignored.
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/tinker-sample-android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
3 | /version.properties
4 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/keystore/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/keystore/debug.keystore
--------------------------------------------------------------------------------
/tinker-sample-android/app/keystore/release.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/keystore/release.keystore
--------------------------------------------------------------------------------
/tinker-sample-android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangshaowen/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 | -keepattributes SourceFile,LineNumberTable
19 |
20 | -dontwarn com.google.**
21 |
22 | -dontwarn com.android.**
23 |
24 |
25 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/java/tinker/sample/android/app/BaseBuildInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tinker.sample.android.app;
18 |
19 | import tinker.sample.android.BuildConfig;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/6/30.
23 | * we add BaseBuildInfo to loader pattern, so it won't change with patch!
24 | */
25 | public class BaseBuildInfo {
26 | public static String TEST_MESSAGE = "I won't change with tinker patch!";
27 | public static String BASE_TINKER_ID = BuildConfig.TINKER_ID;
28 | }
29 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/java/tinker/sample/android/app/BuildInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tinker.sample.android.app;
18 |
19 | import tinker.sample.android.BuildConfig;
20 |
21 | /**
22 | * Created by zhangshaowen on 16/6/30.
23 | * we use BuildInfo instead of {@link BuildInfo} to make less change
24 | */
25 | public class BuildInfo {
26 | /**
27 | * they are not final, so they won't change with the BuildConfig values!
28 | */
29 | public static boolean DEBUG = BuildConfig.DEBUG;
30 | public static String VERSION_NAME = BuildConfig.VERSION_NAME;
31 | public static int VERSION_CODE = BuildConfig.VERSION_CODE;
32 |
33 | public static String MESSAGE = BuildConfig.MESSAGE;
34 | public static String TINKER_ID = BuildConfig.TINKER_ID;
35 | public static String PLATFORM = BuildConfig.PLATFORM;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/java/tinker/sample/android/util/SampleApplicationContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tinker.sample.android.util;
18 |
19 | import android.app.Application;
20 | import android.content.Context;
21 |
22 | /**
23 | * Created by zhangshaowen on 16/8/9.
24 | */
25 | public class SampleApplicationContext {
26 | public static Application application = null;
27 | public static Context context = null;
28 | }
29 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | tinker-sample-android
3 | I am in the base apk
4 |
5 | Please grant external storage accessing permissions to this app. Otherwise patch loading may be failed.
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/tinker-sample-android/app/src/test/java/tinker/sample/android/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tencent is pleased to support the open source community by making Tinker available.
3 | *
4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
5 | *
6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
7 | * compliance with the License. You may obtain a copy of the License at
8 | *
9 | * https://opensource.org/licenses/BSD-3-Clause
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is
12 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tinker.sample.android;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
25 | */
26 | public class ExampleUnitTest {
27 | @Test
28 | public void addition_isCorrect() throws Exception {
29 | assertEquals(4, 2 + 2);
30 | }
31 | }
--------------------------------------------------------------------------------
/tinker-sample-android/app/tinker_multidexkeep.pro:
--------------------------------------------------------------------------------
1 |
2 | #tinker multidex keep patterns:
3 | -keep public class * implements com.tencent.tinker.entry.ApplicationLifeCycle {
4 | (...);
5 | void onBaseContextAttached(android.content.Context);
6 | }
7 |
8 | -keep public class com.tencent.tinker.entry.ApplicationLifeCycle {
9 | *;
10 | }
11 |
12 | -keep public class * extends com.tencent.tinker.loader.TinkerLoader {
13 | (...);
14 | }
15 |
16 | -keep public class * extends android.app.Application {
17 | ();
18 | void attachBaseContext(android.content.Context);
19 | }
20 |
21 | -keep class com.tencent.tinker.loader.TinkerTestAndroidNClassLoader {
22 | (...);
23 | }
24 |
25 | #your dex.loader patterns here
26 | -keep class tinker.sample.android.app.SampleApplication {
27 | (...);
28 | }
29 |
30 | -keep class com.tencent.tinker.loader.** {
31 | (...);
32 | }
33 |
34 | -keep class android.support.test.internal** { *; }
35 | -keep class org.junit.** { *; }
36 |
--------------------------------------------------------------------------------
/tinker-sample-android/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | buildscript {
3 | repositories {
4 | mavenLocal()
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | if (project.hasProperty('GRADLE_3') && GRADLE_3.equalsIgnoreCase('TRUE')) {
10 | classpath 'com.android.tools.build:gradle:3.5.3'
11 | } else {
12 | classpath 'com.android.tools.build:gradle:2.3.3'
13 | }
14 | classpath("com.tencent.tinker:tinker-patch-gradle-plugin:${TINKER_VERSION}") {
15 | changing = TINKER_VERSION?.endsWith("-SNAPSHOT")
16 | exclude group: 'com.android.tools.build', module: 'gradle'
17 | }
18 | }
19 | configurations.all {
20 | it.resolutionStrategy.cacheDynamicVersionsFor(5, 'minutes')
21 | it.resolutionStrategy.cacheChangingModulesFor(0, 'seconds')
22 | }
23 | }
24 |
25 | allprojects {
26 | repositories {
27 | mavenLocal()
28 | jcenter()
29 | google()
30 | }
31 | }
32 |
33 | def is_gradle_3() {
34 | return hasProperty('GRADLE_3') && GRADLE_3.equalsIgnoreCase('TRUE')
35 | }
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tinker-sample-android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | TINKER_VERSION=1.9.14.18
21 | GRADLE_3=true
22 |
23 | #tinker.aapt2.public=false
24 | android.useAndroidX=true
25 | android.enableJetifier=true
26 |
--------------------------------------------------------------------------------
/tinker-sample-android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tencent/tinker/7a0311c8fce2a3eefb08cf526f414ea48876b39f/tinker-sample-android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/tinker-sample-android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/tinker-sample-android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/tinker-sample-android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/tinker-sample-android/updateTinkerLib.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | rm -rf ~/.gradle/caches/modules-2/metadata-2.16/descriptors/com.tencent.tinker
3 |
4 | #rm -rf ~/.m2/repository/com/tencent/tinker
5 | #adb push ./app/build/outputs/tinkerPatch/debug/patch_signed_7zip.apk /sdcard/
--------------------------------------------------------------------------------