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

Commit 6b6de1d8 authored by Shaleen Jain's avatar Shaleen Jain
Browse files

SystemUI: code clean up and reformat

Change-Id: Idaee0a9e67aaf12b98125dfeceabb08df7600bcc
parent 287cd61f
Loading
Loading
Loading
Loading
+176 −185
Original line number Diff line number Diff line
@@ -18,48 +18,37 @@

package com.android.systemui.statusbar.policy;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.net.wimax.WimaxManagerConstants;
import android.os.Binder;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Telephony;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
import android.telephony.SubInfoRecord;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Slog;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.internal.util.AsyncChannel;

import com.android.systemui.R;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;

public class MSimNetworkControllerImpl extends NetworkControllerImpl {
    // debug
    static final String TAG = "StatusBar.MSimNetworkController";
@@ -105,8 +94,6 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
    String[] mSpn;
    String[] mPlmn;
    int mPhoneCount = 0;
    int PHONE_ID1 = PhoneConstants.PHONE_ID1;
    int PHONE_ID2 = PhoneConstants.PHONE_ID2;
    private HashMap<Long, Integer> mSubIdPhoneIdMap;
    ArrayList<MSimSignalCluster> mSimSignalClusters = new ArrayList<MSimSignalCluster>();
    ArrayList<TextView> mSubsLabelViews = new ArrayList<TextView>();
@@ -114,9 +101,11 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
    public interface MSimSignalCluster {
        void setWifiIndicators(boolean visible, int strengthIcon, int activityIcon,
                String contentDescription);

        void setMobileDataIndicators(boolean visible, int strengthIcon, int activityIcon,
                int typeIcon, String contentDescription, String typeContentDescription,
                int phoneId, int noSimIcon);

        void setIsAirplaneMode(boolean is, int airplaneIcon);
    }

@@ -227,9 +216,6 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
    protected void registerPhoneStateListener(Context context) {
        // telephony
        mPhone = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        //List<SubInfoRecord> subInfoList = SubscriptionManager.getActivatedSubInfoList(context);
        //if (subInfoList != null) {
            //int subCount = subInfoList.size();
        mSubIdPhoneIdMap = new HashMap<Long, Integer>();
        mPhoneCount = TelephonyManager.getDefault().getPhoneCount();
        Slog.d(TAG, "registerPhoneStateListener: " + mPhoneCount);
@@ -240,7 +226,6 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                long subId = subIdtemp[0];
                Slog.d(TAG, "registerPhoneStateListener subId: " + subId);
                Slog.d(TAG, "registerPhoneStateListener slotId: " + i);
                    //if (subInfoList.get(i).mSubId >= 0) {
                if (subId > 0) {
                    mSubIdPhoneIdMap.put(subId, i);
                    mMSimPhoneStateListener[i] = getPhoneStateListener(subId,
@@ -256,7 +241,6 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                }
            }
        }
        //}
    }

    private int getDefaultPhoneId() {
@@ -501,7 +485,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
    }

    private void setCarrierText() {
        String carrierName = mCarrierTextSub[PHONE_ID1];
        String carrierName = mCarrierTextSub[PhoneConstants.PHONE_ID1];
        for (int i = 1; i < mPhoneCount; i++) {
            carrierName = carrierName + "    " + mCarrierTextSub[i];
        }
@@ -524,13 +508,14 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
    // ===== Telephony ==============================================================

    private PhoneStateListener getPhoneStateListener(long subId, int slotId) {
        PhoneStateListener mMSimPhoneStateListener = new PhoneStateListener(subId) {
        return new PhoneStateListener(subId) {
            @Override
            public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                if (DEBUG) {
                    Slog.d(TAG, "onSignalStrengthsChanged received on phoneId :"
                            + getPhoneId(mSubId) + "signalStrength=" + signalStrength +
                        ((signalStrength == null) ? "" : (" level=" + signalStrength.getLevel())));
                            ((signalStrength == null) ? "" :
                            (" level=" + signalStrength.getLevel())));
                }
                mMSimSignalStrength[getPhoneId(mSubId)] = signalStrength;
                updateIconSet(getPhoneId(mSubId));
@@ -589,15 +574,15 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                int phoneId = getPhoneId(mSubId);
                if (DEBUG) {
                    Slog.d(TAG, "onDataConnectionStateChanged received on phoneId :"
                    + phoneId + " subid: " + mSubId+ "state=" + state + " type=" + networkType);
                            + phoneId + " subid: " + mSubId + "state=" + state
                            + " type=" + networkType);
                }

                // DSDS case: Data is active only on DDS. Ignore the Data Connection
                // State changed notifications of the other NON-DDS.
                Slog.d(TAG, "onDataConnectionStateChanged getDefaultDataSubId :" +
                        SubscriptionManager.getDefaultDataSubId());
                if ( mSubId ==
                        SubscriptionManager.getDefaultDataSubId()) {
                if (mSubId == SubscriptionManager.getDefaultDataSubId()) {
                    mDataState = state;
                    mDataNetType = networkType;
                }
@@ -621,7 +606,6 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                refreshViews(phoneId);
            }
        };
        return mMSimPhoneStateListener;
    }

    // ===== Wifi ===================================================================
