cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stavros Kounis (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-10160) Android - ConnectionType always returning Connection.UNKNOWN
Date Wed, 16 Dec 2015 12:45:46 GMT

    [ https://issues.apache.org/jira/browse/CB-10160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15059940#comment-15059940
] 

Stavros Kounis commented on CB-10160:
-------------------------------------

Hi [~bowserj], 

I also confirm that connection type which returned is "Unknown" when the device is online
by using its 3G feature. This is tested on Nexus 6, Android version 6. I made some tests and
I'm getting the types that follow

1. 3G Internet Access
WiFi interface: Turned OFF
3G interface (data): Turned ON
returned state: Unknown

2. No Internet Access
WiFi interface: Turned OFF
3G interface (data): Turned OFF
returned state: None









> Android - ConnectionType always returning Connection.UNKNOWN
> ------------------------------------------------------------
>
>                 Key: CB-10160
>                 URL: https://issues.apache.org/jira/browse/CB-10160
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Network Information
>    Affects Versions: 1.1.0
>         Environment: Apache Cordova project utilizing the Ionic Framework on Mac OSX.
Building and deploying using Android Studio 1.5. 
>            Reporter: Binh Robles
>              Labels: Android
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 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:

> {quote}private String getType(NetworkInfo info) {
>         if (info != null) {
>             String type = info.getTypeName().{color:red}toLowerCase{color}(Locale.US);{quote}
> However, if type == MOBILE or CELLULAR, the subType is not converted to all lowercase:
> {quote} 
> else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
>                 type = {color:red}info.getSubtypeName();{color}
>                 if (type.equals(GSM) ||
>                         type.equals(GPRS) ||
> {quote}
> 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)) {
>                 {color:green}type = info.getSubtypeName().toLowerCase();{color}
>                 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!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message