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

Commit 5ccaaff4 authored by Richard LIU's avatar Richard LIU
Browse files

Hide emergency button when OOS

Hide emergency button when OOS in lock screen

Change-Id: Ia3c360755ab74b2c688833f9972710304a195f65
parent 169ae8db
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,4 +17,5 @@
<resources>
    <bool name="kg_show_ime_at_screen_on">true</bool>
    <bool name="kg_use_all_caps">true</bool>
    <bool name="kg_hide_emgcy_btn_when_oos">false</bool>
</resources>
+11 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.telecom.TelecomManager;
import android.telephony.ServiceState;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
@@ -58,6 +59,11 @@ public class EmergencyButton extends Button {
        public void onPhoneStateChanged(int phoneState) {
            updateEmergencyCallButton();
        }

        @Override
        public void onServiceStateChanged(int sub, ServiceState state) {
            updateEmergencyCallButton();
        }
    };

    public interface EmergencyButtonCallback {
@@ -153,6 +159,11 @@ public class EmergencyButton extends Button {
                    visible = mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser()) ||
                            SystemProperties.getBoolean("persist.radio.emgcy_btn_onswipe", false);
                }

                if (mContext.getResources().getBoolean(R.bool.kg_hide_emgcy_btn_when_oos)) {
                    KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
                    visible = visible && !monitor.isOOS();
                }
            }
        }
        if (visible) {
+16 −0
Original line number Diff line number Diff line
@@ -1197,6 +1197,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get();
            if (cb != null) {
                cb.onRefreshCarrierInfo();
                cb.onServiceStateChanged(subId, serviceState);
            }
        }
    }
@@ -1423,6 +1424,21 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    public boolean isOOS()
    {
        boolean ret = true;
        for (int subId : mServiceStates.keySet()) {
            ServiceState state = mServiceStates.get(subId);
            if (((state.getVoiceRegState() != ServiceState.STATE_OUT_OF_SERVICE)
                    && (state.getVoiceRegState() != ServiceState.STATE_POWER_OFF))
                    || (state.isEmergencyOnly())) {
                ret = false;
                break;
            }
        }
        return ret;
    }

    /**
     * @return true if and only if the state has changed for the specified {@code slotId}
     */
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.Bitmap;
import android.media.AudioManager;
import android.os.SystemClock;
import android.hardware.fingerprint.FingerprintManager;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.view.WindowManagerPolicy;

@@ -122,6 +123,13 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }

    /**
     * Called when the sevice state changes.
     * @param subId
     * @param serviceState
     */
    public void onServiceStateChanged(int sub, ServiceState state) { }

    /**
     * Called when the user's info changed.
     */