Disable All Apps keyboard shortcut during user setup.
Flag: EXEMPT bugfix Fix: 394238663 Test: go/testedequals Change-Id: I4a9175613686a358bd62800789b30262d9dc39cb
This commit is contained in:
1 parent
2b6f14b621
commit
6dec35f18e
4 files changed
+135
-18
No files matched your search
@@ -612,6 +612,7 @@ public class TaskbarManager {
|
||||
*/
|
||||
public void setSetupUIVisible(boolean isVisible) {
|
||||
mSharedState.setupUIVisible = isVisible;
|
||||
mAllAppsActionManager.setSetupUiVisible(isVisible);
|
||||
TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
|
||||
if (taskbar != null) {
|
||||
taskbar.setSetupUIVisible(isVisible);
|
||||
|
||||
@@ -21,10 +21,16 @@ import android.app.PendingIntent
|
||||
import android.app.RemoteAction
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Icon
|
||||
import android.provider.Settings
|
||||
import android.provider.Settings.Secure.USER_SETUP_COMPLETE
|
||||
import android.view.accessibility.AccessibilityManager
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.SettingsCache
|
||||
import com.android.launcher3.util.SettingsCache.OnChangeListener
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
private val USER_SETUP_COMPLETE_URI = Settings.Secure.getUriFor(USER_SETUP_COMPLETE)
|
||||
|
||||
/**
|
||||
* Registers a [RemoteAction] for toggling All Apps if needed.
|
||||
*
|
||||
@@ -38,6 +44,12 @@ class AllAppsActionManager(
|
||||
private val createAllAppsPendingIntent: () -> PendingIntent,
|
||||
) {
|
||||
|
||||
private val onSettingsChangeListener = OnChangeListener { v -> isUserSetupComplete = v }
|
||||
|
||||
init {
|
||||
SettingsCache.INSTANCE[context].register(USER_SETUP_COMPLETE_URI, onSettingsChangeListener)
|
||||
}
|
||||
|
||||
/** `true` if home and overview are the same Activity. */
|
||||
var isHomeAndOverviewSame = false
|
||||
set(value) {
|
||||
@@ -52,12 +64,27 @@ class AllAppsActionManager(
|
||||
updateSystemAction()
|
||||
}
|
||||
|
||||
/** `true` if the setup UI is visible. */
|
||||
var isSetupUiVisible = false
|
||||
set(value) {
|
||||
field = value
|
||||
updateSystemAction()
|
||||
}
|
||||
|
||||
private var isUserSetupComplete =
|
||||
SettingsCache.INSTANCE[context].getValue(USER_SETUP_COMPLETE_URI, 0)
|
||||
set(value) {
|
||||
field = value
|
||||
updateSystemAction()
|
||||
}
|
||||
|
||||
/** `true` if the action should be registered. */
|
||||
var isActionRegistered = false
|
||||
private set
|
||||
|
||||
private fun updateSystemAction() {
|
||||
val shouldRegisterAction = isHomeAndOverviewSame || isTaskbarPresent
|
||||
val isInSetupFlow = isSetupUiVisible || !isUserSetupComplete
|
||||
val shouldRegisterAction = (isHomeAndOverviewSame || isTaskbarPresent) && !isInSetupFlow
|
||||
if (isActionRegistered == shouldRegisterAction) return
|
||||
isActionRegistered = shouldRegisterAction
|
||||
|
||||
@@ -84,8 +111,10 @@ class AllAppsActionManager(
|
||||
isActionRegistered = false
|
||||
context
|
||||
.getSystemService(AccessibilityManager::class.java)
|
||||
?.unregisterSystemAction(
|
||||
GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS,
|
||||
)
|
||||
?.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS)
|
||||
SettingsCache.INSTANCE[context].unregister(
|
||||
USER_SETUP_COMPLETE_URI,
|
||||
onSettingsChangeListener,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user