FileDocCategorySizeDatePackage
AndroidRadioDataProvider.javaAPI DocAndroid 1.5 API9004Wed May 06 22:41:56 BST 2009android.webkit.gears

AndroidRadioDataProvider

public final class AndroidRadioDataProvider extends android.telephony.PhoneStateListener
Radio data provider implementation for Android.

Fields Summary
private static final String
TAG
Logging tag
private static final int
RADIO_TYPE_UNKNOWN
Network types
private static final int
RADIO_TYPE_GSM
private static final int
RADIO_TYPE_WCDMA
private long
nativeObject
The native object ID
private android.telephony.CellLocation
cellLocation
The last known cellLocation
private int
signalStrength
The last known signal strength
private android.telephony.ServiceState
serviceState
The last known serviceState
private android.telephony.TelephonyManager
telephonyManager
Our TelephonyManager instance.
Constructors Summary
public AndroidRadioDataProvider(android.webkit.WebView webview, long object)
Public constructor. Uses the webview to get the Context object.


               
       
    super();
    nativeObject = object;
    telephonyManager = (TelephonyManager) webview.getContext().getSystemService(
        Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) {
      Log.e(TAG,
          "AndroidRadioDataProvider: could not get tepephony manager.");
      throw new NullPointerException(
          "AndroidRadioDataProvider: telephonyManager is null.");
    }

    // Register for cell id, signal strength and service state changed
    // notifications.
    telephonyManager.listen(this, PhoneStateListener.LISTEN_CELL_LOCATION
        | PhoneStateListener.LISTEN_SIGNAL_STRENGTH
        | PhoneStateListener.LISTEN_SERVICE_STATE);
  
Methods Summary
private voidnotifyListeners()

    RadioData radioData = RadioData.getInstance(telephonyManager, cellLocation,
        signalStrength, serviceState);
    if (radioData != null) {
      onUpdateAvailable(radioData, nativeObject);
    }
  
public voidonCellLocationChanged(android.telephony.CellLocation location)

    cellLocation = location;
    notifyListeners();
  
public voidonServiceStateChanged(android.telephony.ServiceState state)

    serviceState = state;
    notifyListeners();
  
public voidonSignalStrengthChanged(int asu)

    signalStrength = asu;
    notifyListeners();
  
private static native voidonUpdateAvailable(android.webkit.gears.AndroidRadioDataProvider$RadioData radioData, long nativeObject)
The native method called when new radio data is available.

param
radioData is the RadioData instance to pass to the native side.
param
nativeObject is a pointer to the corresponding AndroidRadioDataProvider C++ instance.

public voidshutdown()
Should be called when the provider is no longer needed.

    telephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
    Log.i(TAG, "AndroidRadioDataProvider shutdown.");