Skip to content

Commit b41c8e3

Browse files
committed
Resolve all review
1 parent ae24636 commit b41c8e3

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

app/src/main/java/io/github/libxposed/example/App.kt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package io.github.libxposed.example
22

33
import android.app.Application
4-
import android.os.Handler
5-
import android.os.Looper
64
import io.github.libxposed.service.XposedService
75
import io.github.libxposed.service.XposedServiceHelper
86
import java.util.concurrent.CopyOnWriteArraySet
@@ -14,21 +12,15 @@ class App : Application(), XposedServiceHelper.OnServiceListener {
1412
companion object {
1513
@Volatile
1614
var mService: XposedService? = null
17-
val serviceStateListeners =
15+
private val serviceStateListeners =
1816
CopyOnWriteArraySet<ServiceStateListener>()
19-
val mainHandler: Handler = Handler(Looper.getMainLooper())
17+
2018
private fun dispatchServiceState(
2119
listener: ServiceStateListener,
2220
service: XposedService?
2321
) {
24-
if (Looper.myLooper() == Looper.getMainLooper()) {
22+
if (serviceStateListeners.contains(listener)) {
2523
listener.onServiceStateChanged(service)
26-
return
27-
}
28-
mainHandler.post {
29-
listener.onServiceStateChanged(
30-
service
31-
)
3224
}
3325
}
3426

@@ -38,10 +30,7 @@ class App : Application(), XposedServiceHelper.OnServiceListener {
3830
) {
3931
serviceStateListeners.add(listener)
4032
if (notifyImmediately) {
41-
dispatchServiceState(
42-
listener,
43-
mService
44-
)
33+
dispatchServiceState(listener, mService)
4534
}
4635
}
4736

app/src/main/java/io/github/libxposed/example/MainActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ class MainActivity : Activity(), App.ServiceStateListener {
7373
"Framework version code " + service?.frameworkVersionCode
7474
val cap = service?.frameworkProperties
7575
val capStringList = mutableListOf<String>()
76-
cap?.and(XposedService.PROP_CAP_SYSTEM)?.let {
76+
if (cap != null && cap.and(XposedService.PROP_CAP_SYSTEM) != 0L) {
7777
capStringList.add("PROP_CAP_SYSTEM")
7878
}
79-
cap?.and(XposedService.PROP_CAP_REMOTE)?.let {
79+
if (cap != null && cap.and(XposedService.PROP_CAP_REMOTE) != 0L) {
8080
capStringList.add("PROP_CAP_REMOTE")
8181
}
82-
cap?.and(XposedService.PROP_RT_API_PROTECTION)?.let {
82+
if (cap != null && cap.and(XposedService.PROP_RT_API_PROTECTION) != 0L) {
8383
capStringList.add("PROP_RT_API_PROTECTION")
8484
}
8585
it.frameworkProperties.text =

0 commit comments

Comments
 (0)