diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bouncer/util/BouncerTestUtils.kt | 38 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java | 7 |
2 files changed, 43 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/util/BouncerTestUtils.kt b/packages/SystemUI/src/com/android/systemui/bouncer/util/BouncerTestUtils.kt new file mode 100644 index 000000000000..08a79c92919f --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/bouncer/util/BouncerTestUtils.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.bouncer.util + +import android.app.ActivityManager +import android.content.res.Resources +import com.android.systemui.res.R +import java.io.File + +private const val ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key" + +/** + * In general, we enable unlocking the insecure keyguard with the menu key. However, there are some + * cases where we wish to disable it, notably when the menu button placement or technology is prone + * to false positives. + * + * @return true if the menu key should be enabled + */ +fun Resources.shouldEnableMenuKey(): Boolean { + val configDisabled = getBoolean(R.bool.config_disableMenuKeyInLockScreen) + val isTestHarness = ActivityManager.isRunningInTestHarness() + val fileOverride = File(ENABLE_MENU_KEY_FILE).exists() + return !configDisabled || isTestHarness || fileOverride +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 1ea26e5727ac..5ae24f76a9bf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -63,6 +63,7 @@ import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInte import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor; import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags; import com.android.systemui.bouncer.ui.BouncerView; +import com.android.systemui.bouncer.util.BouncerTestUtilsKt; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor; @@ -1552,8 +1553,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } public boolean shouldDismissOnMenuPressed() { - return mPrimaryBouncerView.getDelegate() != null - && mPrimaryBouncerView.getDelegate().shouldDismissOnMenuPressed(); + return (mPrimaryBouncerView.getDelegate() != null + && mPrimaryBouncerView.getDelegate().shouldDismissOnMenuPressed()) || ( + ComposeBouncerFlags.INSTANCE.isEnabled() && BouncerTestUtilsKt.shouldEnableMenuKey( + mContext.getResources())); } public boolean interceptMediaKey(KeyEvent event) { |