FileDocCategorySizeDatePackage
RadioInfo.javaAPI DocAndroid 1.5 API45489Wed May 06 22:42:48 BST 2009com.android.settings

RadioInfo

public class RadioInfo extends android.app.Activity

Fields Summary
private final String
TAG
private static final int
EVENT_PHONE_STATE_CHANGED
private static final int
EVENT_SIGNAL_STRENGTH_CHANGED
private static final int
EVENT_SERVICE_STATE_CHANGED
private static final int
EVENT_CFI_CHANGED
private static final int
EVENT_QUERY_PREFERRED_TYPE_DONE
private static final int
EVENT_SET_PREFERRED_TYPE_DONE
private static final int
EVENT_QUERY_NEIGHBORING_CIDS_DONE
private static final int
EVENT_SET_QXDMLOG_DONE
private static final int
EVENT_SET_CIPHER_DONE
private static final int
EVENT_QUERY_SMSC_DONE
private static final int
EVENT_UPDATE_SMSC_DONE
private static final int
MENU_ITEM_SELECT_BAND
private static final int
MENU_ITEM_VIEW_ADN
private static final int
MENU_ITEM_VIEW_FDN
private static final int
MENU_ITEM_VIEW_SDN
private static final int
MENU_ITEM_GET_PDP_LIST
private static final int
MENU_ITEM_TOGGLE_DATA
private static final int
MENU_ITEM_TOGGLE_DATA_ON_BOOT
private android.widget.TextView
mImei
private android.widget.TextView
number
private android.widget.TextView
callState
private android.widget.TextView
operatorName
private android.widget.TextView
roamingState
private android.widget.TextView
gsmState
private android.widget.TextView
gprsState
private android.widget.TextView
network
private android.widget.TextView
dBm
private android.widget.TextView
mMwi
private android.widget.TextView
mCfi
private android.widget.TextView
mLocation
private android.widget.TextView
mNeighboringCids
private android.widget.TextView
resets
private android.widget.TextView
attempts
private android.widget.TextView
successes
private android.widget.TextView
disconnects
private android.widget.TextView
sentSinceReceived
private android.widget.TextView
sent
private android.widget.TextView
received
private android.widget.TextView
mPingIpAddr
private android.widget.TextView
mPingHostname
private android.widget.TextView
mHttpClientTest
private android.widget.TextView
cipherState
private android.widget.TextView
dnsCheckState
private android.widget.EditText
smsc
private android.widget.Button
radioPowerButton
private android.widget.Button
qxdmLogButton
private android.widget.Button
cipherToggleButton
private android.widget.Button
dnsCheckToggleButton
private android.widget.Button
pingTestButton
private android.widget.Button
updateSmscButton
private android.widget.Button
refreshSmscButton
private android.widget.Spinner
preferredNetworkType
private android.telephony.TelephonyManager
mTelephonyManager
private com.android.internal.telephony.Phone
phone
private com.android.internal.telephony.PhoneStateIntentReceiver
mPhoneStateReceiver
private android.os.INetStatService
netstat
private OemCommands
mOem
private boolean
mQxdmLogEnabled
private boolean
mCipherOn
private String
mPingIpAddrResult
private String
mPingHostnameResult
private String
mHttpClientTestResult
private boolean
mMwiValue
private boolean
mCfiValue
private android.telephony.PhoneStateListener
mPhoneStateListener
private android.os.Handler
mHandler
private MenuItem.OnMenuItemClickListener
mViewADNCallback
private MenuItem.OnMenuItemClickListener
mViewFDNCallback
private MenuItem.OnMenuItemClickListener
mViewSDNCallback
private MenuItem.OnMenuItemClickListener
mToggleDataOnBoot
private MenuItem.OnMenuItemClickListener
mToggleData
private MenuItem.OnMenuItemClickListener
mGetPdpList
private MenuItem.OnMenuItemClickListener
mSelectBandCallback
android.view.View.OnClickListener
mPowerButtonHandler
android.view.View.OnClickListener
mCipherButtonHandler
android.view.View.OnClickListener
mDnsCheckButtonHandler
android.view.View.OnClickListener
mPingButtonHandler
android.view.View.OnClickListener
mUpdateSmscButtonHandler
android.view.View.OnClickListener
mRefreshSmscButtonHandler
android.view.View.OnClickListener
mQxdmButtonHandler
AdapterView.OnItemSelectedListener
mPreferredNetworkHandler
private String[]
mPreferredNetworkLabels
Constructors Summary
Methods Summary
private voiddisplayQxdmEnableResult()

        String status = mQxdmLogEnabled ? "Start QXDM Log" : "Stop QXDM Log";

        DialogInterface mProgressPanel = new AlertDialog.
                Builder(this).setMessage(status).show();

        mHandler.postDelayed(
                new Runnable() {
                    public void run() {
                        finish();
                    }
                }, 2000);
    
