Class AbsMainProcessPlugin<E extends BaseExtension>

    • Constructor Detail

      • AbsMainProcessPlugin

        public AbsMainProcessPlugin()
    • Method Detail

      • traverse

        public void traverse​(@Nonnull
                             java.lang.String relativePath,
                             @Nonnull
                             ClassVisitorChain chain)
        Description copied from interface: MainProcessHandler
        遍历工程中所有的class Traverse all classes in the whole project.
        Specified by:
        traverse in interface MainProcessHandler
        Parameters:
        relativePath - class的相对路径。 relative path of class
        chain - ClassVisitorChain用于加入自定义的ClassVisitor。 ASM visitor api. ClassVisitorChain is used for appending your custom ClassVisitor.
      • traverseAndroidJar

        public void traverseAndroidJar​(@Nonnull
                                       java.lang.String relativePath,
                                       @Nonnull
                                       ClassVisitorChain chain)
        Description copied from interface: MainProcessHandler
        遍历android.jar中所有的class Traverse all classes in android.jar.
        Specified by:
        traverseAndroidJar in interface MainProcessHandler
        Parameters:
        relativePath - class的相对路径。 relative path of class
        chain - ClassVisitorChain用于加入自定义的ClassVisitor。 ASM visitor api. ClassVisitorChain is used for appending your custom ClassVisitor.
      • traverse

        public void traverse​(@Nonnull
                             java.lang.String relativePath,
                             @Nonnull
                             org.objectweb.asm.tree.ClassNode node)
        Description copied from interface: MainProcessHandler
        遍历工程中所有的class Traverse all classes in the whole project.
        Specified by:
        traverse in interface MainProcessHandler
        Parameters:
        relativePath - class的相对路径。 relative path of class
        node - class的数据结构(照顾喜欢用tree api的同学)。 ASM tree api.
      • traverseAndroidJar

        public void traverseAndroidJar​(@Nonnull
                                       java.lang.String relativePath,
                                       @Nonnull
                                       org.objectweb.asm.tree.ClassNode node)
        Description copied from interface: MainProcessHandler
        遍历android.jar中所有的class Traverse all classes in android.jar.
        Specified by:
        traverseAndroidJar in interface MainProcessHandler
        Parameters:
        relativePath - class的相对路径。 relative path of class
        node - class的数据结构(照顾喜欢用tree api的同学)。 ASM tree api.
      • transform

        public boolean transform​(@Nonnull
                                 java.lang.String relativePath,
                                 @Nonnull
                                 ClassVisitorChain chain)
        Description copied from interface: MainProcessHandler
        handle 工程中的所有class To process all classed in the whole project.
        Specified by:
        transform in interface MainProcessHandler
        Parameters:
        relativePath - class的相对路径。 relative path of class
        chain - ClassVisitorChain用于注册自定义的ClassVisitor。 ASM visitor api. ClassVisitorChain is used for appending your custom ClassVisitor.
        Returns:
        if false, this class file would be deleted, otherwise it would be output after transform.
      • transform

        public boolean transform​(@Nonnull
                                 java.lang.String relativePath,
                                 @Nonnull
                                 org.objectweb.asm.tree.ClassNode node)
        Description copied from interface: MainProcessHandler
        handle 工程中的所有class To process all classed in the whole project.
        Specified by:
        transform in interface MainProcessHandler
        Parameters:
        relativePath - class的相对路径。 relative path of class
        node - class的数据结构(照顾喜欢用tree api的同学)。。 ASM tree api.
        Returns:
        if false, this class file would be deleted, otherwise it would be output after transform.
      • afterTransform

        public void afterTransform​(@Nonnull
                                   TransformEngine engine)
        Description copied from interface: MainProcessHandler
        用于transform完成后,进行各种illegal check It's usually used for plugin's custom illegal check after transform.
        Specified by:
        afterTransform in interface MainProcessHandler
        Parameters:
        engine - from TransformEngine
      • registerTransformFlow

        @Nonnull
        public final TransformFlow registerTransformFlow​(@Nonnull
                                                         MainTransformFlow mainFlow,
                                                         @Nonnull
                                                         TransformContext transformContext)
        Each ByteX plugin can have its own TransformFlow, and the return value of this method determines which flow the plugin runs in.
        We mark it as final because TransformFlow should register only once
        Specified by:
        registerTransformFlow in interface IPlugin
        Parameters:
        mainFlow - 全局的MainTransformFlow。The global MainTransformFlow
        Returns:
        当前插件关联的TransformFlow,通常返回mainFlow就可以。如果想让插件通过单独一个TransformFlow处理class文件, 这个方法需要另外return 新的TransformFlow(可以是自定义的TransformFlow,也可以new 一个MainTransformFlow)。 If this plugin is related to the global MainTransformFlow, just return `mainFlow` is OK. If you want to handle class files with a single TransformFlow, you should return a new TransformFlow. If so, this new TransformFlow would only contain this plugin.
      • getTransformFlow

        public final TransformFlow getTransformFlow()
        Specified by:
        getTransformFlow in interface IPlugin
        Returns:
        get the TransformFlow that the current plugin runs on
      • process

        public java.util.List<FileProcessor> process​(Process process)
        Description copied from interface: MainProcessHandler
        在traverse和transform的过程中,加入自定义的FileProcessor,提供更大的灵活性。 Add custom FileProcessor during traverse or transform.
        Specified by:
        process in interface MainProcessHandler
        Parameters:
        process - enum
        Returns:
        list of FileProcessor
      • needPreVerify

        public boolean needPreVerify()
        Description copied from interface: MainProcessHandler
        这个Handler是不是要求在真正执行前进行一次校验 Verify bytecode before transform.
        Specified by:
        needPreVerify in interface MainProcessHandler
        Returns:
        if true, indicate that need to verify bytecode. Default is false.
      • needVerify

        public boolean needVerify()
        Description copied from interface: MainProcessHandler
        在执行完这个Handler后是否需要进行一次校验 Verify bytecode after transform.
        Specified by:
        needVerify in interface MainProcessHandler
        Returns:
        if true, indicate that need to verify bytecode. Default is false.
      • afterExecute

        public void afterExecute()
                          throws java.lang.Throwable
        Description copied from interface: IPlugin
        插件执行执行结束后的回调,不管成功和失败都会执行.做一些数据回收处理工作
        Specified by:
        afterExecute in interface IPlugin
        Overrides:
        afterExecute in class AbsPlugin<E extends BaseExtension>
        Throws:
        java.lang.Throwable