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

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

Merge "Keyguard: Change carrier text to "airplane mode" in APM"

parents 4684100e d88c3de1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -38,4 +38,7 @@
    <!-- monitor locale change -->
    <bool name="config_monitor_locale_change">false</bool>
    <bool name="config_showEmergencyCallOnlyInLockScreen">false</bool>

    <!-- display airplane mode in lock sreen when phone is in APM mode -->
    <bool name="config_display_APM">false</bool>
</resources>
+20 −1
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ public class CarrierText extends TextView {

    private LockPatternUtils mLockPatternUtils;

    protected boolean mAirplaneMode;
    protected boolean showAPM;

    private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
        private CharSequence mPlmn;
        private CharSequence mSpn;
@@ -55,6 +58,12 @@ public class CarrierText extends TextView {
            updateCarrierText(mSimState, mPlmn, mSpn);
        }

        @Override
        void onAirplaneModeChanged(boolean on) {
            mAirplaneMode = on;
            updateCarrierText(mSimState, mPlmn, mSpn);
        }

        public void onScreenTurnedOff(int why) {
            setSelected(false);
        };
@@ -88,10 +97,20 @@ public class CarrierText extends TextView {
        mLockPatternUtils = new LockPatternUtils(mContext);
        boolean useAllCaps = mContext.getResources().getBoolean(R.bool.kg_use_all_caps);
        setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
        showAPM = context.getResources().getBoolean(R.bool.config_display_APM);
    }

    protected void updateCarrierText(State simState, CharSequence plmn, CharSequence spn) {
        setText(getCarrierTextForSimState(simState, plmn, spn));
        CharSequence text = "";

        if (mAirplaneMode && showAPM) {
            // if airplane mode is on, show "airplane mode"
            text = getContext().getText(com.android.internal.R.string.lockscreen_airplane_mode_on);
        } else {
            text = getCarrierTextForSimState(simState, plmn, spn);
        }

        setText(text);
    }

    @Override
+20 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ public class KeyguardUpdateMonitor {
    protected static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318;
    private static final int MSG_SCREEN_TURNED_ON = 319;
    private static final int MSG_SCREEN_TURNED_OFF = 320;
    private static final int MSG_AIRPLANE_MODE_CHANGED = 321;

    private static KeyguardUpdateMonitor sInstance;

@@ -206,6 +207,9 @@ public class KeyguardUpdateMonitor {
                case MSG_SCREEN_TURNED_ON:
                    handleScreenTurnedOn();
                    break;
                case MSG_AIRPLANE_MODE_CHANGED:
                    handleAirplaneModeChanged((Boolean) msg.obj);
                    break;
            }
        }
    };
@@ -318,6 +322,9 @@ public class KeyguardUpdateMonitor {
            } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
                mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_REMOVED,
                       intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
            } else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
                boolean state = intent.getBooleanExtra("state", false);
                mHandler.sendMessage(mHandler.obtainMessage(MSG_AIRPLANE_MODE_CHANGED, state));
            } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
                dispatchBootCompleted();
            } else if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) {
@@ -596,6 +603,15 @@ public class KeyguardUpdateMonitor {
        }
    }

    private void handleAirplaneModeChanged(boolean on) {
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onAirplaneModeChanged(on);
            }
        }
    }

    private void handleUserInfoChanged(int userId) {
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
@@ -647,6 +663,7 @@ public class KeyguardUpdateMonitor {
        filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
        filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
        filter.addAction(Intent.ACTION_USER_REMOVED);
        filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
        context.registerReceiver(mBroadcastReceiver, filter);

@@ -1101,6 +1118,9 @@ public class KeyguardUpdateMonitor {
                mDisplayClientState.intent);
        callback.onMusicPlaybackStateChanged(mDisplayClientState.playbackState,
                mDisplayClientState.playbackEventTime);
        boolean airplaneModeOn = Settings.System.getInt(
            mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
        callback.onAirplaneModeChanged(airplaneModeOn);
    }

    public void sendKeyguardVisibilityChanged(boolean showing) {
+7 −0
Original line number Diff line number Diff line
@@ -190,4 +190,11 @@ class KeyguardUpdateMonitorCallback {
     * @param subscription The subscription for which onRefreshCarrierInfo is meant
     */
    void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn, int subscription) { }

    /**
     * Called when the airplane mode changes.
     *
     * @param on Indicates if the airplane mode is now enable.
     */
    void onAirplaneModeChanged(boolean on) { }
}
+18 −7
Original line number Diff line number Diff line
@@ -51,6 +51,12 @@ public class MSimCarrierText extends CarrierText {
            mSimState[sub] = simState;
            updateCarrierText(mSimState, mPlmn, mSpn);
        }

        @Override
        void onAirplaneModeChanged(boolean on) {
            mAirplaneMode = on;
            updateCarrierText(mSimState, mPlmn, mSpn);
        }
    };

    private void initialize() {
@@ -71,14 +77,19 @@ public class MSimCarrierText extends CarrierText {

    protected void updateCarrierText(State []simState, CharSequence []plmn, CharSequence []spn) {
        CharSequence text = "";

        if (mAirplaneMode && showAPM) {
            text = getContext().getText(com.android.internal.R.string.lockscreen_airplane_mode_on);
        } else {
            for (int i = 0; i < simState.length; i++) {
                CharSequence displayText = getCarrierTextForSimState(simState[i], plmn[i], spn[i]);
                if (mContext.getResources().getBoolean(R.bool.kg_use_all_caps)) {
                displayText = (displayText != null ? displayText.toString().toUpperCase() : "");
                    displayText = (displayText != null ?
                            displayText.toString().toUpperCase() : "");
                }
                text = (TextUtils.isEmpty(text) ? displayText : getContext().getString(
                        R.string.msim_carrier_text_format, text, displayText));
            }
            text = (TextUtils.isEmpty(text)
                    ? displayText
                    : getContext().getString(R.string.msim_carrier_text_format, text, displayText));
        }
        Log.d(TAG, "updateCarrierText: text = " + text);
        setText(text);