Add soft blocking

This commit is contained in:
Jonas Lochmann 2020-11-02 01:00:00 +01:00
parent 405d896e2f
commit 0a24314d39
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
5 changed files with 21 additions and 4 deletions

View file

@ -231,4 +231,5 @@ object ExperimentalFlags {
const val REQUIRE_SYNC_FOR_PARENT_LOGIN = 2048L const val REQUIRE_SYNC_FOR_PARENT_LOGIN = 2048L
const val BLOCK_SPLIT_SCREEN = 4096L const val BLOCK_SPLIT_SCREEN = 4096L
const val HIDE_MANIPULATION_WARNING = 8192L const val HIDE_MANIPULATION_WARNING = 8192L
const val ENABLE_SOFT_BLOCKING = 16384L
} }

View file

@ -125,8 +125,12 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
private val isChromeOs = appLogic.context.packageManager.hasSystemFeature(PackageManager.FEATURE_PC) private val isChromeOs = appLogic.context.packageManager.hasSystemFeature(PackageManager.FEATURE_PC)
private suspend fun openLockscreen(blockedAppPackageName: String, blockedAppActivityName: String?) { private suspend fun openLockscreen(blockedAppPackageName: String, blockedAppActivityName: String?, enableSoftBlocking: Boolean) {
appLogic.platformIntegration.setShowBlockingOverlay(true, "$blockedAppPackageName:${blockedAppActivityName?.removePrefix(blockedAppPackageName)}") if (enableSoftBlocking) {
appLogic.platformIntegration.setShowBlockingOverlay(false)
} else {
appLogic.platformIntegration.setShowBlockingOverlay(true, "$blockedAppPackageName:${blockedAppActivityName?.removePrefix(blockedAppPackageName)}")
}
if (isChromeOs) { if (isChromeOs) {
LockActivity.currentInstances.forEach { it.finish() } LockActivity.currentInstances.forEach { it.finish() }
@ -139,7 +143,7 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
} }
} }
if (appLogic.platformIntegration.isAccessibilityServiceEnabled()) { if (appLogic.platformIntegration.isAccessibilityServiceEnabled() && !enableSoftBlocking) {
if (blockedAppPackageName != appLogic.platformIntegration.getLauncherAppPackageName()) { if (blockedAppPackageName != appLogic.platformIntegration.getLauncherAppPackageName()) {
AccessibilityService.instance?.showHomescreen() AccessibilityService.instance?.showHomescreen()
delay(100) delay(100)
@ -602,7 +606,11 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
// handle blocking // handle blocking
if (blockedForegroundApp != null) { if (blockedForegroundApp != null) {
openLockscreen(blockedForegroundApp.packageName, blockedForegroundApp.activityName) openLockscreen(
blockedAppPackageName = blockedForegroundApp.packageName,
blockedAppActivityName = blockedForegroundApp.activityName,
enableSoftBlocking = deviceRelatedData.experimentalFlags and ExperimentalFlags.ENABLE_SOFT_BLOCKING == ExperimentalFlags.ENABLE_SOFT_BLOCKING
)
} else { } else {
appLogic.platformIntegration.setShowBlockingOverlay(false) appLogic.platformIntegration.setShowBlockingOverlay(false)
} }

View file

@ -197,6 +197,12 @@ data class DiagnoseExperimentalFlagItem(
enableFlags = ExperimentalFlags.HIDE_MANIPULATION_WARNING, enableFlags = ExperimentalFlags.HIDE_MANIPULATION_WARNING,
disableFlags = ExperimentalFlags.HIDE_MANIPULATION_WARNING, disableFlags = ExperimentalFlags.HIDE_MANIPULATION_WARNING,
enable = { true } enable = { true }
),
DiagnoseExperimentalFlagItem(
label = R.string.diagnose_exf_esb,
enableFlags = ExperimentalFlags.ENABLE_SOFT_BLOCKING,
disableFlags = ExperimentalFlags.ENABLE_SOFT_BLOCKING,
enable = { true }
) )
) )
} }

View file

@ -67,6 +67,7 @@
<string name="diagnose_exf_rsl">Anmeldung von Eltern mit Anmeldeverhinderungskategorie nur nach einer Synchronisation erlauben</string> <string name="diagnose_exf_rsl">Anmeldung von Eltern mit Anmeldeverhinderungskategorie nur nach einer Synchronisation erlauben</string>
<string name="diagnose_exf_bss">Splitscreen automatisch beenden per Bedienhilfe</string> <string name="diagnose_exf_bss">Splitscreen automatisch beenden per Bedienhilfe</string>
<string name="diagnose_exf_hmw">Manipulationswarnung in der Kategorienliste ausblenden</string> <string name="diagnose_exf_hmw">Manipulationswarnung in der Kategorienliste ausblenden</string>
<string name="diagnose_exf_esb">Overlay und Home-Button nicht zum Sperren verwenden</string>
<string name="diagnose_bg_task_loop_ex">Hintergrundaufgabenschleifenfehler</string> <string name="diagnose_bg_task_loop_ex">Hintergrundaufgabenschleifenfehler</string>

View file

@ -67,6 +67,7 @@
<string name="diagnose_exf_rsl">Only allow login of parent users with limit login category after syncing</string> <string name="diagnose_exf_rsl">Only allow login of parent users with limit login category after syncing</string>
<string name="diagnose_exf_bss">Automatically disable splitscreen using the accessibility service</string> <string name="diagnose_exf_bss">Automatically disable splitscreen using the accessibility service</string>
<string name="diagnose_exf_hmw" tools:ignore="MissingTranslation">Hide manipulation warning in the category list</string> <string name="diagnose_exf_hmw" tools:ignore="MissingTranslation">Hide manipulation warning in the category list</string>
<string name="diagnose_exf_esb" tools:ignore="MissingTranslation">Do not use a overlay or the home button for blocking</string>
<string name="diagnose_bg_task_loop_ex">Background task loop exception</string> <string name="diagnose_bg_task_loop_ex">Background task loop exception</string>