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

Commit 700a654d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Keyguard: Hide emergency button in OOS"

parents e6eb5418 5b033c21
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
@@ -27,6 +27,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.util.Slog;
import android.view.View;
@@ -64,6 +65,11 @@ public class EmergencyButton extends Button {
        public void onPhoneStateChanged(int phoneState) {
            updateEmergencyCallButton();
        }

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

    public interface EmergencyButtonCallback {
@@ -168,6 +174,11 @@ public class EmergencyButton extends Button {
                    visible = mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser()) ||
                              mContext.getResources().getBoolean(R.bool.config_showEmergencyButton);
                }

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

    public boolean isOOS()
    {
        boolean ret = true;
        int phoneCount = TelephonyManager.getDefault().getPhoneCount();

        for (int phoneId = 0; phoneId < phoneCount; phoneId++) {
            int[] subId = SubscriptionManager.getSubId(phoneId);
            if (subId != null && subId.length >= 1) {
                if (DEBUG) Log.d(TAG, "slot id:" + phoneId + " subId:" + subId[0]);
                ServiceState state = mServiceStates.get(subId[0]);
                if (state != null) {
                    if (state.isEmergencyOnly())
                        ret = false;
                    if ((state.getVoiceRegState() != ServiceState.STATE_OUT_OF_SERVICE)
                            && (state.getVoiceRegState() != ServiceState.STATE_POWER_OFF))
                        ret = false;
                    if (DEBUG) {
                        Log.d(TAG, "is emergency: " + state.isEmergencyOnly());
                        Log.d(TAG, "voice state: " + state.getVoiceRegState());
                    }
                } else {
                    if (DEBUG) Log.d(TAG, "state is NULL");
                }
            }
        }

        if (DEBUG) Log.d(TAG, "is Emergency supported: " + ret);
        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 subId, ServiceState state) { }

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