双卡项目如何在状态栏显示或隐藏G,3G以及卡1和卡2的信号标识

1.KK版本上(4.4)如何隐藏有SIM卡1,2标记,如何去掉状态栏G、3G图标

2.L版本上(5.0)如何增加有SIM卡1,2标记

3.特别的,目前M版本不支持该功能。

一 KK版本上(4.4)

1、如何隐藏有SIM卡1,2标记

KK上默认是显示1,2卡标识的。

如果隐藏它们,在文件SignalClusterView.java上由mMobileSlotIndicator变量控制

将mMobileSlotIndicator出现的地方屏蔽掉就可以

2、如何去掉状态栏G、3G图标

去掉方法很简单,就是把这个View隐藏就行了,具体修改如下 SignalClusterView.java (frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar)

apply():

……

//hide network icon begin

/* int state = SIMHelper.getSimIndicatorStateGemini(i);//hide network icon

if (!mIsAirplaneMode

&& SIMHelper.isSimInserted(i)

&& PhoneConstants.SIM_INDICATOR_LOCKED != state

&& PhoneConstants.SIM_INDICATOR_SEARCHING != state

&& PhoneConstants.SIM_INDICATOR_INVALID != state

&& PhoneConstants.SIM_INDICATOR_RADIOOFF != state) {

……

} else {*/

mSignalNetworkType[i].setImageDrawable(null);

mSignalNetworkType[i].setVisibility(View.GONE);

//}

//hide network icon end

……

二 L版本上(5.0)如何增加有SIM卡1,2标记

L版本5.0默认是没有显示的1.2卡标识的!

如果要增加1,2标识,可按下面步骤添加:

1、Signal_Cluster_View.xml

2、SignalClusterView.java 文件添加

// add private ImageView[] mMobileSlotIndicator; //add int[] slots_indicators=new int[]{R.drawable.sim1_indicator,R.drawable.sim2_indicator}; // 图片sim1_indicator,sim2_indicator是你制作的sim1,sim2标识 public SignalClusterView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mSlotCount = SIMHelper.getSlotCount(); ........ // add mMobileSlotIndicator= new ImageView[mSlotCount]; }

onAttachedToWindow()那里 //add for (int i = SIMHelper.SLOT_INDEX_DEFAULT ; i < mSlotCount; i++) { final int k = i + 1; if (i == SIMHelper.SLOT_INDEX_DEFAULT) { // load views for first SIM card mMobile[i] = (ImageView) findViewById(R.id.mobile_signal); mMobileGroup[i] = (ViewGroup) findViewById(R.id.mobile_combo); mMobileType[i] = (ImageView) findViewById(R.id.mobile_type); mSpacer[i] = findViewById(R.id.spacer); mSignalClusterCombo[i] = (ViewGroup) findViewById(R.id.signal_cluster_combo); /// M: Support "Service Network Type on Statusbar" mSignalNetworkType[i] = (ImageView) findViewById(R.id.network_type);

//tdp add mMobileSlotIndicator[i] = (ImageView) findViewById(R.id.mobile_slot_indicator); } else { mMobile[i] = (ImageView) findViewWithTag("mobile_signal_" + k); mMobileGroup[i] = (ViewGroup) findViewWithTag("mobile_combo_" + k); mMobileType[i] = (ImageView) findViewWithTag("mobile_type_" + k); mSpacer[i] = findViewWithTag("spacer_" + k); mSignalClusterCombo[i] = (ViewGroup) findViewWithTag("signal_cluster_combo_" + k); /// M: Support "Service Network Type on Statusbar" mSignalNetworkType[i] = (ImageView) findViewWithTag("network_type_" + k);

//tdp add mMobileSlotIndicator[i] = (ImageView) findViewWithTag("mobile_slot_indicator_"+k); } //add mMobileSlotIndicator[i].setImageDrawable(slots_indicators[i]); mMobileSlotIndicator[i].setVisibility(View.VISIBLE); } onDetachedFromWindow()那里 //add @Override protected void onDetachedFromWindow() { mVpn = null; mWifiGroup = null; mWifi = null; /// M: WifiActivityIcon mWifiActivity = null;

for (int i = SIMHelper.SLOT_INDEX_DEFAULT; i < mSlotCount ; i++) { mMobileGroup[i] = null; mMobile[i] = null; mMobileType[i] = null; mSpacer[i] = null; //add mMobileSlotIndicator[i] = null; }