private booleangetCiphPref()

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
        boolean ret = sp.getBoolean(GSMPhone.CIPHERING_KEY, true);
        return ret;
    
private voidhttpClientTest()
This function checks for basic functionality of HTTP Client.

        HttpClient client = new DefaultHttpClient();
        try {
            HttpGet request = new HttpGet("http://www.google.com");
            HttpResponse response = client.execute(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                mHttpClientTestResult = "Pass";
            } else {
                mHttpClientTestResult = "Fail: Code: " + String.valueOf(response);
            }
            request.abort();
        } catch (IOException e) {
            mHttpClientTestResult = "Fail: IOException";
        }
    
private booleanisRadioOn()

        return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
    
public voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        setContentView(R.layout.radio_info);

        mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
        phone = PhoneFactory.getDefaultPhone();

        mImei = (TextView) findViewById(R.id.imei);
        number = (TextView) findViewById(R.id.number);
        callState = (TextView) findViewById(R.id.call);
        operatorName = (TextView) findViewById(R.id.operator);
        roamingState = (TextView) findViewById(R.id.roaming);
        gsmState = (TextView) findViewById(R.id.gsm);
        gprsState = (TextView) findViewById(R.id.gprs);
        network = (TextView) findViewById(R.id.network);
        dBm = (TextView) findViewById(R.id.dbm);
        mMwi = (TextView) findViewById(R.id.mwi);
        mCfi = (TextView) findViewById(R.id.cfi);
        mLocation = (TextView) findViewById(R.id.location);
        mNeighboringCids = (TextView) findViewById(R.id.neighboring);

        resets = (TextView) findViewById(R.id.resets);
        attempts = (TextView) findViewById(R.id.attempts);
        successes = (TextView) findViewById(R.id.successes);
        disconnects = (TextView) findViewById(R.id.disconnects);
        sentSinceReceived = (TextView) findViewById(R.id.sentSinceReceived);
        sent = (TextView) findViewById(R.id.sent);
        received = (TextView) findViewById(R.id.received);
        cipherState = (TextView) findViewById(R.id.ciphState);
        smsc = (EditText) findViewById(R.id.smsc);
        dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);

        mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr);
        mPingHostname = (TextView) findViewById(R.id.pingHostname);
        mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);

        preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
        ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
                android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);        
        preferredNetworkType.setAdapter(adapter);
        preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);

        radioPowerButton = (Button) findViewById(R.id.radio_power);
        radioPowerButton.setOnClickListener(mPowerButtonHandler);

        qxdmLogButton = (Button) findViewById(R.id.qxdm_log);
        qxdmLogButton.setOnClickListener(mQxdmButtonHandler);

        cipherToggleButton = (Button) findViewById(R.id.ciph_toggle);
        cipherToggleButton.setOnClickListener(mCipherButtonHandler);
        pingTestButton = (Button) findViewById(R.id.ping_test);
        pingTestButton.setOnClickListener(mPingButtonHandler);
        updateSmscButton = (Button) findViewById(R.id.update_smsc);
        updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
        refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
        refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
        dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
        dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
        
        mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
        mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
        mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
        mPhoneStateReceiver.notifyPhoneCallState(EVENT_PHONE_STATE_CHANGED);
                         
        updateQxdmState(null);
        mOem = new OemCommands();

        phone.getPreferredNetworkType(
                mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
        phone.getNeighboringCids(
                mHandler.obtainMessage(EVENT_QUERY_NEIGHBORING_CIDS_DONE));

        netstat = INetStatService.Stub.asInterface(ServiceManager.getService("netstat"));

        CellLocation.requestLocationUpdate();
    
public booleanonCreateOptionsMenu(android.view.Menu menu)

        menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label).setOnMenuItemClickListener(mSelectBandCallback)
                .setAlphabeticShortcut('b");
        menu.add(1, MENU_ITEM_VIEW_ADN, 0,
                R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
        menu.add(1, MENU_ITEM_VIEW_FDN, 0,
                R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
        menu.add(1, MENU_ITEM_VIEW_SDN, 0,
                R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
        menu.add(1, MENU_ITEM_GET_PDP_LIST,
                0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList);
        menu.add(1, MENU_ITEM_TOGGLE_DATA,
                0, R.string.radioInfo_menu_disableData).setOnMenuItemClickListener(mToggleData);
        menu.add(1, MENU_ITEM_TOGGLE_DATA_ON_BOOT,
                0, R.string.radioInfo_menu_disableDataOnBoot).setOnMenuItemClickListener(mToggleDataOnBoot);
        return true;
    
public voidonPause()

        super.onPause();

        Log.i(TAG, "[RadioInfo] onPause: unregister phone & data intents");

        mPhoneStateReceiver.unregisterIntent();
        mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
    
public booleanonPrepareOptionsMenu(android.view.Menu menu)

        // Get the TOGGLE DATA menu item in the right state.
        MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
        int state = mTelephonyManager.getDataState();
        boolean visible = true;

        switch (state) {
            case TelephonyManager.DATA_CONNECTED:
            case TelephonyManager.DATA_SUSPENDED:
                item.setTitle(R.string.radioInfo_menu_disableData);
                break;
            case TelephonyManager.DATA_DISCONNECTED:
                item.setTitle(R.string.radioInfo_menu_enableData);
                break;
            default:
                visible = false;
                break;
        }
        item.setVisible(visible);

        // Get the toggle-data-on-boot menu item in the right state.
        item = menu.findItem(MENU_ITEM_TOGGLE_DATA_ON_BOOT);
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
        boolean value = sp.getBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, false);
        if (value) {
            item.setTitle(R.string.radioInfo_menu_enableDataOnBoot);
        } else {
            item.setTitle(R.string.radioInfo_menu_disableDataOnBoot);
        }
        return true;
    
protected voidonResume()

        super.onResume();

        updatePhoneState();
        updateSignalStrength();
        updateMessageWaiting();
        updateCallRedirect();
        updateServiceState();
        updateLocation(mTelephonyManager.getCellLocation());
        updateDataState();
        updateDataStats();
        updateDataStats2();
        updatePowerState();
        updateQxdmState(null);
        updateProperties();
        updateCiphState();
        updateDnsCheckState();

        Log.i(TAG, "[RadioInfo] onResume: register phone & data intents");

        mPhoneStateReceiver.registerIntent();
        mTelephonyManager.listen(mPhoneStateListener,
                  PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
                | PhoneStateListener.LISTEN_DATA_ACTIVITY
                | PhoneStateListener.LISTEN_CELL_LOCATION
                | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
                | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR);
    
private final voidpingHostname()
Ping a host name

        try {
            Process p = Runtime.getRuntime().exec("ping -c 1 www.google.com"); 
            int status = p.waitFor();
            if (status == 0) {
                mPingHostnameResult = "Pass";
            } else {
                mPingHostnameResult = "Fail: Host unreachable";
            }
        } catch (UnknownHostException e) {
            mPingHostnameResult = "Fail: Unknown Host";
        } catch (IOException e) {
            mPingHostnameResult= "Fail: IOException";
        } catch (InterruptedException e) {
            mPingHostnameResult = "Fail: InterruptedException";
        }
    
private final voidpingIpAddr()
Ping a IP address.

        try {
            // This is hardcoded IP addr. This is for testing purposes.
            // We would need to get rid of this before release.
            String ipAddress = "74.125.47.104";
            Process p = Runtime.getRuntime().exec("ping -c 1 " + ipAddress);
            int status = p.waitFor();
            if (status == 0) {
                mPingIpAddrResult = "Pass";
            } else {
                mPingIpAddrResult = "Fail: IP addr not reachable";
            }
        } catch (IOException e) {
            mPingIpAddrResult = "Fail: IOException";
        } catch (InterruptedException e) {
            mPingIpAddrResult = "Fail: InterruptedException";
        }
    
private voidrefreshSmsc()

        byte[] data = mOem.getSmscQueryData();
        if (data == null) return;
        phone.invokeOemRilRequestRaw(data,
                mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
    
private voidsetCiphPref(boolean value)

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean(GSMPhone.CIPHERING_KEY, value);
        editor.commit();
    
private voidtoggleDataDisabledOnBoot()


       
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
        SharedPreferences.Editor editor = sp.edit();
        boolean value = sp.getBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, false);
        editor.putBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, !value);
        byte[] data = mOem.getPsAutoAttachData(value);
        if (data == null) {
            // don't commit
            return;
        }

        editor.commit();
        phone.invokeOemRilRequestRaw(data, null);
    
private final voidupdateCallRedirect()

        mCfi.setText(String.valueOf(mCfiValue));
    
private voidupdateCiphState()

        cipherState.setText(getCiphPref() ? "Ciphering ON" : "Ciphering OFF");
    
private final voidupdateDataState()

        int state = mTelephonyManager.getDataState();
        Resources r = getResources();
        String display = r.getString(R.string.radioInfo_unknown);

        switch (state) {
            case TelephonyManager.DATA_CONNECTED:
                display = r.getString(R.string.radioInfo_data_connected);
                break;
            case TelephonyManager.DATA_CONNECTING:
                display = r.getString(R.string.radioInfo_data_connecting);
                break;
            case TelephonyManager.DATA_DISCONNECTED:
                display = r.getString(R.string.radioInfo_data_disconnected);
                break;
            case TelephonyManager.DATA_SUSPENDED:
                display = r.getString(R.string.radioInfo_data_suspended);
                break;
        }
        
        gprsState.setText(display);
    
private final voidupdateDataStats()

        String s;

        s = SystemProperties.get("net.gsm.radio-reset", "0");
        resets.setText(s);

        s = SystemProperties.get("net.gsm.attempt-gprs", "0");
        attempts.setText(s);

        s = SystemProperties.get("net.gsm.succeed-gprs", "0");
        successes.setText(s);

        //s = SystemProperties.get("net.gsm.disconnect", "0");
        //disconnects.setText(s);

        s = SystemProperties.get("net.ppp.reset-by-timeout", "0");
        sentSinceReceived.setText(s);
    
private final voidupdateDataStats2()

        Resources r = getResources();

        try {
            long txPackets = netstat.getMobileTxPackets();
            long rxPackets = netstat.getMobileRxPackets();
            long txBytes   = netstat.getMobileTxBytes();
            long rxBytes   = netstat.getMobileRxBytes();
    
            String packets = r.getString(R.string.radioInfo_display_packets);
            String bytes   = r.getString(R.string.radioInfo_display_bytes);
    
            sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
            received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
        } catch (RemoteException e) {
        }
    
private voidupdateDnsCheckState()

        GSMPhone gsmPhone = (GSMPhone) phone;
        dnsCheckState.setText(gsmPhone.isDnsCheckDisabled() ?
                "0.0.0.0 allowed" :"0.0.0.0 not allowed");
    
private final voidupdateLocation(android.telephony.CellLocation location)

        GsmCellLocation loc = (GsmCellLocation)location;
        Resources r = getResources();

        int lac = loc.getLac();
        int cid = loc.getCid();

        mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
                          + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
                          + "   "
                          + r.getString(R.string.radioInfo_cid) + " = "
                + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
    
private final voidupdateMessageWaiting()

        mMwi.setText(String.valueOf(mMwiValue));
    
private final voidupdateNeighboringCids(java.util.ArrayList cids)

        String neighborings = "";
        if (cids != null) {
            if ( cids.isEmpty() ) {
                neighborings = "no neighboring cells";
            } else {
                for (NeighboringCellInfo cell : cids) {
                    neighborings += "{" + Integer.toHexString(cell.getCid()) 
                    + "@" + cell.getRssi() + "} ";
                }
            }
        } else {
            neighborings = "unknown";
        }
        mNeighboringCids.setText(neighborings);
    
private final voidupdateNetworkType()

        Resources r = getResources();
        String display = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
                r.getString(R.string.radioInfo_unknown));

        network.setText(display);
    
private final voidupdatePdpList()

        StringBuilder sb = new StringBuilder("========DATA=======\n");

        List<PdpConnection> pdps = phone.getCurrentPdpList();

        for (PdpConnection pdp : pdps) {
            sb.append("    State: ").append(pdp.getState().toString()).append("\n");
            if (pdp.getState().isActive()) {
                long timeElapsed =
                    (System.currentTimeMillis() - pdp.getConnectionTime())/1000;
                sb.append("    connected at ")
                  .append(DateUtils.timeString(pdp.getConnectionTime()))
                  .append(" and elapsed ")
                  .append(DateUtils.formatElapsedTime(timeElapsed))
                  .append("\n    to ")
                  .append(pdp.getApn().toString())
                  .append("\ninterface: ")
                  .append(phone.getInterfaceName(phone.getActiveApnTypes()[0]))
                  .append("\naddress: ")
                  .append(phone.getIpAddress(phone.getActiveApnTypes()[0]))
                  .append("\ngateway: ")
                  .append(phone.getGateway(phone.getActiveApnTypes()[0]));
                String[] dns = phone.getDnsServers(phone.getActiveApnTypes()[0]);
                if (dns != null) {
                    sb.append("\ndns: ").append(dns[0]).append(", ").append(dns[1]);
                }
            } else if (pdp.getState().isInactive()) {
                sb.append("    disconnected with last try at ")
                  .append(DateUtils.timeString(pdp.getLastFailTime()))
                  .append("\n    fail because ")
                  .append(pdp.getLastFailCause().toString());
            } else {
                sb.append("    is connecting to ")
                  .append(pdp.getApn().toString());
            }
            sb.append("\n===================");
        }


        disconnects.setText(sb.toString());
    
private final voidupdatePhoneState()

        Phone.State state = mPhoneStateReceiver.getPhoneState();
        Resources r = getResources();
        String display = r.getString(R.string.radioInfo_unknown);

        switch (state) {
            case IDLE:
                display = r.getString(R.string.radioInfo_phone_idle);
                break;
            case RINGING:
                display = r.getString(R.string.radioInfo_phone_ringing);
                break;
            case OFFHOOK:
                display = r.getString(R.string.radioInfo_phone_offhook);
                break;
        }

        callState.setText(display);
    
private final voidupdatePingState()

        final Handler handler = new Handler();
        // Set all to unknown since the threads will take a few secs to update.
        mPingIpAddrResult = getResources().getString(R.string.radioInfo_unknown);
        mPingHostnameResult = getResources().getString(R.string.radioInfo_unknown);
        mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);

        mPingIpAddr.setText(mPingIpAddrResult);
        mPingHostname.setText(mPingHostnameResult);
        mHttpClientTest.setText(mHttpClientTestResult);

        final Runnable updatePingResults = new Runnable() {
            public void run() {
                mPingIpAddr.setText(mPingIpAddrResult);
                mPingHostname.setText(mPingHostnameResult);
                mHttpClientTest.setText(mHttpClientTestResult);
            }
        };
        Thread ipAddr = new Thread() {
            @Override
            public void run() {
                pingIpAddr();
                handler.post(updatePingResults);
            }
        };
        ipAddr.start();

        Thread hostname = new Thread() {
            @Override
            public void run() {
                pingHostname();
                handler.post(updatePingResults);
            }
        };
        hostname.start();

        Thread httpClient = new Thread() {
            @Override
            public void run() {
                httpClientTest();
                handler.post(updatePingResults);
            }
        };
        httpClient.start();
    
