Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3910907e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enable handling of keycode_menu key event on lockscreen when compose...

Merge "Enable handling of keycode_menu key event on lockscreen when compose bouncer is enabled" into main
parents 521960d1 646ffb65
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
/*
 * 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
}
+5 −2
Original line number Diff line number Diff line
@@ -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) {