System UI native tower replaced by five grid tower

Keywords: Android Java Google xml

As shown in the figure below: to customize Google's native integrated tower icon into a grid icon, the relevant code flow:

The native signal tower is shown in the figure below:

Schematic diagram of customized five grid signal tower:

 

 

The original scheme is drawn by SignalDrawable according to the current signal strength mSignalStrength. The replacement scheme is to replace the current signal strength with the corresponding xml file.

1. When the signal strength of the mobile phone changes, it will return:

/home/android/code/U304_0322/android/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java

class MobilePhoneStateListener extends PhoneStateListener {
    public MobilePhoneStateListener(int subId, Looper looper) {
        super(subId, looper);
    }
    @Override
    public void onSignalStrengthsChanged(SignalStrength signalStrength) {
        if (DEBUG) {
            Log.d(mTag, "onSignalStrengthsChanged signalStrength=" + signalStrength +
                    ((signalStrength == null) ? "" : (" level=" + signalStrength.getLevel())));
        }
        mSignalStrength = signalStrength;
        updateTelephony();
    }
    ......
}

The signal strength value will be encapsulated and transferred to the tower strength change update place for refresh:

/home/android/code/U304_0322/android/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java

private void updateState(MobileIconState state) {
    setContentDescription(state.contentDescription);
    if (mState.visible != state.visible) {
        mMobileGroup.setVisibility(state.visible ? View.VISIBLE : View.GONE);
        requestLayout();
    }
    //Signal strength changes, refresh icon
    if (mState.strengthId != state.strengthId) {
        //Mmobiledrawable. Setlevel (state. Stringthid); / / native
        mMobile.setImageDrawable(getSignalIcon(state.strengthId));//Replacement scheme
        // TINNO END
    }
    ......
}
private static final int STATE_NONE = 0;//Data switch off
private static final int STATE_EMPTY = 1;
private static final int STATE_CUT = 2;//Data switch on
private static final int LEVEL_MASK = 0xff;
private static final int STATE_SHIFT = 16;
private static final int STATE_MASK = 0xff << STATE_SHIFT;
private Drawable getSignalIcon(int strengthId) {
    int state = (strengthId & STATE_MASK) >> STATE_SHIFT;
    int level = strengthId & LEVEL_MASK;
    int signalRes = R.drawable.ic_qs_5bar_signal_0;
    if (state == STATE_EMPTY) {//No Service
        signalRes = R.drawable.ic_qs_5bar_signal_no_service;
    } else if (state == STATE_NONE || state == STATE_CUT) {
        switch (level) {
            case 0:
                signalRes = state == STATE_NONE ? R.drawable.ic_qs_5bar_signal_full_1
                        : R.drawable.ic_qs_5bar_signal_1;
                break;
            case 1:signalRes = state == STATE_NONE ? R.drawable.ic_qs_5bar_signal_full_2
                        : R.drawable.ic_qs_5bar_signal_2;
                break;
            case 2:
                signalRes = state == STATE_NONE ? R.drawable.ic_qs_5bar_signal_full_3
                        : R.drawable.ic_qs_5bar_signal_3;
                break;
            case 3:
                signalRes = state == STATE_NONE ? R.drawable.ic_qs_5bar_signal_full_4
                        : R.drawable.ic_qs_5bar_signal_4;
                break;
            case 4:
                signalRes = state == STATE_NONE ? R.drawable.ic_qs_5bar_signal_full_5
                        : R.drawable.ic_qs_5bar_signal_5;
                break;
            default:
                signalRes = state == STATE_NONE ? R.drawable.ic_qs_5bar_signal_full_0
                        : R.drawable.ic_qs_5bar_signal_0;
                break;
        }
    }
    return getContext().getResources().getDrawable(signalRes);
}

Corresponding five grid signal icon resource file:

https://download.csdn.net/download/tj_shenzhendaxue/11156001

Posted by ShaolinF on Mon, 18 Nov 2019 09:46:44 -0800