better anti evasion
This commit is contained in:
parent
0b96b5bb52
commit
70b269254a
|
@ -14,7 +14,7 @@
|
|||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="digica settings"
|
||||
android:label="@string/app_settings_name"
|
||||
android:theme="@style/Theme.Digica">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -26,7 +26,8 @@
|
|||
android:name=".service.DigicaService"
|
||||
android:exported="false"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
|
||||
android:label="@string/accessibility_service_label">
|
||||
android:label="@string/accessibility_service_label"
|
||||
tools:ignore="AccessibilityPolicy">
|
||||
<intent-filter>
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package rip.min.digica.service
|
||||
|
||||
import android.accessibilityservice.AccessibilityService
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ComponentName
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Handler
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import androidx.collection.emptyLongSet
|
||||
import java.util.Calendar
|
||||
|
||||
@SuppressLint("AccessibilityPolicy")
|
||||
class DigicaService : AccessibilityService() {
|
||||
private lateinit var appLabel: String
|
||||
private lateinit var serviceLabel: String
|
||||
|
||||
private var wasLastViewingAppInfo = false
|
||||
private var wasLastViewingThisAppInfo = false
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
@ -28,25 +29,30 @@ class DigicaService : AccessibilityService() {
|
|||
}
|
||||
|
||||
override fun onAccessibilityEvent(event: AccessibilityEvent?) {
|
||||
if (event == null) return
|
||||
if (event == null || event.packageName == null) return
|
||||
|
||||
if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
|
||||
val pkgName = event.packageName.toString()
|
||||
val className = event.className;
|
||||
val className = event.className
|
||||
|
||||
// Is force stop dialog possibly open?
|
||||
val possiblyForceStop = pkgName == "com.android.settings"
|
||||
val commonSettingsRoot = rootInActiveWindow?.getChild(0)?.getChild(0)?.getChild(0)
|
||||
?.getChild(0)?.getChild(0)
|
||||
|
||||
// Is force stop dialog open?
|
||||
val forceStop = pkgName == "com.android.settings"
|
||||
&& className == "androidx.compose.ui.window.DialogWrapper"
|
||||
&& commonSettingsRoot?.childCount == 4
|
||||
|
||||
// Check if we are on App info page in settings
|
||||
if (pkgName == "com.android.settings") {
|
||||
if (className == "com.android.settings.spa.SpaActivity"
|
||||
&& event.text.getOrNull(0) == "App info"
|
||||
) wasLastViewingAppInfo = true;
|
||||
// If we did not switch to what is maybe the force stop dialog,
|
||||
// reset the flag
|
||||
else if (!possiblyForceStop)
|
||||
wasLastViewingAppInfo = false;
|
||||
// Is user trying to force stop?
|
||||
val attemptingForceStop = wasLastViewingThisAppInfo && forceStop
|
||||
|
||||
// Check if the last app info page visited was this app's
|
||||
if (pkgName == "com.android.settings"
|
||||
&& className == "com.android.settings.spa.SpaActivity"
|
||||
&& commonSettingsRoot?.childCount == 1
|
||||
) {
|
||||
wasLastViewingThisAppInfo =
|
||||
commonSettingsRoot.getChild(0)?.text.toString() == appLabel
|
||||
}
|
||||
|
||||
// Is user trying to uninstall this app?
|
||||
|
@ -65,9 +71,6 @@ class DigicaService : AccessibilityService() {
|
|||
|| pkgName == "com.aliucord"
|
||||
|| pkgName == "app.revanced.android.youtube"
|
||||
|
||||
// Is user trying to force stop?
|
||||
val attemptingForceStop = possiblyForceStop && wasLastViewingAppInfo;
|
||||
|
||||
// Get time
|
||||
val cal = Calendar.getInstance()
|
||||
val day = cal.get(Calendar.DAY_OF_WEEK)
|
||||
|
@ -101,6 +104,7 @@ class DigicaService : AccessibilityService() {
|
|||
) {
|
||||
// Stop them from doing that
|
||||
Log.i("DigicaService", "Preventing action")
|
||||
Log.d("DigicaService", event.toString())
|
||||
leaveDelayed(100L)
|
||||
leaveDelayed(200L)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<resources>
|
||||
<string name="app_name">digica</string>
|
||||
<string name="accessibility_service_label">digica ☆</string>
|
||||
<string name="app_settings_name">digica settings</string>
|
||||
<string name="accessibility_service_label">digica service</string>
|
||||
<string name="accessibility_service_description">allows digica to function</string>
|
||||
</resources>
|
|
@ -4,6 +4,6 @@
|
|||
android:accessibilityFlags="flagDefault"
|
||||
android:accessibilityFeedbackType="feedbackGeneric"
|
||||
android:notificationTimeout="0"
|
||||
android:canRetrieveWindowContent="false"
|
||||
android:canRetrieveWindowContent="true"
|
||||
android:settingsActivity="rip.min.digica.MainActivity"
|
||||
/>
|
Loading…
Reference in New Issue