mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-05 10:49:26 +02:00
Fix blocking home screen with the accessibility service enabled
This commit is contained in:
parent
d3403b6866
commit
5128e3587e
4 changed files with 13 additions and 2 deletions
|
@ -29,6 +29,7 @@ abstract class PlatformIntegration(
|
|||
abstract fun getLocalAppActivities(deviceId: String): Collection<AppActivity>
|
||||
abstract fun getLocalAppTitle(packageName: String): String?
|
||||
abstract fun getAppIcon(packageName: String): Drawable?
|
||||
abstract fun getLauncherAppPackageName(): String?
|
||||
abstract fun getCurrentProtectionLevel(): ProtectionLevel
|
||||
abstract fun getForegroundAppPermissionStatus(): RuntimePermissionStatus
|
||||
abstract fun getDrawOverOtherAppsPermissionStatus(): RuntimePermissionStatus
|
||||
|
|
|
@ -101,6 +101,12 @@ class AndroidIntegration(context: Context): PlatformIntegration(maximumProtectio
|
|||
return AndroidIntegrationApps.getAppIcon(packageName, context)
|
||||
}
|
||||
|
||||
override fun getLauncherAppPackageName(): String? {
|
||||
return Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Intent.CATEGORY_HOME)
|
||||
.resolveActivity(context.packageManager)?.packageName
|
||||
}
|
||||
|
||||
override fun getCurrentProtectionLevel(): ProtectionLevel {
|
||||
return AdminStatus.getAdminStatus(context, policyManager)
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ class DummyIntegration(
|
|||
return null
|
||||
}
|
||||
|
||||
override fun getLauncherAppPackageName(): String? = null
|
||||
|
||||
override fun getCurrentProtectionLevel(): ProtectionLevel {
|
||||
return protectionLevel
|
||||
}
|
||||
|
|
|
@ -146,8 +146,10 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
appLogic.platformIntegration.setShowBlockingOverlay(true)
|
||||
|
||||
if (appLogic.platformIntegration.isAccessibilityServiceEnabled()) {
|
||||
AccessibilityService.instance?.showHomescreen()
|
||||
delay(100)
|
||||
if (blockedAppPackageName != appLogic.platformIntegration.getLauncherAppPackageName()) {
|
||||
AccessibilityService.instance?.showHomescreen()
|
||||
delay(100)
|
||||
}
|
||||
}
|
||||
|
||||
appLogic.platformIntegration.showAppLockScreen(blockedAppPackageName, blockedAppActivityName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue