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

Commit c180dd69 authored by kaiyiz's avatar kaiyiz Committed by Steve Kondik
Browse files

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

The original design did not consider the airplane mode is enabled.

When we receive the airplane mode changed broadcast, change the carrier
text as "airplane mode" in lock screen.

CRs-Fixed: 655336

Change-Id: Ied92ea3273cb0b13ea1b9b5d64f30f99bde22a3c
parent 554b489c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -931,6 +931,7 @@
    <string name="lockscreen_sim_puk_locked_instructions" msgid="8127916255245181063">"请参阅《用户指南》或与客服人员联系。"</string>
    <string name="lockscreen_sim_locked_message" msgid="8066660129206001039">"SIM卡已被锁定。"</string>
    <string name="lockscreen_sim_unlock_progress_dialog_message" msgid="595323214052881264">"正在解锁SIM卡..."</string>
    <string name="lockscreen_airplane_mode_on">"飞行模式"</string>
    <string name="lockscreen_too_many_failed_attempts_dialog_message" msgid="6481623830344107222">"您已经 <xliff:g id="NUMBER_0">%d</xliff:g> 次错误地绘制了解锁图案。\n\n请在 <xliff:g id="NUMBER_1">%d</xliff:g> 秒后重试。"</string>
    <string name="lockscreen_too_many_failed_password_attempts_dialog_message" msgid="2725973286239344555">"您已经 <xliff:g id="NUMBER_0">%d</xliff:g> 次错误地输入了密码。\n\n请在 <xliff:g id="NUMBER_1">%d</xliff:g> 秒后重试。"</string>
    <string name="lockscreen_too_many_failed_pin_attempts_dialog_message" msgid="6216672706545696955">"您已经<xliff:g id="NUMBER_0">%d</xliff:g>次输错了PIN码。\n\n请在<xliff:g id="NUMBER_1">%d</xliff:g>秒后重试。"</string>
+17 −0
Original line number Diff line number Diff line
@@ -30,6 +30,23 @@
**
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView
        android:id="@+id/airplane_mode"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center"
        android:gravity="center"
        android:paddingLeft="12dp"
        android:paddingRight="12dp"
        android:ellipsize="marquee"
        android:singleLine="true"
        android:textDirection = "locale"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="?android:attr/textColorSecondary"
        android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
        android:visibility="gone" />

    <TextView
        android:id="@+id/carrier1"
        android:layout_width="0dip"
+2 −0
Original line number Diff line number Diff line
@@ -32,4 +32,6 @@
    <!-- True if we need to show on "Slide" lock screen -->
    <bool name="config_showEmergencyButton">false</bool>

	<!-- display airplane mode in lock sreen when phone is in APM mode -->
	<bool name="config_display_APM">false</bool>
</resources>
+39 −0
Original line number Diff line number Diff line
@@ -44,9 +44,12 @@ public class CarrierText extends LinearLayout {

    private LockPatternUtils mLockPatternUtils;

    private boolean mShowAPM;

    private KeyguardUpdateMonitor mUpdateMonitor;
    private TextView mOperatorName[];
    private TextView mOperatorSeparator[];
    private TextView mAirplaneModeText;

    private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
        @Override
@@ -60,6 +63,31 @@ public class CarrierText extends LinearLayout {
                mUpdateMonitor.getTelephonySpn(subId), subId);
        }

        @Override
        void onAirplaneModeChanged(boolean on) {
            if (on && mShowAPM) {
                for (int i = 0; i < mNumPhones; i++) {
                    mOperatorName[i].setVisibility(View.GONE);
                    if (i < mNumPhones-1) {
                        mOperatorSeparator[i].setVisibility(View.GONE);
                    }
                }
                if (mAirplaneModeText != null) {
                    mAirplaneModeText.setVisibility(View.VISIBLE);
                }
            } else {
                for (int i = 0; i < mNumPhones; i++) {
                    mOperatorName[i].setVisibility(View.VISIBLE);
                    if (i < mNumPhones-1) {
                        mOperatorSeparator[i].setVisibility(View.VISIBLE);
                    }
                }
                if (mAirplaneModeText != null) {
                    mAirplaneModeText.setVisibility(View.GONE);
                }
            }
        }

        public void onScreenTurnedOff(int why) {
            for (int i = 0; i < mNumPhones; i++) {
                mOperatorName[i].setSelected(false);
@@ -101,6 +129,8 @@ public class CarrierText extends LinearLayout {

        mOperatorName = new TextView[mNumPhones];
        mOperatorSeparator = new TextView[mNumPhones-1];

        mShowAPM = context.getResources().getBoolean(R.bool.config_display_APM);
    }

    protected void updateCarrierText(State simState, CharSequence plmn, CharSequence spn,
@@ -113,11 +143,19 @@ public class CarrierText extends LinearLayout {
            return;
        }

        String airplaneMode = getResources().getString(
                com.android.internal.R.string.lockscreen_airplane_mode_on);
        CharSequence text = getCarrierTextForSimState(simState, plmn, spn);
        TextView updateCarrierView = mOperatorName[phoneId];
        if (mContext.getResources().getBoolean(R.bool.kg_use_all_caps)) {
            if (mAirplaneModeText != null && mShowAPM) {
                mAirplaneModeText.setText(airplaneMode.toUpperCase());
            }
            updateCarrierView.setText(text != null ? text.toString().toUpperCase() : null);
        } else {
            if (mAirplaneModeText != null && mShowAPM) {
                mAirplaneModeText.setText(airplaneMode);
            }
            updateCarrierView.setText(text != null ? text.toString() : null);
        }
    }
@@ -141,6 +179,7 @@ public class CarrierText extends LinearLayout {
                mOperatorSeparator[i].setText("|");
            }
        }
        mAirplaneModeText = (TextView) findViewById(R.id.airplane_mode);
    }

    @Override
+20 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private 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 final int MSG_KEYGUARD_BOUNCER_CHANGED = 322;
    private static final int MSG_FINGERPRINT_PROCESSED = 323;
    private static final int MSG_FINGERPRINT_ACQUIRED = 324;
@@ -229,6 +230,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                case MSG_SCREEN_TURNED_ON:
                    handleScreenTurnedOn();
                    break;
                case MSG_AIRPLANE_MODE_CHANGED:
                    handleAirplaneModeChanged((Boolean) msg.obj);
                    break;
                case MSG_FINGERPRINT_ACQUIRED:
                    handleFingerprintAcquired(msg.arg1);
                    break;
@@ -432,6 +436,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            } 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_SUBINFO_RECORD_UPDATED.equals(action)) {
@@ -711,6 +718,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    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();
@@ -752,6 +768,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
        filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
        filter.addAction(Intent.ACTION_USER_REMOVED);
        filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        filter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
        filter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE);
        filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
@@ -1279,6 +1296,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            callback.onRefreshCarrierInfo(subId, mPlmn.get(subId), mSpn.get(subId));
            callback.onSimStateChanged(subId, mSimState.get(subId));
        }
        boolean airplaneModeOn = Settings.System.getInt(
                mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
        callback.onAirplaneModeChanged(airplaneModeOn);
    }

    public void sendKeyguardVisibilityChanged(boolean showing) {
Loading