Tags: HChenX/HookTool
Tags
chore: upgrade Gradle wrapper to 9.5.1 and compileSdk to 37 - Bump Gradle wrapper from 9.4.1 to 9.5.1 (regenerated gradlew/gradlew.bat) - Update gradle-wrapper.jar and gradle-wrapper.properties accordingly - Remove redundant group/version declarations from tool/build.gradle (handled by publishing configuration) - Raise compileSdk from 36 to 37 in both app and tool modules
feat(tool): add helper methods for safe reflection and bump version Update version to 3.0.4 and add several Kotlin extension functions to CoreTool to facilitate safer reflection operations, including: - `findAllMethodByName` for finding methods by name - `callMethodIfExists` for safe instance method invocation - `getFieldIfExists` and `setFieldIfExists` for safe field access - `callStaticMethodIfExists` for safe static method invocation
3.0.2 (#24) * refactor(tool): enhance core API and documentation Refactor the `tool` module to improve the core hooking API, implement a more robust internal reflection helper, and significantly enhance codebase documentation. - Implement `CoreHelper` in Kotlin to provide high-performance, cached reflection capabilities, replacing direct `XposedHelpers` calls. - Refactor `AbsModule`, `ModuleEntrance`, and `AbsHook` to provide a more structured lifecycle management system. - Enhance `ChainTool` and `ChainHook` with a fluent API for method and constructor hooking. - Improve `ShellTool` and `AndroidLog`/`XposedLog` with better error handling and logging level controls. - Add comprehensive Javadoc/KDoc to almost all public and protected classes and methods across the `tool` module. - Remove the deprecated `xposed-helper` module and clean up project configuration. - Update `AppData` and `ModuleData` to improve data encapsulation and lifecycle awareness. * fix(helper): improve primitive type widening and method matching Refine the `CoreHelper` reflection logic to handle primitive type widening more accurately and improve method discovery. - Update `hashCode` implementations for internal reflection keys to include `isExact` flag. - Enhance `isAssignable` to support widening conversions between primitive types. - Optimize `calculateWideningCost` by using index-based calculations instead of iterative loops. - Implement `collectMethodsBestMatch` to improve method resolution across class hierarchies. * docs(helper): add kdoc for method discovery and instance field utilities Add comprehensive KDoc documentation for `collectMethodsBestMatch`, `setAdditionalInstanceField`, and `getAdditionalInstanceField` within `CoreHelper` to clarify their usage, parameters, and thread-safety guarantees. * build(tool): bump version to 3.0.2 and update CoreHelper documentation Update project version and versionCode in build.gradle. Refactor and expand KDoc for CoreHelper to provide detailed descriptions of internal cache mechanisms, data classes, and the custom Optional implementation. * feat(helper): extend field discovery to include interface constants Enhance the field lookup mechanism in `CoreHelper` to support searching through the interface hierarchy. This allows the tool to resolve constant fields defined in interfaces, which were previously unreachable via standard class superclass traversal. - Implement `findInterfaceFieldRecursive` to traverse interface trees. - Update `findFieldRecursiveImpl` to include interface constant scanning in the search order. - Update documentation to reflect expanded field access capabilities.
3.0.1 (#23) * refactor(tool): improve thread safety and hook management Refactor core components to enhance concurrency support and fix potential issues with hook lifecycle management. - Improve thread safety by using `volatile`, `AtomicBoolean`, and `ConcurrentHashMap` in `ModuleConfig`, `ModuleData`, `PrefsTool`, and `ResInjectTool`. - Implement `DelegateHook` in `CoreTool` to allow multiple hooks to share the same `AbsHook` instance without interfering with each other's unhooking process. - Fix `AbsHook` stack management to prevent index out of bounds and ensure proper state cleanup. - Enhance `ShellTool` with better synchronization and timeout handling for shell command execution. - Add error handling for version parsing in `DeviceTool` and improve logging in `ModuleEntrance`. - Update `PrefsTool` to use `computeIfAbsent` for more efficient and thread-safe preference retrieval. * fix(utils): improve resource management and stability Enhance the robustness of utility classes by addressing potential resource leaks, improving API compatibility, and strengthening error handling. - **Resource Management**: Implement try-with-resources in `LogExpand` and `BitmapTool` to ensure proper closing of `PrintWriter` and `ByteArrayOutputStream`. - **API Compatibility**: Update `DeviceTool.isPadBySize` to use `WindowMetrics` for Android R+ compatibility. - **Stability & Safety**: - Add null checks and validation in `InvokeTool` to prevent ambiguous errors. - Implement `volatile` modifiers in `ShellTool` for better thread visibility. - Use a delegate pattern in `ResInjectTool` to improve hook lifecycle management. - Add null-safety checks for `propClass` in `SystemPropTool`. - **Bug Fixes**: - Fix potential zero-dimension issues in `BitmapTool`. - Improve HyperOS version parsing logic in `DeviceTool`. - Add exception handling for `IOException` in bitmap conversions. * build(tool): bump version to 3.0.1 refactor(hook): transition to multi-handle management and improve thread safety - **Hook Management**: Replace single `HookHandle` with `CopyOnWriteArrayList<HookHandle>` in `AbsHook` to support multiple concurrent hooks and ensure safe unhooking of all registered handles. - **Core Refactor**: Simplify `CoreTool.hookAll` by removing the redundant `DelegateHook` wrapper, allowing direct hook application. - **Thread Safety**: - Mark `shouldSkip` and `handle` in `ModuleEntrance` as `volatile`. - Use `CopyOnWriteArrayList` for thread-safe handle storage. - **Robustness & Safety**: - Implement a centralized `dispatch` mechanism in `AbsModule` using `Consumer` to standardize error handling and stage dispatching. - Add explicit null checks and `UnexpectedException` in `ModuleData.getClassLoader`. - Improve `SystemPropTool` with `Optional` to handle null returns from static method calls safely. - Optimize `DeviceTool` by caching lowercase brand and manufacturer strings. - **Cleanup**: - Remove unused `Intent` logic in `ModuleState`. - Simplify `ResInjectTool` by removing the unnecessary `newDelegate` wrapper. - Fix typo in `SystemPropTool.setProp` parameter name (`vale` -> `value`). - Refine `ShellTool` executor shutdown logic. * docs(utils): add javadoc for SystemPropTool getter methods Add descriptive Javadoc comments to the overloaded `getProp` methods in `SystemPropTool` to clarify the return types (int, long, and String) and their usage.
Refactoring tool, adapted to Api 101 (#22) * 将 .java 重命名为 .kt * refactor: Migrate to LibXposed API and overhaul project structure - **Core Changes & Migrations:** - Migrate from legacy Xposed API to `io.github.libxposed`. - Replace `de.robv.android.xposed.XC_MethodHook` logic with `XposedInterface.Hooker` and `Chain` mechanisms. - Rewrite `CoreTool` in Kotlin for improved modern language feature support. - Replace `IHook` with `AbsHook`, providing a cleaner lifecycle for method interception (`before`, `PROCEED`, `after`). - Rename `HCData` to `ModuleConfig` and `HCState` to `ModuleState` for better clarity. - **Architecture & New Components:** - Introduce `ModuleEntrance` as the new recommended entry point (replaces `HCEntrance`). - Introduce `AbsModule` for implementing hook logic (replaces `HCBase`). - Add `ModuleData` to manage `XposedInterfaceWrapper` and class loaders globally. - Add `HookBridge` to facilitate fluent hook configuration (priority, interception). - Create a new `xposed-helper` module containing stubs for `XposedHelpers` to maintain compatibility with legacy reflection lookups. - **Enhancements & Refactoring:** - **LogExpand:** Rewrite tag detection and `observeCall` logic for compatibility with the new hook system; improve performance of stack trace analysis. - **ChainTool:** Refactor to use the new `AbsHook` and `Executable` types. - **ResInjectTool & PrefsTool:** Update to use `ModuleConfig` and `AbsHook`. - **CoreTool (Kotlin):** Provide comprehensive extension functions for `String`, `Class`, and `Any` to handle reflection, hooking, and invocation more idiomatically. - **Project Configuration:** - Update Gradle version and dependencies in `libs.versions.toml` (Xposed API `82` -> `101.0.0`). - Standardize Proguard rules across modules. - Update sample code in `app` module to reflect the new API usage. * refactor: clean up CoreTool, loggers, and project structure - **CoreTool**: - Rename `getParamTypes` to `getParameterTypes` and standardize `params` parameter names to `parameterTypes` or `args` across various methods for clarity. - Add `Method.callMethod`, `Method.callStaticMethod`, `Field.getField`, and `Field.setField` extension/static methods for more direct reflection operations. - Update `hook` methods to return `HookBridge` consistently. - Remove `buildChain` methods and related logic. - **Logging (XposedLog, AndroidLog)**: - Update `XposedLog` to use `ModuleData.getWrapper().log` for unified output and improve log level mapping to `android.util.Log` constants. - Standardize log tag retrieval using `ModuleConfig.getLogTag()`. - Update log level checks to reference `ModuleConfig` constants. - **ResInjectTool**: - Update resource injection logic to use `ModuleData.getModuleApplicationInfo().sourceDir` instead of `ModuleConfig.getModulePath()`. - Simplify hook registrations by using the generic `CoreTool.hook` method. - Fix potential `thisObject` usage by replacing with `getThisObject()` and update field access to use `CoreTool.getField`. - **Helpers (MethodHelper, ConstructorHelper, HookHelper)**: - Modify `single`, `singleOrNull`, and `singleOrThrow` in `MethodHelper` and `ConstructorHelper` to return raw `Method`/`Constructor` objects instead of `HookHelper` wrappers. - Remove `HookHelper.java` as it is no longer used for wrapping reflection members. - **Cleanup**: - Remove `ChainTool`, `ChainData`, and `ChainType` (Chain-related infrastructure). - Remove `HookException`, `MissingParameterException`, and related unused exception classes. - Update `PrefsTool` to use `ModuleConfig.isXposedEnvironment()` check. - Add `UnexpectedException` for unknown parameter type handling in `CoreTool`. * Refactor: Update ModuleState fields, remove unused filter, and improve documentation - **ModuleState & Proguard**: - Replace static methods `isXposedEnabled()`, `getFramework()`, and `getVersion()` with static fields `isXposedActivated`, `frameworkName`, `frameworkVersion`, and `frameworkVersionCode`. - Update `proguard-rules.pro` to reflect these field changes. - **Callbacks & Interfaces**: - Remove `IMemberFilter` interface. - Update Javadoc for `IContextGetter`, `IPrefsApply`, and `IAsyncPrefs` for clarity. - **CoreTool & HookBridge**: - Add missing license headers. - Add class-level Javadoc/author annotations. * Refactor: Modernize ResInjectTool, improve CoreTool documentation, and enhance PrefsTool - **ResInjectTool**: - Refactored to use `CoreTool.getInvoker` with `XposedInterface.Invoker.Type.ORIGIN` for calling original methods, improving compatibility with modern Xposed APIs. - Simplified resource injection logic and improved error messaging. - Replaced `CopyOnWriteArraySet` recursion check with direct original method invocation via `Invoker`. - Added `@SuppressWarnings("DataFlowIssue")` and assertions for better null safety during reflection. - **CoreTool**: - Added extensive Javadoc comments to most static methods, including class/method/field searching, hooking, and preference management. - Updated parameter handling to support nullable types (`Any?`) in reflection-based calls. - **PrefsTool**: - Renamed internal classes (e.g., `Xprefs` and `Sprefs` to `SPrefs`) for consistency. - Replaced `XSharedPreferences` with `ModuleData.getRemotePreferences()` to align with modern Xposed API practices. - Improved preference name initialization logic and added better exception messages. - **AbsHook**: - Added `currentStage` tracking (BEFORE, PROCEED, AFTER). - Updated `getArgs()` to return a standard `Object[]` for legacy compatibility. - Fixed `getResult()` to return `null` during the `BEFORE` stage to match expected hook behavior. - Added Javadoc to public API methods. - **ModuleConfig & ModuleData**: - Added license headers and updated Javadoc. - Improved validation for `modulePackageName` to ensure it is not empty when accessed. - **Other**: - **HookBridge**: Added Javadoc and internal stage management for interceptors. - **ShellResult**: Switched to `TextUtils.equals` for safer exit code comparison. - **Build**: Added `libs.service` implementation dependency. * refactor: Standardize exception messages and improve type safety - **CoreTool**: - Update `findConstructorIfExists` return type to be nullable (`Constructor<*>?`) to correctly reflect potential missing constructors. - **Exception Messages**: - Standardize and clean up exception messages across multiple classes by removing class-name prefixes (e.g., `[ContextTool]:`) and fixing capitalization/punctuation. - Affected classes: `ContextTool`, `ResInjectTool`, `ConstructorHelper`, `MethodHelper`, `InvokeTool`, `ClassHelper`, `PrefsTool`, `ModuleConfig`, `AbsHook`, `ShellTool`, `PackageTool`, and `FieldHelper`. * Refactor: Improve AbsHook thread safety and ClassHelper optimization - **AbsHook & HookBridge**: - Implement `ThreadLocal<CallState>` in `AbsHook` to ensure thread safety during concurrent hook interceptions. - Introduce `proceed(XposedInterface.Chain)` to allow flexible control over the original method call. - Add `setThrowable` and `getThrowable` for better exception management within the hook lifecycle. - Refactor `HookBridge` to support the new multi-stage lifecycle (`before`, `proceed`, `after`) with improved error handling and state management. - Add `InnerChain` to wrap the original Xposed chain, ensuring modified arguments are correctly propagated. - **ClassHelper**: - Optimize `find()` logic by checking `packagePath` early to reduce unnecessary class loading. - Remove `URLClassLoader` fallback logic and manual JAR scanning to streamline class path retrieval on Android. - Replace `Objects.equals` with `TextUtils.equals` for string comparisons. - Fix `fieldClasses` matching logic to use `null` instead of the deleted `Any` class. - **Helper Classes (ConstructorHelper, MethodHelper, FieldHelper)**: - Replace the placeholder `Any` class with `null` for "any" parameter matching. - Standardize `Objects.requireNonNull` error messages. - Remove the `Any.java` placeholder class. - **Other Components**: - **CoreTool**: Fix capitalization in error message. - **PrefsTool**: Fix capitalization in error message. * Refactor: Optimize Helper classes and improve code quality - **General (Helper classes):** - Refactor `ClassHelper`, `MethodHelper`, `ConstructorHelper`, and `FieldHelper` to use imperative loops instead of Java Streams for better performance and readability. - Add explicit `Objects.requireNonNull` checks to public setter methods for improved robustness. - Standardize Javadoc comments and method descriptions across all helper components. - **ClassHelper:** - Rename internal count fields (e.g., `fieldCount` to `expectedFieldCount`) for clarity. - Optimize class loading and filtering logic, including safer handling of `BaseDexClassLoader` and `DexFile` entries. - Improve field and method matching by checking for presence rather than using intermediate sets. - **MethodHelper & ConstructorHelper:** - Modularize filtering logic into specific private methods (e.g., `matchesParamClasses`, `matchesModifiers`). - Update parameter matching to consistently use `null` as a wildcard placeholder for any type. - Ensure `withSuper` logic correctly traverses the class hierarchy for methods. - **FieldHelper:** - Add descriptive comments for modifier setters (`withPublic`, `withStatic`, etc.). - Fix and optimize field matching logic, including proper superclass field inclusion. - **LogExpand:** - Switch from `hook.getArgs().get(i)` to array-style access `hook.getArgs()[i]` for efficiency and compatibility. * Refactor: Clean up helper classes, context tools, and exception names - **Removal of Helper Classes**: - Deleted `ClassHelper`, `ConstructorHelper`, `FieldHelper`, and `MethodHelper` from the `com.hchen.hooktool.helper` package. - **Context & Preference Updates**: - Removed `ContextTool` and its associated callback `IContextGetter`. - Removed `asyncPrefs` functionality from `CoreTool` and `PrefsTool`, along with the `IAsyncPrefs` callback. - **Exceptions**: - Renamed `NonXposedException` to `NoXposedEnvironmentException`. - Removed `NonSingletonException`. - **PackageTool**: - Improved `getAppData` logic to properly shut down the `ExecutorService` after asynchronous execution. - **PrefsTool**: - Updated to use the renamed `NoXposedEnvironmentException`. * Refactor: Improve AppData encapsulation, InvokeTool caching, and PackageTool logic - **AppData**: - Encapsulate fields by changing access modifiers from `public` to `private`. - Add standard getter and setter methods for all fields (`user`, `uid`, `icon`, `label`, etc.). - **InvokeTool**: - Refactor method and field lookup logic into dedicated `findMethod` and `findField` helper methods to improve readability and reuse. - Optimize cache key generation for methods to include parameter types, ensuring more reliable lookups. - Rename internal parameters (e.g., `paramTypes` to `parameterTypes`, `params` to `args`) for better clarity. - Improve error handling by providing more descriptive messages in `UnexpectedException`. - **PackageTool**: - Simplify `isDisable` and `isSystem` logic. - Refactor `createAppData` to reduce code duplication by extracting common `ApplicationInfo` processing. - Replace Java Streams with manual loops in `getAppData` to potentially reduce overhead and improve compatibility. - Update `getUserId` to use a more direct null-check instead of `Optional`. - Improve exception messaging when package information retrieval fails. * feat: Refactor module initialization and improve hook state management - **Core/Hook System**: - **AbsHook**: Replace `ThreadLocal<CallState>` with a `StateStack` to properly handle nested hook calls. Added `reset()` and improved lifecycle management (`enter`/`exit`). - **ModuleEntrance**: Added `ModuleData.setXposedEnvironment(true)` and implemented libxposed service integration. - **CoreTool.kt**: Fixed spread operator usage for `vararg` parameters in method/constructor search and invocation helpers. - **Module Configuration & Data**: - **ModuleConfig**: Removed `isAutoReload` and `isXposedEnvironment` fields (moved to `ModuleData`). Cleaned up setters and getters. - **ModuleData**: Centralized framework information (version, name, properties) and added `isXposedEnvironment` state. - **ModuleState**: Removed static framework metadata fields as they are now managed via `ModuleData` and the wrapper. - **Tools & Helpers**: - **PackageTool & IAppDataGetter**: Refactored `getAppData` to use generics (`T`) and `List<T>` instead of `Parcelable[]`, providing better type safety for package information retrieval. - **PrefsTool**: Updated environment checks to use `ModuleData`. - **XposedLog**: Simplified log tagging logic by removing square brackets from tags. - **App/Demo Refactoring**: - Deleted `HookDemo.java` and `HookInit.java`. - Added `InitHook.java` as the new entry point using updated `ModuleEntrance` APIs. - Added a basic `MainActivity`, `Application` with libxposed service listener, and standard Android resource files (layout, themes, mipmaps). - **Build & Environment**: - Updated `gradle/libs.versions.toml` with new dependencies (`appcompat`, `activity`, `constraintlayout`). - Standardized plugin aliases in `build.gradle` files. - Updated `xposed-helper` `minSdk` to 26. - Added Xposed module configuration files (`scope.list`, `java_init.list`, `module.prop`) in `META-INF`. * feat: Refactor logging, preferences, and add new utility features - **LogExpand**: - Optimize `getTag` logic to use a single loop and improve string manipulation performance. - Refactor `observeCall` to use `StringBuilder` for better efficiency. - Improve `paramToString` by using `Arrays.deepToString` and specialized `Arrays.toString` for primitives instead of a manual stack-based implementation. - **CoreTool**: - Add support for optional "hook success" logging in `hook()` and `hookClassInitializer()`. - Update return types from `IPrefsApply` to `IPreferences`. - **BitmapTool**: - Add `getRoundedCornerBitmap` and `scaleBitmap` methods. - Optimize `drawableToBitmap` to directly return the bitmap if the drawable is a `BitmapDrawable`. - **TryHelper & ResultData**: - Move result handling logic from `TryHelper.Result` to a new standalone `ResultData` class. - Introduce `IDecomposer` interface to abstract the data supplier. - **Preferences**: - Rename `IPrefsApply` interface to `IPreferences`. - Update `PrefsTool` and related classes to reflect the renaming. - **ModuleConfig**: - Add `isShowHookSuccessLog` configuration and related getter/setter. - Add Javadoc comments to configuration methods. - **Other**: - Enable `showHookSuccessLog` and set `logExpandPaths` in the sample `InitHook`. - Add IDE configuration file `.idea/deviceManager.xml`. * feat: Refactor for Java 7 compatibility and update version to 3.0.0-rc01 - **DeviceTool**: - Add `getScreenDensity(Context)` and `getDeviceId()` methods. - Improve `getRomVersion` with better null checking and error handling. - Refactor `isMiuiInternational`, `isXiaomiPad`, and other internal methods to use anonymous classes instead of lambdas for better compatibility with older Java versions. - Fix logic in `getHyperOSVersion` to correctly assign the parsed version. - Correct typo in `isColorOS` Javadoc. - **ShellTool**: - Refactor `isRootAvailable`, `run`, and `brokenPip` to use anonymous `Callable`, `Runnable`, and `Function` classes instead of lambdas. - **PackageTool**: - Refactor `getUserId` and `getPackagesAsync` to use anonymous classes instead of lambdas. - **Build & Documentation**: - Update project version to `3.0.0-rc01` and version code to `2026032000`. - Significantly prune `README.md` to remove detailed usage examples, focusing on dependency declaration and a list of tool users. * Refactor: Streamline hook API and update version - **CoreTool**: - Refactor `hook` and `hookClassInitializer` methods to accept `AbsHook` as a parameter directly. - Change return types of hook methods from `HookBridge` to `XposedInterface.HookHandle`. - Enforce that the last element of `parameterTypes` in hook methods must be an instance of `AbsHook`. - **AbsHook**: - Add `priority` field and constructors to support custom hook priority (defaults to `PRIORITY_DEFAULT`). - **HookBridge**: - Change `setPriority` to `private` and call it automatically within `intercept` using the priority defined in `AbsHook`. - **ResInjectTool**: - Update numerous `CoreTool.hook` calls to use the new API where the hook callback is passed as the final argument instead of using `.intercept()`. - **Project Updates**: - Update project version to `v3.0.0-rc02`. - Update `README.md` and `build.gradle` to reflect the new version and version code. * feat: Add ChainTool for fluent hook configuration and improve ModuleEntrance - **ModuleEntrance**: - Add `handleApplicationCreated(Context)` callback. - Implement automatic hooking of `Application.attach(Context)` to trigger the new callback. - **CoreTool**: - Add `hookAll` methods to support hooking all methods by name or all constructors in a class. - Add `buildChain` extension methods to initialize `ChainTool` from a class or class name. - Update Javadoc to correctly reference `XposedInterface.HookHandle` instead of `HookBridge`. - **ChainTool & ChainData**: - Introduce `ChainTool` to provide a fluent/chainable API for finding and hooking methods or constructors. - Add support for exception handling (`onThrow`, `ignoreThrow`) and duplicate hook prevention within the chain. - Add `ChainData` and `ChainType` to manage the state and configuration of chained hook operations. - **Build**: - Update project version to `v3.0.0-rc03` and version code to `2026032200`. * Refactor: Improve exception handling, class modifiers, and package loading logic - **CoreTool**: - Add `throwIt()` extension method to facilitate throwing `Throwable` instances from Kotlin to Java. - **ModuleEntrance**: - Update `hookApplication` to accept `PackageLoadedParam` and check `isFirstPackage()` to prevent redundant hooks. - **ResultData**: - Add `getOrThrow()` method to return the result or throw the captured exception. - Rename `onThrowable` methods to `onThrow` for conciseness. - **InvokeTool & PackageTool**: - Replace `UnexpectedException` wrapping with `CoreTool.throwIt()` for more direct exception propagation. - **ChainTool**: - Use `CoreTool.throwIt()` when chain execution fails. - **ModuleConfig**: - Change `setLogExpandPaths` and `setLogExpandIgnoreClassNames` to use varargs for better API flexibility. - Add a private constructor to prevent instantiation. - **Architecture & Modifiers**: - Mark numerous utility, data, and helper classes as `final` to enforce immutability/singleton patterns (e.g., `ResInjectTool`, `RangeHelper`, `AppData`, `BitmapTool`, `InvokeTool`, etc.). - **Build**: - Comment out unused `libs.service` dependency in `tool/build.gradle`. * Refactor: Modernize AbsModule lifecycle and improve null safety - **AbsModule**: - Replace `StageEnum` and generic `onLoaded` methods with specific lifecycle callbacks: `onModuleLoaded`, `onPackageLoaded`, `onPackageReady`, `onClassLoader`, and `onApplicationCreated`. - Rename `onThrowable` to `onThrow` and update internal `handle*` methods to match the new lifecycle hooks. - Standardize error handling and logging across all lifecycle entry points. - **ModuleConfig & LogExpand**: - Change `logExpandPaths` and `logExpandIgnoreClassNames` from `@Nullable` to `@NonNull` by initializing them with empty arrays. - Simplify null checks in `LogExpand` now that arrays are guaranteed non-null. - **ModuleData**: - Add `@NonNull` requirements to `setWrapper` and `setClassLoader` parameters. - **TestHook & InitHook**: - Update implementation and call sites to use the new `onPackageReady` and `handlePackageReady` methods. - **Build**: - Update project version to `v.3.0.0-rc03` in `README.md`. * feat: Enhance AppData, PackageTool, and logging utilities - **AppData**: - Add `ApplicationInfo` field with getter/setter. - Update `Parcelable` implementation, `equals`, `hashCode`, and `toString` to include the new `info` field. - Refactor `hashCode` for better distribution. - **PackageTool & IAppDataGetter**: - Update `getAsyncAppData` callback to include an optional `NameNotFoundException`. - Enhance `createAppData` to support `ServiceInfo` and direct `ApplicationInfo` inputs. - Ensure `ApplicationInfo` is stored within `AppData` objects. - **InvokeTool**: - Add `getField(Object, String)` for instance field retrieval. - Refactor internal `baseInvoke` methods to simplify null checks and improve robustness. - Add `@NonNull` annotations to method/field lookup parameters. - **AbsHook & HookBridge**: - Remove `getResultOrThrowable` from `AbsHook`. - Modify `HookBridge` to catch and store exceptions during the `PROCEED` stage without immediately rethrowing, allowing `after` interceptors to run. - **DeviceTool**: - Add `@NonNull` annotations to various system information getters (Xiaomi/ColorOS versions, WindowManager, etc.). - **Log Utilities**: - `XposedLog`: Add `logI(String, Throwable)` overload. - `AndroidLog`: Add `logI(String, String, String)` for logging with stack traces; remove package-specific `logI`. - `LogExpand`: Add `@NonNull` annotations to string conversion and stack trace methods. - **Other**: - **ModuleData**: Add `getModulePath()` to retrieve the module's source directory. - **ResultData**: Rename `orElse` to `getOrDefault`. - **ShellTool**: Ensure `ExecutorService` is shut down after asynchronous execution. - **InitHook**: Add `handleApplicationCreated` override for debugging. - Update project version to `v.3.0.0-rc04`. * feat: Refactor `AbsModule` loading logic and optimize `XposedLog` - **AbsModule**: - Introduce `StageEnum` (MODULE_LOADED, PACKAGE_LOADED, PACKAGE_READY, SYSTEM_SERVER_STARTING) to handle different lifecycle stages. - Replace individual `onModuleLoaded`, `onPackageLoaded`, and `onPackageReady` methods with a single abstract `onLoaded(@nonnull StageEnum stageEnum, @nonnull Object param)` method. - Add `handleSystemServerStarting` to support hooking the system server startup stage. - **XposedLog**: - Simplify log level mapping by using standard `android.util.Log` constants directly in wrapper calls. - Remove the redundant `getLogLevel()` helper method. - **Build**: - Update project version to `v3.0.0-rc05`. - Update `defVersionCode` to `2026032301`. - Update version reference in `README.md`. * Refactor: Update TestHook method signature - **TestHook**: - Replace `onPackageReady` override with `onLoaded`. - Update method parameters to use `StageEnum` and `Object` instead of `XposedModuleInterface.PackageReadyParam`. - Remove unused `XposedModuleInterface` import. * Refactor: Simplify Preferences, improve ChainTool, and update AppData - **Preferences & PrefsTool**: - Remove `IPreferences` interface and the internal `SPrefs` wrapper class. - Update `PrefsTool` and `CoreTool` to use standard Android `SharedPreferences` directly. - Consolidate preference creation logic into a single `createSharedPreferences` method. - Use `ConcurrentHashMap` with simplified keys for caching preference instances. - **ChainTool & ChainData**: - Optimize duplicate detection in `ChainTool` by using a `HashSet<Integer>` to store `ChainData` hash codes instead of the objects themselves. - Throw a `UnexpectedException` when a duplicate chain is detected instead of just logging a warning. - Update `ChainData` to use `Objects.deepEquals` and `Objects.hash` for more robust equality checks and hash code generation. - **AppData & PackageTool**: - Update `AppData` to store both `PackageInfo` and `ApplicationInfo` (previously only `ApplicationInfo`). - Update `PackageTool.createAppData` to correctly populate both info fields when available. - Update `Parcelable` implementation and `toString`/`equals`/`hashCode` in `AppData` to include the new fields. - **ResInjectTool**: - Update `injectModuleRes` to use `ModuleData.getModulePath()` instead of retrieving it via `ApplicationInfo`. - Standardize log message capitalization. - **Other Changes**: - **AbsHook**: Simplify `getArg` logic by always returning from the `state.args` array. - **CoreTool**: Fix a capitalization typo in an exception message. - **ModuleConfig**: Change the default `logTag` from "unknown" to "Unknown". * build: Update version to v.3.0.0-rc06 - **Build**: - Update `defVersion` to `3.0.0-rc06` and `defVersionCode` to `2026033000` in `tool/build.gradle`. - **VSCode**: - Reformat `.vscode/settings.json` to use standard indentation. * feat: Refactor hook/invoker naming and enhance CoreTool - **CoreTool**: - Rename `hook` to `hookMethod` and `hookConstructor` for clarity. - Rename `hookAll` to `hookAllMethod` and `hookAllConstructor`. - Rename `getInvoker` to `getMethodInvoker` and `getConstructorInvoker`. - Rename `deoptimize` to `deoptimizeMethod` and `deoptimizeConstructor`. - Replace `exactMatch` parameter in `hasMethod` with a new `hasAnyMethod` helper. - Update internal calls to use the new renamed methods. - **AbsModule**: - Add `ON_CLASSLOADER` and `ON_APPLICATION_CREATED` to `StageEnum`. - Update `onThrow` to include the `StageEnum` where the error occurred. - Standardize parameter name from `stageEnum` to `stage`. - **ResInjectTool & ModuleEntrance**: - Update all references to use renamed `CoreTool` methods (`hookMethod`, `hookConstructor`, `getMethodInvoker`). - **Build**: - Update project version to `v3.0.0-rc07`. * feat: Add deoptimization methods and update version - **CoreTool**: - Add `deoptimizeAllMethod` and `deoptimizeAllConstructor` extension methods for `String` and `Class` types. - Add `deoptimizeAll` extension method for `Array<out Executable>`. - Add `@JvmStatic` and `@JvmOverloads` annotations to several methods (e.g., `hasAnyMethod`, `deoptimizeAllMethod`) to improve Java interoperability. - Refactor null checks across various "has" methods (e.g., `hasClass`, `hasMethod`, `hasField`) to use Kotlin's native `!= null` or Elvis operator instead of `Objects.nonNull`. - **Build**: - Update project version to `3.0.0-rc08` (versionCode `2026033002`). * feat: Add deoptimization methods and update version - **CoreTool**: - Add `deoptimizeAllMethod` and `deoptimizeAllConstructor` extension methods for `String` and `Class` types. - Add `deoptimizeAll` extension method for `Array<out Executable>`. - Add `@JvmStatic` and `@JvmOverloads` annotations to several methods (e.g., `hasAnyMethod`, `deoptimizeAllMethod`) to improve Java interoperability. - Refactor null checks across various "has" methods (e.g., `hasClass`, `hasMethod`, `hasField`) to use Kotlin's native `!= null` or Elvis operator instead of `Objects.nonNull`. - **Build**: - Update project version to `3.0.0-rc08` (versionCode `2026033002`). * feat: Refactor ClassLoader initialization and update version - **ModuleEntrance**: - Remove redundant `ModuleData.setClassLoader` calls from `handleLoadPackage`, `handleInitPackageResources`, and `onSystemServerStarting`. - **Build**: - Update project version to `v.3.0.0-rc09`. - Update version code to `2026033100`. * feat: Refactor ModuleData and PrefsTool for better preference management - **ModuleData**: - Add `mRemotePreferences` (WeakHashMap) to cache `SharedPreferences` in non-Xposed environments. - Add `addRemotePreferences` and `clearRemotePreferences` methods for manual preference management outside of Xposed. - Add `getModulePackageName()` to retrieve the module's package name from `ApplicationInfo`. - Update `getRemotePreferences` to support non-Xposed environments via the local cache. - **PrefsTool**: - Remove dependency on `NoXposedEnvironmentException`; `prefs()` can now be used in non-Xposed environments if preferences are pre-added to `ModuleData`. - Switch internal storage from `ConcurrentHashMap` to `WeakHashMap`. - Refactor preference caching logic to use a composite key (package name + prefs name) to prevent collisions. - Update `initPrefsName` to use `ModuleData.getModulePackageName()` as a fallback. - **ModuleConfig**: - Remove `modulePackageName` field and its related getter/setter, delegating this responsibility to `ModuleData`. - **ModuleEntrance**: - Ensure `ModuleData` state is initialized before calling `initModuleConfig()`. - **Other**: - Delete `NoXposedEnvironmentException` class. - Update project version to `v.3.0.0-rc10` (version code `2026033101`). * Refactor: Improve environment checks and update project version - **ModuleData**: - Add a check to `getWrapper()` to ensure it is called within an Xposed environment, throwing an `UnexpectedException` otherwise. - Update exception messages in `addRemotePreferences` and `clearRemotePreferences` to "Please call in the module environment" for consistency. - **Application & InitHook**: - Remove redundant `ModuleConfig.setModulePackageName(BuildConfig.APPLICATION_ID)` calls, as this is now handled internally. - **Build**: - Update project version to `v.3.0.0-rc11` and version code to `2026033102`. * feat: Add "IfExists" hook methods and refactor AppData - **CoreTool**: - Add `hookMethodIfExists`, `hookConstructorIfExists`, and `hookClassInitializerIfExists` extension methods to support hooking optional components without throwing exceptions. - **AppData**: - Refactor from a private-field/getter-setter pattern to a public-field structure for simplicity. - Remove `marshall` and `unmarshall` methods. - **ModuleData & PrefsTool**: - Simplify `SharedPreferences` handling by removing remote preference caching and restricting `getRemotePreferences` to Xposed environments. - **AbsHook**: - Mark `setThrowable` and `getThrowable` as `final`. - **Data Classes (ChainData, ShellResult)**: - Replace `Objects.deepEquals` with `Arrays.deepEquals` for `parameterTypes`, `errors`, and `outputs` array comparisons. - **PackageTool**: - Update `createAppData` to use direct field access in `AppData`. - **Build**: - Update project version to `v.3.0.0-rc12`. * docs: Update version to v3.0.0 and refine documentation - **Build**: - Update project version from `3.0.0-rc12` to `3.0.0`. - Update version code to `2026041200`. - **Documentation (README.md)**: - Update implementation dependency to version `3.0.0`. - Refine Chinese description and section headers for clarity. - Clean up redundant text and formatting in the project showcase and closing sections.
feat: Add "IfExists" hook methods and refactor AppData
- **CoreTool**:
- Add `hookMethodIfExists`, `hookConstructorIfExists`, and `hookClassInitializerIfExists` extension methods to support hooking optional components without throwing exceptions.
- **AppData**:
- Refactor from a private-field/getter-setter pattern to a public-field structure for simplicity.
- Remove `marshall` and `unmarshall` methods.
- **ModuleData & PrefsTool**:
- Simplify `SharedPreferences` handling by removing remote preference caching and restricting `getRemotePreferences` to Xposed environments.
- **AbsHook**:
- Mark `setThrowable` and `getThrowable` as `final`.
- **Data Classes (ChainData, ShellResult)**:
- Replace `Objects.deepEquals` with `Arrays.deepEquals` for `parameterTypes`, `errors`, and `outputs` array comparisons.
- **PackageTool**:
- Update `createAppData` to use direct field access in `AppData`.
- **Build**:
- Update project version to `v.3.0.0-rc12`.
Refactor: Improve environment checks and update project version
- **ModuleData**:
- Add a check to `getWrapper()` to ensure it is called within an Xposed environment, throwing an `UnexpectedException` otherwise.
- Update exception messages in `addRemotePreferences` and `clearRemotePreferences` to "Please call in the module environment" for consistency.
- **Application & InitHook**:
- Remove redundant `ModuleConfig.setModulePackageName(BuildConfig.APPLICATION_ID)` calls, as this is now handled internally.
- **Build**:
- Update project version to `v.3.0.0-rc11` and version code to `2026033102`.
feat: Refactor ModuleData and PrefsTool for better preference management
- **ModuleData**:
- Add `mRemotePreferences` (WeakHashMap) to cache `SharedPreferences` in non-Xposed environments.
- Add `addRemotePreferences` and `clearRemotePreferences` methods for manual preference management outside of Xposed.
- Add `getModulePackageName()` to retrieve the module's package name from `ApplicationInfo`.
- Update `getRemotePreferences` to support non-Xposed environments via the local cache.
- **PrefsTool**:
- Remove dependency on `NoXposedEnvironmentException`; `prefs()` can now be used in non-Xposed environments if preferences are pre-added to `ModuleData`.
- Switch internal storage from `ConcurrentHashMap` to `WeakHashMap`.
- Refactor preference caching logic to use a composite key (package name + prefs name) to prevent collisions.
- Update `initPrefsName` to use `ModuleData.getModulePackageName()` as a fallback.
- **ModuleConfig**:
- Remove `modulePackageName` field and its related getter/setter, delegating this responsibility to `ModuleData`.
- **ModuleEntrance**:
- Ensure `ModuleData` state is initialized before calling `initModuleConfig()`.
- **Other**:
- Delete `NoXposedEnvironmentException` class.
- Update project version to `v.3.0.0-rc10` (version code `2026033101`).
PreviousNext