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

BandMode

public class BandMode extends android.app.Activity
Radio Band Mode Selection Class It will query baseband about all available band modes and display them in screen. It will display all six band modes if the query failed. After user select one band, it will send the selection to baseband. It will alter user the result of select operation and exit, no matter success or not.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private static final int
EVENT_BAND_SCAN_COMPLETED
private static final int
EVENT_BAND_SELECTION_DONE
private static final String[]
BAND_NAMES
private android.widget.ListView
mBandList
private android.widget.ArrayAdapter
mBandListAdapter
private BandListItem
mTargetBand
private android.content.DialogInterface
mProgressPanel
private com.android.internal.telephony.Phone
mPhone
private AdapterView.OnItemClickListener
mBandSelectionHandler
private android.os.Handler
mHandler
Constructors Summary
Methods Summary
private voidbandListLoaded(android.os.AsyncResult result)

        if (DBG) log("network list loaded");

        if (mProgressPanel != null) mProgressPanel.dismiss();

        clearList();

        boolean addBandSuccess = false;
        BandListItem item;

        if (result.result != null) {
            int bands[] = (int[])result.result;
            int size = bands[0];

            if (size > 0) {
                for (int i=1; i<size; i++) {
                    item = new BandListItem(bands[i]);
                    mBandListAdapter.add(item);
                    if (DBG) log("Add " + item.toString());
                }
                addBandSuccess = true;
            }
        }

        if (addBandSuccess == false) {
            if (DBG) log("Error in query, add default list");
            for (int i=0; i<Phone.BM_BOUNDARY; i++) {
                item = new BandListItem(i);
                mBandListAdapter.add(item);
                if (DBG) log("Add default " + item.toString());
            }
        }
        mBandList.requestFocus();
    
private voidclearList()

        while(mBandListAdapter.getCount() > 0) {
            mBandListAdapter.remove(
                    mBandListAdapter.getItem(0));
        }
    
private voiddisplayBandSelectionResult(java.lang.Throwable ex)

        String status = getString(R.string.band_mode_set)
                +" [" + mTargetBand.toString() + "] ";

        if (ex != null) {
            status = status + getString(R.string.band_mode_failed);
        } else {
            status = status + getString(R.string.band_mode_succeeded);
        }

        mProgressPanel = new AlertDialog.Builder(this)
            .setMessage(status)
            .setPositiveButton(android.R.string.ok, null).show();
    
private voidloadBandList()

        String str = getString(R.string.band_mode_loading);

        if (DBG) log(str);


        //ProgressDialog.show(this, null, str, true, true, null);
        mProgressPanel = new AlertDialog.Builder(this)
            .setMessage(str)
            .show();

        Message msg = mHandler.obtainMessage(EVENT_BAND_SCAN_COMPLETED);
        mPhone.queryAvailableBandMode(msg);

    
private voidlog(java.lang.String msg)

        Log.d(LOG_TAG, "[BandsList] " + msg);
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        
        setContentView(R.layout.band_mode);

        setTitle(getString(R.string.band_mode_title));
        getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT,
                                    WindowManager.LayoutParams.WRAP_CONTENT);

        mPhone = PhoneFactory.getDefaultPhone();

        mBandList = (ListView) findViewById(R.id.band);
        mBandListAdapter = new ArrayAdapter<BandListItem>(this,
                android.R.layout.simple_list_item_1);
        mBandList.setAdapter(mBandListAdapter);
        mBandList.setOnItemClickListener(mBandSelectionHandler);



        loadBandList();