@@ -653,29 +637,23 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
        IccCardConstants.State simState;
        String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
        // Obtain the phoneId info from intent.
        //long subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, 0);
        int phoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY, 0);
        //Integer sub = mSubIdPhoneIdMap.get(subId);
        Slog.d(TAG, "updateSimState for phoneId :" + phoneId);
        if (phoneId >= 0) {
            if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
                simState = IccCardConstants.State.ABSENT;
            }
            else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)
            } else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)
                    || IccCardConstants.INTENT_VALUE_ICC_IMSI.equals(stateExtra)
                    || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(stateExtra)) {
                simState = IccCardConstants.State.READY;
            }
            else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
            } else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
                final String lockedReason = intent.getStringExtra(IccCardConstants.
                        INTENT_KEY_LOCKED_REASON);
                if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
                    simState = IccCardConstants.State.PIN_REQUIRED;
                }
                else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
                } else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
                    simState = IccCardConstants.State.PUK_REQUIRED;
                }
                else {
                } else {
                    simState = IccCardConstants.State.PERSO_LOCKED;
                }
            } else {
@@ -714,7 +692,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
        }
    }

    private final void updateTelephonySignalStrength(int phoneId) {
    private void updateTelephonySignalStrength(int phoneId) {
        if (DEBUG) Slog.d(TAG, "updateTelephonySignalStrength: phoneId =" + phoneId);
        int dataSub = SubscriptionManager.getPhoneId(
                SubscriptionManager.getDefaultDataSubId());
@@ -796,7 +774,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                : mMSimServiceState[phoneId] != null && mMSimServiceState[phoneId].getRoaming());
    }

    private final void updateDataNetType(int phoneId) {
    private void updateDataNetType(int phoneId) {
        // DSDS case: Data is active only on DDS. Clear the icon for NON-DDS
        int dataSub = SubscriptionManager.getPhoneId(
                SubscriptionManager.getDefaultDataSubId());
@@ -862,7 +840,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
        return false;
    }

    private final void updateSimIcon(int phoneId) {
    private void updateSimIcon(int phoneId) {
        Slog.d(TAG, "In updateSimIcon card =" + phoneId + ", simState= " + mMSimState[phoneId]);
        if (mMSimState[phoneId] == IccCardConstants.State.ABSENT) {
            mNoMSimIconId[phoneId] = TelephonyIcons.getNoSimIcon(phoneId);
@@ -893,7 +871,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                mShow4GforLTE, mHspaDataDistinguishable, inetCondition);
    }

    private final void updateDataIcon(int phoneId) {
    private void updateDataIcon(int phoneId) {
        if (DEBUG) Slog.d(TAG, "updateDataIcon phoneId =" + phoneId);
        int iconId = 0;
        boolean visible = true;
@@ -962,8 +940,8 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
        StringBuilder str = new StringBuilder();
        boolean something = false;
        if (showPlmn && plmn != null) {
            if(mContext.getResources().getBoolean(com.android.internal.R.bool.config_display_rat) &&
                    mMSimServiceState[phoneId] != null) {
            if (mContext.getResources().getBoolean(com.android.internal.R.bool.config_display_rat)
                    && mMSimServiceState[phoneId] != null) {
                plmn = appendRatToNetworkName(plmn, mMSimServiceState[phoneId]);
            }
            str.append(plmn);
@@ -1153,10 +1131,21 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
            combinedLabel = mConnectedNetworkTypeName;
        }

        if (mAirplaneMode &&
                (mMSimServiceState[phoneId] == null || (!hasService(phoneId)
                    && !mMSimServiceState[phoneId].isEmergencyOnly()))) {
            // Only display the flight-mode icon if not in "emergency calls only" mode.
        final boolean displayAirplaneModeIcon;
        if (!mAirplaneMode) {
            // airplane mode disabled
            displayAirplaneModeIcon = false;
        } else if (mMSimServiceState[phoneId] == null) {
            // airplane mode enabled, but no state yet - display icon to be on the safe side
            displayAirplaneModeIcon = true;
        } else if (hasService(phoneId) || mMSimServiceState[phoneId].isEmergencyOnly()) {
            // don't display airplane mode icon in emergency calls mode
            displayAirplaneModeIcon = false;
        } else {
            displayAirplaneModeIcon = true;
        }

        if (displayAirplaneModeIcon) {

            // look again; your radios are now airplanes
            mMSimContentDescriptionPhoneSignal[phoneId] = mContext.getString(
@@ -1193,8 +1182,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
            }

            mMSimcombinedSignalIconId[phoneId] = mMSimDataSignalIconId[phoneId];
        }
        else if (!mMSimDataConnected[phoneId] && !mWifiConnected && !mBluetoothTethered &&
        } else if (!mMSimDataConnected[phoneId] && !mWifiConnected && !mBluetoothTethered &&
                !mWimaxConnected && !ethernetConnected) {
            // pretty much totally disconnected

@@ -1231,8 +1219,9 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
        }

        if (!mAirplaneMode && mMSimState[phoneId] == IccCardConstants.State.ABSENT) {
            mMSimPhoneSignalIconId[phoneId] = mMSimDataSignalIconId[phoneId]
                = mMSimDataTypeIconId[phoneId] = 0;
            mMSimPhoneSignalIconId[phoneId] = 0;
            mMSimDataSignalIconId[phoneId] = 0;
            mMSimDataTypeIconId[phoneId] = 0;
        }

        if (DEBUG) {
@@ -1280,8 +1269,7 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                || mLastAirplaneMode != mAirplaneMode
                || mMSimLastSimIconId[phoneId] != mNoMSimIconId[phoneId]
                || mMSimLastcombinedActivityIconId[phoneId]
                != mMSimcombinedActivityIconId[phoneId])
        {
                != mMSimcombinedActivityIconId[phoneId]) {
            // NB: the mLast*s will be updated later
            for (MSimSignalCluster cluster : mSimSignalClusters) {
                refreshSignalCluster(cluster, phoneId);
@@ -1459,9 +1447,12 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {

        if (mWimaxSupported) {
            pw.println("  - wimax ------");
            pw.print("  mIsWimaxEnabled="); pw.println(mIsWimaxEnabled);
            pw.print("  mWimaxConnected="); pw.println(mWimaxConnected);
            pw.print("  mWimaxIdle="); pw.println(mWimaxIdle);
            pw.print("  mIsWimaxEnabled=");
            pw.println(mIsWimaxEnabled);
            pw.print("  mWimaxConnected=");
            pw.println(mWimaxConnected);
            pw.print("  mWimaxIdle=");
            pw.println(mWimaxIdle);
            pw.println(String.format("  mWimaxIconId=0x%08x/%s",
                    mWimaxIconId, getResourceName(mWimaxIconId)));
            pw.println(String.format("  mWimaxSignal=%d", mWimaxSignal));