最近俄罗斯客户要求,添加Volte Vowifi Tile,费了好多时间加好了,现在又要求,插指定mccmnc的卡才显示。
具体的实现如下:
PagedTileLayout.java 和QuickQSPanel.java 修改
PagedTileLayout.java
/*sun:jicong.wang add start {@*/
import com.android.systemui.qs.tiles.VoLTETile;
import com.android.systemui.qs.tiles.VoWifiTile;
import com.android.systemui.recents.events.component.ShowUserToastEvent;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import com.android.config.OptConfig;
import java.util.List;
/*sun:jicong.wang add end @}*/
...
private void distributeTiles() {
if (DEBUG) Log.d(TAG, "Distributing tiles");
final int NP = mPages.size();
for (int i = 0; i < NP; i++) {
mPages.get(i).removeAllViews();
}
int index = 0;
final int NT = mTiles.size();
for (int i = 0; i < NT; i++) {
TileRecord tile = mTiles.get(i);
if (mPages.get(index).isFull()) {
if (++index == mPages.size()) {
if (DEBUG) Log.d(TAG, "Adding page for "
+ tile.tile.getClass().getSimpleName());
mPages.add((TilePage) LayoutInflater.from(getContext())
.inflate(R.layout.qs_paged_page, this, false));
}
}
if (DEBUG) Log.d(TAG, "Adding " + tile.tile.getClass().getSimpleName() + " to "
+ index);
/*sun:jicong.wang add start {@*/
if (OptConfig.SUBCUSTOM_D3907_HD_TG_16_2_Vertex){
if (tile.tile instanceof VoLTETile || tile.tile instanceof VoWifiTile){
if (simStateEnable(mContext)){
mPages.get(index).addTile(tile);
}
} else {
mPages.get(index).addTile(tile);
}
} else {
mPages.get(index).addTile(tile);
}
/*sun:jicong.wang add end @}*/
}
if (mNumPages != index + 1) {
mNumPages = index + 1;
while (mPages.size() > mNumPages) {
mPages.remove(mPages.size() - 1);
}
if (DEBUG) Log.d(TAG, "Size: " + mNumPages);
mPageIndicator.setNumPages(mNumPages);
setAdapter(mAdapter);
mAdapter.notifyDataSetChanged();
setCurrentItem(0, false);
}
}
...
/*sun:jicong.wang add start {@*/
private boolean simStateEnable(Context context){
boolean result = false;
int simCount = 0;
SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
simCount = subscriptionManager.getActiveSubscriptionInfoCount();
if (simCount==0){
return false;
}
try{
List<SubscriptionInfo> subinfos = subscriptionManager.getActiveSubscriptionInfoList();
for (SubscriptionInfo info: subinfos){
if (info.getMcc() == 414 && info.getMnc() == 6){
result = true;
break;
}
}
} catch (Exception e){
e.printStackTrace();
return false;
}
return result;
}
/*sun:jicong.wang add end @}*/
QuickQSPanel.java
/*sun:jicong.wang add start {@*/
import java.util.List;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import com.android.config.OptConfig;
import com.android.systemui.qs.tiles.VoLTETile;
import com.android.systemui.qs.tiles.VoWifiTile;
/*sun:jicong.wang add end @}*/
...
@Override
public void setTiles(Collection<QSTile> tiles) {
ArrayList<QSTile> quickTiles = new ArrayList<>();
for (QSTile tile : tiles) {
/*sun:jicong.wang add start {@*/
if (OptConfig.SUBCUSTOM_D3907_HD_TG_16_2_Vertex){
if ((tile instanceof VoLTETile || tile instanceof VoWifiTile) && !simStateEnable(mContext)){
//no noting
} else {
quickTiles.add(tile);
}
} else {
quickTiles.add(tile);
}
/*sun:jicong.wang end @}*/
if (quickTiles.size() == mMaxTiles) {
break;
}
}
super.setTiles(quickTiles, true);
}
...
@Override
public void setTiles(Collection<QSTile> tiles) {
ArrayList<QSTile> quickTiles = new ArrayList<>();
for (QSTile tile : tiles) {
/*sun:jicong.wang add start {@*/
if (OptConfig.SUBCUSTOM_D3907_HD_TG_16_2_Vertex){
if ((tile instanceof VoLTETile || tile instanceof VoWifiTile) && !simStateEnable(mContext)){
//no noting
} else {
quickTiles.add(tile);
}
} else {
quickTiles.add(tile);
}
/*sun:jicong.wang end @}*/
if (quickTiles.size() == mMaxTiles) {
break;
}
}
super.setTiles(quickTiles, true);
}
...
/*sun:jicong.wang add start {@*/
private boolean simStateEnable(Context context){
boolean result = false;
int simCount = 0;
SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
simCount = subscriptionManager.getActiveSubscriptionInfoCount();
if (simCount==0){
return false;
}
try{
List<SubscriptionInfo> subinfos = subscriptionManager.getActiveSubscriptionInfoList();
for (SubscriptionInfo info: subinfos){
if (info.getMcc() == 414 && info.getMnc() == 6){
result = true;
break;
}
}
} catch (Exception e){
e.printStackTrace();
return false;
}
return result;
}
/*sun:jicong.wang add end @}*/