nicolas2k / google-glass-api

Automatically exported from code.google.com/p/google-glass-api
1 stars 0 forks source link

NetworkInfo instance's isConnected() method incorrectly returns true when data and WiFi are disabled #332

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a isConnected() method within an Activity, such as the following:
private boolean isConnected() {
    ConnectivityManager connectivityManager
            = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
2. Disable WiFi and data on the phone that is connected to your Glass via 
Bluetooth
3. Use or log isConnected() and notice that it returns true, even though Glass 
"Can't reach Google right now" if you try to do something like voice recognition

What is the expected output? What do you see instead?
isConnected() should return false, since Glass isn't connected. Instead, it 
returns true and thus attempts doing things that require connection, which then 
fail.

What version of the product are you using? On what operating system?
Glass Version 2 XE12

Please provide any additional information below.
I dumped information about the NetworkInfo instance used in my isConnected() 
method when my phone had data and when data was disabled. Strangely enough, the 
information was the same both times:

activeNetworkInfo.toString(): NetworkInfo: type: COMPANION_PROXY[], state: 
CONNECTED/CONNECTED, reason: enabled, extra: (none), roaming: false, failover: 
false, isAvailable: true

It is also important to note that isConnected() correctly returns false when 
Bluetooth is disabled (because connectivityManager.getActiveNetworkInfo() 
returns null). So the issue is when Bluetooth is connected but the phone 
doesn't have internet access.

Original issue reported on code.google.com by warlock....@gmail.com on 1 Jan 2014 at 8:34

GoogleCodeExporter commented 8 years ago

Original comment by allev...@google.com on 2 Jan 2014 at 6:13