Skip to content

Edison0716/hll-sys-hook-android

 
 

Repository files navigation

HuoLaLa unify hook lib

license release

简体中文

The HuoLaLa and Lalamove Android project employs inline-hook techniques to address system-level issues and enhance app's overall stability or performance.

Thread Shield

Safe to suspend thread.

Avoid suspending thread timeout to make process kill by Abort signal.

  • Android [5,11] : Hook ThreadSuspendByPeerWarning() to modified log level, if hit thread suspend timeout, will call suspendThreadTimeout() to notified java side.

  • Android [12,14] : Hook SuspendThreadByPeer() function and replace it to call SuspendThreadByPeerId() function, will not need to call suspendThreadTimeout() to notified java side, because if thread suspend timeout can not send abort signal.

  • Android 15 : Hook StringPrintf() function and block thread to wait thread suspends finish, will call suspendThreadTimeout() to notified java side.

Earnings

In Lalamove Side, the number of thread suspend timeout crash times is so huge.

suspend_thread_timeout_trend.png

How to use

1. Add dependencies
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url = uri("https://jitpack.io") }
        }
    }
    dependencies {
	    implementation 'com.github.HuolalaTech:hll-sys-hook-android:1.4-SNAPSHOT'
    }
2. Add code
    SuspendThreadSafeHelper.getInstance()
            .suspendThreadSafe(object : SuspendThreadSafeHelper.SuspendThreadCallback {
                override fun suspendThreadTimeout(waitTime: Double) {
                    Log.i("TAG", "Waitting for thread suspend done, spend : $waitTime s")
                }

                override fun onError(errorMsg: String) {
                    Log.e("TAG", "onError: $errorMsg")
                }
            })

About

Fix some system bugs to enhance app stability.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 76.0%
  • Kotlin 11.2%
  • CMake 8.5%
  • C 4.3%