Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-10160

Android - ConnectionType always returning Connection.UNKNOWN

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0
    • None
    • Apache Cordova project utilizing the Ionic Framework on Mac OSX. Building and deploying using Android Studio 1.5.

    • Patch

    Description

      In src/android/NetworkManager.java, all the static final String constants are written in all lowercase. When checking the type in GetType(), the code already makes this adjustment:

      private String getType(NetworkInfo info) {
      if (info != null) {
      String type = info.getTypeName().toLowerCase(Locale.US);

      However, if type == MOBILE or CELLULAR, the subType is not converted to all lowercase:

      else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
      type = info.getSubtypeName();
      if (type.equals(GSM) ||
      type.equals(GPRS) ||

      For me, running on the Android emulator and pushing to a device, this was causing the app to always fail every subType comparison, and always return Connection.UNKNOWN, resulting in an app that was always 'offline'.

      After debugging the plugin, it looked like subTypes were coming in as 'GSM' and 'UMTS' in all-caps, and being compared to 'gsm' and 'umts', the lower-case pre-defined strings. I added a .toLowerCase() to the subType get, and everything seems to be working fine for me:

      else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
      type = info.getSubtypeName().toLowerCase();
      if (type.equals(GSM) ||

      I'm not sure why this was an issue for me, but hasn't been in the past for other users. I can submit whatever environment info you might want if you let me know. Thanks!

      Attachments

        Issue Links

          Activity

            People

              bowserj Joey Robert Bowser
              binhrobles Binh Robles
              Votes:
              4 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 24h
                  24h
                  Remaining:
                  Remaining Estimate - 24h
                  24h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified