Package com.motorola.oem.network

Network package - Perform operations and get indications related to the GSM Network (registration status, Network clock and more).

See:
          Description

Interface Summary
NetworkCellInfoListener Listener type for network cell information changes
NetworkRegistrationListener A listener type for GSM/GPRS network registration state changes
NetworkSignalListener Listener type for signal strength level changes.
NetworkUSSDListener Listener type for Network USSD Responce Events.
 

Class Summary
Network Provides control over the Network features.
NetworkUSSD Provides Unstructured Supplementary Service Data(USSD) service.
NetworkUSSDResponseData The NetworkUSSDResponseData class is designed to hold the NetworkUSSDResponseData sent by the network.
 

Exception Summary
NetworkException Exception type for Network class.
NetworkUSSDException Exception type for NetworkUSSD class.
 

Package com.motorola.oem.network Description

Network package - Perform operations and get indications related to the GSM Network (registration status, Network clock and more).
The main goals of this class are:

(1) Provide the ability to get Network indications and query status of the network, such as signal strength, location elements, current operator name, GSM/GPRS registration status, current time and preferred operators list.
Network (GSM/GPRS), registration status, cell information and signal strength may be queried/notified in two ways:

  • Using 'status changed event handlers' (notification). See NetworkRegistrationListener.onGSMRegStateChanged(int), NetworkRegistrationListener.onGPRSRegStateChanged(int),
    NetworkCellInfoListener.onCellInfoChanged(int, int), NetworkSignalListener.onSignalStrengthLevelChanged(int, int)

  • Using simple 'get' methods (query). See Network.getGSMRegState(), Network.getGPRSRegState(), Network.getCellID(), Network.getCellLAC(),
    Network.getSignalStrengthRSSI(), Network.getSignalStrengthBER()

  • Network class can also get and update preferred operators' list(Network.getPreferredOperatorsListInAlphaNames(),
    Network.addOperatorNumericNameToPreferredList(java.lang.String, int), Network.deleteOperatorFromPreferredList(int)),
    get the current operator's name(Network.getOperatorNameAlpha(), Network.getOperatorNameNumeric()),
    get the current network's time(Network.getNITZClock())

    (2) Control the Supplementary services (SS), such as CLI presentation (calling line ID).
  • Network.getLineIdPresentationStatus() and Network.getLineIdRestrictionStatus() - Network's requests.
    These requests take some time to return - waiting for an answer from the network/platform
  • .
  • Setting of Calling Line ID Restriction status - Network.setLineIdRestriction(int)


  • (3) Send USSD (Unstructured Supplementary Service Data) strings to the network and maintain a session in which asynchronous responses arrive. For each transaction response data, a required-action code will be attached:
  • Further user action required(session continues - MIDlet should follow with a new USSD send) or not.
  • Error cause - transaction error will be sent to the MIDlet.


  • Unstructured responses will include a String representation of the unstructured data.

    Code example:


    
            public class OEMNetworkTest1MIDlet extends MIDlet implements NetworkRegistrationListener, NetworkCellInfoListener
            {
    
            // constructor
                public OEMNetworkTest1MIDlet () 
                    {       
                            super();                        
                }
            
                    
                    // implement handlers
                    public void onGSMRegStateChanged(int new_reg_state)
                    {                   
                            System.out.println("MIDLET: GSM Reg State Changed "+new_reg_state);             
                    }       
            
            
                    public void onGPRSRegStateChanged(int new_reg_state)
                    {                   
                            System.out.println("MIDLET: GPRS Reg State Changed "+new_reg_state);            
                    }
            
            
                    public void onCellInfoChanged(int new_cell_id, int new_cell_lac)
                    {
                            System.out.println("MIDLET: Cell Info Changed: "+Integer.toHexString(new_cell_lac)+","+Integer.toHexString(new_cell_id)); 
                    }       
    
            
    
                public void startApp() throws MIDletStateChangeException
            {        
                            try 
                            {
                                    Network.getInstance().setNetworkRegistrationListener(this);                     
                                    Network.getInstance().setNetworkCellInfoListener(this);                 
                            }               
                            catch (OEMException e) 
                            {
                                    e.printStackTrace();
                            }                                                                                               
                    
                            // Main function 
                            
                            String string_cell_id = "";
                            String string_lac     = "";
                            String string_nitz    = "";
                    
                            int gsm_reg_status  = 0;
                            int gprs_reg_status = 0;
                            
                            int clip_ss_status  = 0;
    
            
                            try
                            {
                                    // get date, time and timezone
                                    string_nitz = Network.getInstance().getNITZClock();
                                    System.out.println("MIDLET: Date, Time and TimeZone: "+string_nitz);
    
    
                                    // get and display GSM registration state
                                    gsm_reg_status = Network.getInstance().getGSMRegState();
                                    System.out.println("MIDLET: GSM Registration State: "+gsm_reg_status);
                            
    
                                    // get and display GPRS registration state
                                    gprs_reg_status = Network.getInstance().getGPRSRegState();
                                    System.out.println("MIDLET: GPRS Registration State: "+gprs_reg_status);
    
                                                    
                                    // get and display Cell info                    
                                    string_lac     = Network.getInstance().getCellLAC();
                                    string_cell_id = Network.getInstance().getCellID();                     
                                    System.out.println("MIDLET: Cell Info: "+string_lac+","+string_cell_id);
               
                            
                                    // request CLIP status and wait for reply
                                    clip_ss_status = Network.getInstance().getLineIdPresentationStatus();
                                    System.out.println("MIDLET: CLIP ss status: "+clip_ss_status);
                            }
                            catch (OEMException e)
                            {
                                    e.printStackTrace();
                            }       
            }
    
                public void pauseApp()
            {
                }
    
                    public void destroyApp(boolean unconditional)
                    {
                            notifyDestroyed();
                    }
            }