private voidupdatePowerState()

    	//log("updatePowerState");
        String buttonText = isRadioOn() ?
                            getString(R.string.turn_off_radio) :
                            getString(R.string.turn_on_radio);
        radioPowerButton.setText(buttonText);    	
    
private final voidupdateProperties()

        String s;
        Resources r = getResources();

        s = phone.getDeviceId();
        if (s == null) s = r.getString(R.string.radioInfo_unknown); 
        mImei.setText(s);
        
        s = phone.getLine1Number();
        if (s == null) s = r.getString(R.string.radioInfo_unknown); 
        number.setText(s);
    
private voidupdateQxdmState(java.lang.Boolean newQxdmStatus)

        SharedPreferences sp = 
          PreferenceManager.getDefaultSharedPreferences(phone.getContext());
        mQxdmLogEnabled = sp.getBoolean("qxdmstatus", false);
        // This is called from onCreate, onResume, and the handler when the status
        // is updated. 
        if (newQxdmStatus != null) {
            SharedPreferences.Editor editor = sp.edit();
            editor.putBoolean("qxdmstatus", newQxdmStatus);
            editor.commit();
            mQxdmLogEnabled = newQxdmStatus;
        }
        
        String buttonText = mQxdmLogEnabled ?
                            getString(R.string.turn_off_qxdm) :
                            getString(R.string.turn_on_qxdm);
        qxdmLogButton.setText(buttonText);
    
private final voidupdateServiceState()

        ServiceState serviceState = mPhoneStateReceiver.getServiceState();
        int state = serviceState.getState();
        Resources r = getResources();
        String display = r.getString(R.string.radioInfo_unknown);
        
        switch (state) {
            case ServiceState.STATE_IN_SERVICE:
                display = r.getString(R.string.radioInfo_service_in);
                break;
            case ServiceState.STATE_OUT_OF_SERVICE:
            case ServiceState.STATE_EMERGENCY_ONLY:
                display = r.getString(R.string.radioInfo_service_emergency);
                break;
            case ServiceState.STATE_POWER_OFF:
                display = r.getString(R.string.radioInfo_service_off);
                break;
        }
        
        gsmState.setText(display);
        
        if (serviceState.getRoaming()) {
            roamingState.setText(R.string.radioInfo_roaming_in);
        } else {
            roamingState.setText(R.string.radioInfo_roaming_not);
        }

        operatorName.setText(serviceState.getOperatorAlphaLong());
    
private final voidupdateSignalStrength()

        int state =
                mPhoneStateReceiver.getServiceState().getState();
        Resources r = getResources();

        if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
                (ServiceState.STATE_POWER_OFF == state)) {
            dBm.setText("0");
        }
        
        int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm();
        
        if (-1 == signalDbm) signalDbm = 0;

        int signalAsu = mPhoneStateReceiver.getSignalStrength();

        if (-1 == signalAsu) signalAsu = 0;

        dBm.setText(String.valueOf(signalDbm) + " "
            + r.getString(R.string.radioInfo_display_dbm) + "   "
            + String.valueOf(signalAsu) + " "
            + r.getString(R.string.radioInfo_display_asu));