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

Commit becf170a authored by burakov's avatar burakov Committed by Danny Burakov
Browse files

Verify it's an emergency call button before initiating an emergency call

Fixes: 308043315
Test: Manual
Flag: None
Change-Id: I1eafea12db0c431c6ec8bc60e8fc29a2879136fc
parent 71449d9e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.keyguard;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -57,7 +58,10 @@ public class EmergencyButton extends Button {
        super.onFinishInflate();
        if (mEmergencyAffordanceManager.needsEmergencyAffordance()) {
            setOnLongClickListener(v -> {
                if (!mLongPressWasDragged
                boolean isEmergencyCallButton = getVisibility() == View.VISIBLE
                        && TextUtils.equals(getText(), getEmergencyButtonLabel());
                if (isEmergencyCallButton
                        && !mLongPressWasDragged
                        && mEmergencyAffordanceManager.needsEmergencyAffordance()) {
                    mEmergencyAffordanceManager.performEmergencyCall();
                    return true;
@@ -122,4 +126,8 @@ public class EmergencyButton extends Button {
            setVisibility(View.GONE);
        }
    }

    private String getEmergencyButtonLabel() {
        return mContext.getString(com.android.internal.R.string.lockscreen_emergency_call);
    }
}