public static String getConnectionSuffix() {
   String connSuffix;
   if (DeviceInfo.isSimulator()) {
     connSuffix = ";deviceside=true";
   } else if ((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
       && RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {
     connSuffix = ";interface=wifi";
   } else {
     String uid = null;
     ServiceBook sb = ServiceBook.getSB();
     ServiceRecord[] records = sb.findRecordsByCid("WPTCP");
     for (int i = 0; i < records.length; i++) {
       if (records[i].isValid() && !records[i].isDisabled()) {
         if (records[i].getUid() != null && records[i].getUid().length() != 0) {
           if ((records[i].getCid().toLowerCase().indexOf("wptcp") != -1)
               && (records[i].getUid().toLowerCase().indexOf("wifi") == -1)
               && (records[i].getUid().toLowerCase().indexOf("mms") == -1)) {
             uid = records[i].getUid();
             break;
           }
         }
       }
     }
     if (uid != null) {
       // WAP2 Connection
       connSuffix = ";ConnectionUID=" + uid;
     } else {
       connSuffix = ";deviceside=true";
     }
   }
   return connSuffix;
 }
Exemplo n.º 2
0
 public static boolean isWifiActive() {
   // BB 4.3+: detecting WiFi: use getWLANState
   int state = WLANInfo.getWLANState();
   return state == WLANInfo.WLAN_STATE_CONNECTED;
 }
 /**
  * There is no a specific airplane mode for BB, what is possible for the user is to disable all
  * connections.
  *
  * @return true if both mobile network and Wi-Fi are disabled
  */
 public boolean isAirplaneMode() {
   return (RadioInfo.getState() == RadioInfo.STATE_OFF)
       && (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_DISCONNECTED);
 }