diff --git a/app/src/main/java/io/github/libxposed/example/MainActivity.kt b/app/src/main/java/io/github/libxposed/example/MainActivity.kt index ec8d6b7..8d4c556 100644 --- a/app/src/main/java/io/github/libxposed/example/MainActivity.kt +++ b/app/src/main/java/io/github/libxposed/example/MainActivity.kt @@ -5,6 +5,7 @@ import android.app.Activity import android.os.Bundle import android.os.Handler import android.os.Looper +import android.util.Log import android.widget.Toast import io.github.libxposed.example.databinding.ActivityMainBinding import io.github.libxposed.service.XposedService @@ -36,33 +37,35 @@ class MainActivity : Activity() { super.onCreate(savedInstanceState) val binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) - + val handler = Handler(Looper.getMainLooper()) binding.binder.text = "Loading" XposedServiceHelper.registerListener(object : XposedServiceHelper.OnServiceListener { override fun onServiceBind(service: XposedService) { - mService = service - binding.binder.text = "Binder acquired" - binding.api.text = "API " + service.apiVersion - binding.framework.text = "Framework " + service.frameworkName - binding.frameworkVersion.text = "Framework version " + service.frameworkVersion - binding.frameworkVersionCode.text = "Framework version code " + service.frameworkVersionCode - binding.frameworkProperties.text = "Framework properties: " + service.frameworkProperties.toHexString() - binding.scope.text = "Scope: " + service.scope + handler.post { + mService = service + binding.binder.text = "Binder acquired" + binding.api.text = "API " + service.apiVersion + binding.framework.text = "Framework " + service.frameworkName + binding.frameworkVersion.text = "Framework version " + service.frameworkVersion + binding.frameworkVersionCode.text = "Framework version code " + service.frameworkVersionCode + binding.frameworkProperties.text = "Framework properties: " + service.frameworkProperties.toHexString() + binding.scope.text = "Scope: " + service.scope - binding.requestScope.setOnClickListener { - service.requestScope(listOf("com.android.settings"), mCallback) - } - binding.randomPrefs.setOnClickListener { - val prefs = service.getRemotePreferences("test") - val old = prefs.getInt("test", -1) - val new = Random.nextInt() - Toast.makeText(this@MainActivity, "$old -> $new", Toast.LENGTH_SHORT).show() - prefs.edit().putInt("test", new).apply() - } - binding.remoteFile.setOnClickListener { - service.openRemoteFile("test.txt").use { pfd -> - FileWriter(pfd.fileDescriptor).use { - it.append("Hello World!") + binding.requestScope.setOnClickListener { + service.requestScope(listOf("com.android.settings"), mCallback) + } + binding.randomPrefs.setOnClickListener { + val prefs = service.getRemotePreferences("test") + val old = prefs.getInt("test", -1) + val new = Random.nextInt() + Toast.makeText(this@MainActivity, "$old -> $new", Toast.LENGTH_SHORT).show() + prefs.edit().putInt("test", new).apply() + } + binding.remoteFile.setOnClickListener { + service.openRemoteFile("test.txt").use { pfd -> + FileWriter(pfd.fileDescriptor).use { + it.append("Hello World!") + } } } } @@ -72,7 +75,7 @@ class MainActivity : Activity() { } }) - val handler = Handler(Looper.getMainLooper()) + handler.postDelayed({ if (mService == null) { binding.binder.text = "Binder is null" diff --git a/build.gradle.kts b/build.gradle.kts index a596355..7f0594e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,3 @@ tasks.register("Delete", Delete::class) { - delete(rootProject.buildDir) + delete(rootProject.layout.buildDirectory) }