Fix blocking home screen with the accessibility service enabled

This commit is contained in:
Jonas L 2019-04-15 00:00:00 +00:00
parent d3403b6866
commit 5128e3587e
4 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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)
}

View file

@ -50,6 +50,8 @@ class DummyIntegration(
return null
}
override fun getLauncherAppPackageName(): String? = null
override fun getCurrentProtectionLevel(): ProtectionLevel {
return protectionLevel
}

View file

@ -146,9 +146,11 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
appLogic.platformIntegration.setShowBlockingOverlay(true)
if (appLogic.platformIntegration.isAccessibilityServiceEnabled()) {
if (blockedAppPackageName != appLogic.platformIntegration.getLauncherAppPackageName()) {
AccessibilityService.instance?.showHomescreen()
delay(100)
}
}
appLogic.platformIntegration.showAppLockScreen(blockedAppPackageName, blockedAppActivityName)
}