diff --git a/embedding/android/AndroidManifest.xml.in b/embedding/android/AndroidManifest.xml.in
index 1768d05d236d..6f10cc73c879 100644
--- a/embedding/android/AndroidManifest.xml.in
+++ b/embedding/android/AndroidManifest.xml.in
@@ -13,6 +13,7 @@
+
diff --git a/embedding/android/GeckoApp.java b/embedding/android/GeckoApp.java
index 8a851640f60f..524939167ddb 100644
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -61,6 +61,7 @@ import android.util.*;
import android.net.*;
import android.database.*;
import android.provider.*;
+import android.telephony.*;
abstract public class GeckoApp
extends Activity
@@ -77,6 +78,7 @@ abstract public class GeckoApp
public Handler mMainHandler;
private IntentFilter mConnectivityFilter;
private BroadcastReceiver mConnectivityReceiver;
+ private PhoneStateListener mPhoneStateListener;
enum LaunchState {PreLaunch, Launching, WaitButton,
Launched, GeckoRunning, GeckoExiting};
@@ -232,6 +234,8 @@ abstract public class GeckoApp
mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
mConnectivityReceiver = new GeckoConnectivityReceiver();
+ mPhoneStateListener = new GeckoPhoneStateListener();
+
if (!checkAndSetLaunchState(LaunchState.PreLaunch,
LaunchState.Launching))
return;
@@ -326,6 +330,10 @@ abstract public class GeckoApp
super.onPause();
unregisterReceiver(mConnectivityReceiver);
+
+ TelephonyManager tm = (TelephonyManager)
+ GeckoApp.mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
+ tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}
@Override
@@ -344,6 +352,13 @@ abstract public class GeckoApp
onNewIntent(getIntent());
registerReceiver(mConnectivityReceiver, mConnectivityFilter);
+
+ TelephonyManager tm = (TelephonyManager)
+ GeckoApp.mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
+ tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
+
+ // Notify if network state changed since we paused
+ GeckoAppShell.onNetworkStateChange(true);
}
@Override
diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java
index 76a150fd4ea0..0a7638ade555 100644
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -58,6 +58,7 @@ import android.graphics.*;
import android.widget.*;
import android.hardware.*;
import android.location.*;
+import android.telephony.*;
import android.webkit.MimeTypeMap;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
@@ -94,6 +95,10 @@ public class GeckoAppShell
static private File sCacheFile = null;
static private int sFreeSpace = -1;
+ static private String sNetworkState = "unknown";
+ static private String sNetworkType = "unknown";
+ static private int sNetworkTypeCode = 0;
+
/* The Android-side API: API methods that Android calls */
// Initialization methods
@@ -108,7 +113,7 @@ public class GeckoAppShell
public static native void callObserver(String observerKey, String topic, String data);
public static native void removeObserver(String observerKey);
public static native void loadLibs(String apkName, boolean shouldExtract);
- public static native void onChangeNetworkLinkStatus(String status);
+ public static native void onChangeNetworkLinkStatus(String status, String type);
public static native void reportJavaCrash(String stack);
// A looper thread, accessed by GeckoAppShell.getHandler
@@ -654,6 +659,9 @@ public class GeckoAppShell
// mLaunchState can only be Launched at this point
GeckoApp.setLaunchState(GeckoApp.LaunchState.GeckoRunning);
sendPendingEventsToGecko();
+
+ // Refresh the network connectivity state
+ onNetworkStateChange(false);
}
static void onXreExit() {
@@ -1010,20 +1018,92 @@ public class GeckoAppShell
}
public static boolean isNetworkLinkUp() {
- ConnectivityManager cm = (ConnectivityManager)
- GeckoApp.mAppContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo info = cm.getActiveNetworkInfo();
- if (info == null || !info.isConnected())
+ if (sNetworkState == "up")
+ return true;
+ return false;
+ }
+
+ public static boolean isNetworkLinkKnown() {
+ if (sNetworkState == "unknown")
return false;
return true;
}
- public static boolean isNetworkLinkKnown() {
+ public static int getNetworkLinkType() {
+ return sNetworkTypeCode;
+ }
+
+ public static void onNetworkStateChange(boolean notifyChanged) {
+ String state;
+ String type;
+ int typeCode;
+
ConnectivityManager cm = (ConnectivityManager)
GeckoApp.mAppContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (cm.getActiveNetworkInfo() == null)
- return false;
- return true;
+ NetworkInfo info = cm.getActiveNetworkInfo();
+
+ // Note, these strings and codes correspond to those specified in
+ // nsINetworkLinkService. Make sure to keep them in sync!
+ type = "unknown";
+ typeCode = 0;
+ if (info == null) {
+ state = "unknown";
+ } else if (!info.isConnected()) {
+ state = "down";
+ } else {
+ state = "up";
+
+ int androidType = info.getType();
+
+ if (androidType == ConnectivityManager.TYPE_WIFI) {
+ type = "wifi";
+ typeCode = 3;
+ } else if (androidType == ConnectivityManager.TYPE_WIMAX) {
+ type = "wimax";
+ typeCode = 4;
+ } else if (androidType == ConnectivityManager.TYPE_MOBILE) {
+ TelephonyManager tm = (TelephonyManager)
+ GeckoApp.mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
+ typeCode = tm.getNetworkType();
+
+ // Note that the value of some of these constants are used due
+ // to not all of these existing in API level 8.
+ //
+ // In particular, EVDO_B appears at level 9, and EHRPD and LTE
+ // appear at level 11.
+ if (androidType == TelephonyManager.NETWORK_TYPE_GPRS ||
+ androidType == TelephonyManager.NETWORK_TYPE_EDGE ||
+ androidType == TelephonyManager.NETWORK_TYPE_CDMA ||
+ androidType == TelephonyManager.NETWORK_TYPE_IDEN ||
+ androidType == TelephonyManager.NETWORK_TYPE_1xRTT) {
+ type = "2g";
+ typeCode = 5;
+ } else if (androidType == TelephonyManager.NETWORK_TYPE_UMTS ||
+ androidType == TelephonyManager.NETWORK_TYPE_HSDPA ||
+ androidType == TelephonyManager.NETWORK_TYPE_HSUPA ||
+ androidType == TelephonyManager.NETWORK_TYPE_HSPA ||
+ androidType == TelephonyManager.NETWORK_TYPE_EVDO_0 ||
+ androidType == TelephonyManager.NETWORK_TYPE_EVDO_A ||
+ androidType == 12 || // TelephonyManager.NETWORK_TYPE_EVDO_B
+ androidType == 14) { // TelephonyManager.NETWORK_TYPE_EHRPD
+ type = "3g";
+ typeCode = 6;
+ } else if (androidType == 13) { // TelephonyManager.NETWORK_TYPE_LTE
+ type = "4g";
+ typeCode = 7;
+ }
+ }
+ }
+
+ // If the network state has changed, notify Gecko
+ if (notifyChanged && (state != sNetworkState || typeCode != sNetworkTypeCode)) {
+ Log.i("GeckoAppShell", "Network state changed: (" + state + ", " + type + ") ");
+ sNetworkState = state;
+ sNetworkType = type;
+ sNetworkTypeCode = typeCode;
+ if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning))
+ onChangeNetworkLinkStatus(sNetworkState, sNetworkType);
+ }
}
public static void setSelectedLocale(String localeCode) {
diff --git a/embedding/android/GeckoConnectivityReceiver.java b/embedding/android/GeckoConnectivityReceiver.java
index ffabc9a547d7..18c7724c5576 100644
--- a/embedding/android/GeckoConnectivityReceiver.java
+++ b/embedding/android/GeckoConnectivityReceiver.java
@@ -38,25 +38,12 @@
package org.mozilla.gecko;
import android.content.*;
-import android.net.*;
public class GeckoConnectivityReceiver
extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent) {
- String status;
- ConnectivityManager cm = (ConnectivityManager)
- context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo info = cm.getActiveNetworkInfo();
- if (info == null)
- status = "unknown";
- else if (!info.isConnected())
- status = "down";
- else
- status = "up";
-
- if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning))
- GeckoAppShell.onChangeNetworkLinkStatus(status);
+ GeckoAppShell.onNetworkStateChange(true);
}
}
diff --git a/embedding/android/GeckoPhoneStateListener.java b/embedding/android/GeckoPhoneStateListener.java
new file mode 100644
index 000000000000..58f5f8118e56
--- /dev/null
+++ b/embedding/android/GeckoPhoneStateListener.java
@@ -0,0 +1,50 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Android code.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Chris Lord
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package org.mozilla.gecko;
+
+import android.telephony.*;
+
+public class GeckoPhoneStateListener
+ extends PhoneStateListener
+{
+ @Override
+ public void onDataConnectionStateChanged(int state, int networkType) {
+ GeckoAppShell.onNetworkStateChange(true);
+ }
+}
+
diff --git a/embedding/android/Makefile.in b/embedding/android/Makefile.in
index 136ceb0c471e..dd8f9cda55d6 100644
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -52,6 +52,7 @@ JAVAFILES = \
GeckoEvent.java \
GeckoSurfaceView.java \
GeckoInputConnection.java \
+ GeckoPhoneStateListener.java \
AlertNotification.java \
$(NULL)
diff --git a/netwerk/base/public/nsINetworkLinkService.idl b/netwerk/base/public/nsINetworkLinkService.idl
index eabba888bd6c..3507eec685e0 100644
--- a/netwerk/base/public/nsINetworkLinkService.idl
+++ b/netwerk/base/public/nsINetworkLinkService.idl
@@ -42,9 +42,19 @@
/**
* Network link status monitoring service.
*/
-[scriptable, uuid(61618a52-ea91-4277-a4ab-ebe10d7b9a64)]
+[scriptable, uuid(f7d3be87-7403-4a1e-b89f-2797776e9b08)]
interface nsINetworkLinkService : nsISupports
{
+ /* Link type constants */
+ const unsigned long LINK_TYPE_UNKNOWN = 0;
+ const unsigned long LINK_TYPE_ETHERNET = 1;
+ const unsigned long LINK_TYPE_USB = 2;
+ const unsigned long LINK_TYPE_WIFI = 3;
+ const unsigned long LINK_TYPE_WIMAX = 4;
+ const unsigned long LINK_TYPE_2G = 5;
+ const unsigned long LINK_TYPE_3G = 6;
+ const unsigned long LINK_TYPE_4G = 7;
+
/**
* This is set to true when the system is believed to have a usable
* network connection.
@@ -62,6 +72,11 @@ interface nsINetworkLinkService : nsISupports
* This is set to true when we believe that isLinkUp is accurate.
*/
readonly attribute boolean linkStatusKnown;
+
+ /**
+ * The type of network connection.
+ */
+ readonly attribute unsigned long linkType;
};
%{C++
@@ -85,4 +100,36 @@ interface nsINetworkLinkService : nsISupports
* linkStatusKnown is now false.
*/
#define NS_NETWORK_LINK_DATA_UNKNOWN "unknown"
+
+/**
+ * We send notifications through nsIObserverService with topic
+ * NS_NETWORK_LINK_TYPE_TOPIC whenever the network connection type
+ * changes. We pass one of the valid connection type constants
+ * below as the aData parameter of the notification.
+ */
+#define NS_NETWORK_LINK_TYPE_TOPIC "network:link-type-changed"
+
+/** We were unable to determine the network connection type */
+#define NS_NETWORK_LINK_TYPE_UNKNOWN "unknown"
+
+/** A standard wired ethernet connection */
+#define NS_NETWORK_LINK_TYPE_ETHERNET "ethernet"
+
+/** A connection via a USB port */
+#define NS_NETWORK_LINK_TYPE_USB "usb"
+
+/** A connection via a WiFi access point (IEEE802.11) */
+#define NS_NETWORK_LINK_TYPE_WIFI "wifi"
+
+/** A connection via WiMax (IEEE802.16) */
+#define NS_NETWORK_LINK_TYPE_WIMAX "wimax"
+
+/** A '2G' mobile connection (e.g. GSM, GPRS, EDGE) */
+#define NS_NETWORK_LINK_TYPE_2G "2g"
+
+/** A '3G' mobile connection (e.g. UMTS, CDMA) */
+#define NS_NETWORK_LINK_TYPE_3G "3g"
+
+/** A '4G' mobile connection (e.g. LTE, UMB) */
+#define NS_NETWORK_LINK_TYPE_4G "4g"
%}
diff --git a/netwerk/system/android/nsAndroidNetworkLinkService.cpp b/netwerk/system/android/nsAndroidNetworkLinkService.cpp
index b533586ffc00..1c6e55f87d24 100644
--- a/netwerk/system/android/nsAndroidNetworkLinkService.cpp
+++ b/netwerk/system/android/nsAndroidNetworkLinkService.cpp
@@ -70,3 +70,13 @@ nsAndroidNetworkLinkService::GetLinkStatusKnown(PRBool *aIsKnown)
*aIsKnown = mozilla::AndroidBridge::Bridge()->IsNetworkLinkKnown();
return NS_OK;
}
+
+NS_IMETHODIMP
+nsAndroidNetworkLinkService::GetLinkType(PRUint32 *aLinkType)
+{
+ NS_ENSURE_ARG_POINTER(aLinkType);
+ NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_UNEXPECTED);
+
+ *aLinkType = mozilla::AndroidBridge::Bridge()->GetNetworkLinkType();
+ return NS_OK;
+}
diff --git a/netwerk/system/mac/nsNetworkLinkService.mm b/netwerk/system/mac/nsNetworkLinkService.mm
index 7a1c4d755966..ad31fc3e22f0 100644
--- a/netwerk/system/mac/nsNetworkLinkService.mm
+++ b/netwerk/system/mac/nsNetworkLinkService.mm
@@ -41,6 +41,7 @@
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
+#include "nsCRT.h"
#import
#import
@@ -75,6 +76,16 @@ nsNetworkLinkService::GetLinkStatusKnown(PRBool *aIsUp)
return NS_OK;
}
+NS_IMETHODIMP
+nsNetworkLinkService::GetLinkType(PRUint32 *aLinkType)
+{
+ NS_ENSURE_ARG_POINTER(aLinkType);
+
+ // XXX This function has not yet been implemented for this platform
+ *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsNetworkLinkService::Observe(nsISupports *subject,
const char *topic,
diff --git a/netwerk/system/maemo/nsMaemoNetworkLinkService.cpp b/netwerk/system/maemo/nsMaemoNetworkLinkService.cpp
index d4d9a81e73b1..6abed897a6e7 100644
--- a/netwerk/system/maemo/nsMaemoNetworkLinkService.cpp
+++ b/netwerk/system/maemo/nsMaemoNetworkLinkService.cpp
@@ -43,6 +43,7 @@
#include "nsString.h"
#include "nsMaemoNetworkManager.h"
#include "mozilla/Services.h"
+#include "nsCRT.h"
NS_IMPL_ISUPPORTS2(nsMaemoNetworkLinkService,
nsINetworkLinkService,
@@ -70,6 +71,16 @@ nsMaemoNetworkLinkService::GetLinkStatusKnown(PRBool *aIsKnown)
return NS_OK;
}
+NS_IMETHODIMP
+nsMaemoNetworkLinkService::GetLinkType(PRUint32 *aLinkType)
+{
+ NS_ENSURE_ARG_POINTER(aLinkType);
+
+ // XXX This function has not yet been implemented for this platform
+ *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsMaemoNetworkLinkService::Observe(nsISupports *aSubject,
const char *aTopic,
diff --git a/netwerk/system/qt/nsQtNetworkLinkService.cpp b/netwerk/system/qt/nsQtNetworkLinkService.cpp
index 15e6f617d6f7..589358f1a1a7 100644
--- a/netwerk/system/qt/nsQtNetworkLinkService.cpp
+++ b/netwerk/system/qt/nsQtNetworkLinkService.cpp
@@ -42,6 +42,7 @@
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "mozilla/Services.h"
+#include "nsCRT.h"
NS_IMPL_ISUPPORTS2(nsQtNetworkLinkService,
nsINetworkLinkService,
@@ -69,6 +70,16 @@ nsQtNetworkLinkService::GetLinkStatusKnown(PRBool* aIsKnown)
return NS_OK;
}
+NS_IMETHODIMP
+nsQtNetworkLinkService::GetLinkType(PRUint32 *aLinkType)
+{
+ NS_ENSURE_ARG_POINTER(aLinkType);
+
+ // XXX This function has not yet been implemented for this platform
+ *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsQtNetworkLinkService::Observe(nsISupports* aSubject,
const char* aTopic,
diff --git a/netwerk/system/win32/nsNotifyAddrListener.cpp b/netwerk/system/win32/nsNotifyAddrListener.cpp
index 2b091842e02d..a04d659e3391 100644
--- a/netwerk/system/win32/nsNotifyAddrListener.cpp
+++ b/netwerk/system/win32/nsNotifyAddrListener.cpp
@@ -54,6 +54,7 @@
#include "nsString.h"
#include "nsAutoPtr.h"
#include "mozilla/Services.h"
+#include "nsCRT.h"
#include
#include
@@ -166,6 +167,16 @@ nsNotifyAddrListener::GetLinkStatusKnown(PRBool *aIsUp)
return NS_OK;
}
+NS_IMETHODIMP
+nsNotifyAddrListener::GetLinkType(PRUint32 *aLinkType)
+{
+ NS_ENSURE_ARG_POINTER(aLinkType);
+
+ // XXX This function has not yet been implemented for this platform
+ *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsNotifyAddrListener::Run()
{
diff --git a/other-licenses/android/APKOpen.cpp b/other-licenses/android/APKOpen.cpp
index 6670403a0cda..14de579f4f38 100644
--- a/other-licenses/android/APKOpen.cpp
+++ b/other-licenses/android/APKOpen.cpp
@@ -238,7 +238,7 @@ SHELL_WRAPPER0(onResume)
SHELL_WRAPPER0(onLowMemory)
SHELL_WRAPPER3(callObserver, jstring, jstring, jstring)
SHELL_WRAPPER1(removeObserver, jstring)
-SHELL_WRAPPER1(onChangeNetworkLinkStatus, jstring)
+SHELL_WRAPPER2(onChangeNetworkLinkStatus, jstring, jstring)
SHELL_WRAPPER1(reportJavaCrash, jstring)
static void * xul_handle = NULL;
diff --git a/toolkit/system/dbus/nsNetworkManagerListener.cpp b/toolkit/system/dbus/nsNetworkManagerListener.cpp
index 92e69c200ed6..6b5d2691c798 100644
--- a/toolkit/system/dbus/nsNetworkManagerListener.cpp
+++ b/toolkit/system/dbus/nsNetworkManagerListener.cpp
@@ -45,6 +45,7 @@
#include "nsServiceManagerUtils.h"
#include "nsIObserverService.h"
#include "nsStringAPI.h"
+#include "nsCRT.h"
// Define NetworkManager API constants. This avoids a dependency on
// NetworkManager-devel.
@@ -87,6 +88,16 @@ nsNetworkManagerListener::GetLinkStatusKnown(PRBool* aKnown) {
return NS_OK;
}
+nsresult
+nsNetworkManagerListener::GetLinkType(PRUint32 *aLinkType)
+{
+ NS_ENSURE_ARG_POINTER(aLinkType);
+
+ // XXX This function has not yet been implemented for this platform
+ *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
+ return NS_OK;
+}
+
nsresult
nsNetworkManagerListener::Init() {
mDBUS = nsDBusService::Get();
diff --git a/widget/src/android/AndroidBridge.cpp b/widget/src/android/AndroidBridge.cpp
index 1e8493bae3fd..5415a69526a5 100644
--- a/widget/src/android/AndroidBridge.cpp
+++ b/widget/src/android/AndroidBridge.cpp
@@ -48,6 +48,7 @@
#include "nsOSHelperAppService.h"
#include "nsWindow.h"
#include "mozilla/Preferences.h"
+#include "nsINetworkLinkService.h"
#ifdef DEBUG
#define ALOG_BRIDGE(args...) ALOG(args)
@@ -141,6 +142,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
jSetKeepScreenOn = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setKeepScreenOn", "(Z)V");
jIsNetworkLinkUp = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "isNetworkLinkUp", "()Z");
jIsNetworkLinkKnown = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "isNetworkLinkKnown", "()Z");
+ jGetNetworkLinkType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getNetworkLinkType", "()I");
jSetSelectedLocale = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setSelectedLocale", "(Ljava/lang/String;)V");
jScanMedia = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scanMedia", "(Ljava/lang/String;Ljava/lang/String;)V");
jGetSystemColors = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getSystemColors", "()[I");
@@ -669,6 +671,13 @@ AndroidBridge::IsNetworkLinkKnown()
return !!mJNIEnv->CallStaticBooleanMethod(mGeckoAppShellClass, jIsNetworkLinkKnown);
}
+int
+AndroidBridge::GetNetworkLinkType()
+{
+ ALOG_BRIDGE("AndroidBridge::GetNetworkLinkType");
+ return (int) mJNIEnv->CallStaticIntMethod(mGeckoAppShellClass, jGetNetworkLinkType);
+}
+
void
AndroidBridge::SetSelectedLocale(const nsAString& aLocale)
{
diff --git a/widget/src/android/AndroidBridge.h b/widget/src/android/AndroidBridge.h
index 54c0b75ed8a7..0b4c301b7cac 100644
--- a/widget/src/android/AndroidBridge.h
+++ b/widget/src/android/AndroidBridge.h
@@ -204,6 +204,8 @@ public:
bool IsNetworkLinkKnown();
+ int GetNetworkLinkType();
+
void SetSelectedLocale(const nsAString&);
void GetSystemColors(AndroidSystemColors *aColors);
@@ -312,6 +314,7 @@ protected:
jmethodID jSetKeepScreenOn;
jmethodID jIsNetworkLinkUp;
jmethodID jIsNetworkLinkKnown;
+ jmethodID jGetNetworkLinkType;
jmethodID jSetSelectedLocale;
jmethodID jScanMedia;
jmethodID jGetSystemColors;
diff --git a/widget/src/android/AndroidJNI.cpp b/widget/src/android/AndroidJNI.cpp
index 73850ed66f91..869e651d55bd 100644
--- a/widget/src/android/AndroidJNI.cpp
+++ b/widget/src/android/AndroidJNI.cpp
@@ -69,7 +69,7 @@ extern "C" {
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onLowMemory(JNIEnv *, jclass);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_callObserver(JNIEnv *, jclass, jstring observerKey, jstring topic, jstring data);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_removeObserver(JNIEnv *jenv, jclass, jstring jObserverKey);
- NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onChangeNetworkLinkStatus(JNIEnv *, jclass, jstring status);
+ NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onChangeNetworkLinkStatus(JNIEnv *, jclass, jstring status, jstring type);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash(JNIEnv *, jclass, jstring stack);
}
@@ -143,7 +143,7 @@ Java_org_mozilla_gecko_GeckoAppShell_removeObserver(JNIEnv *jenv, jclass, jstrin
}
NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_onChangeNetworkLinkStatus(JNIEnv *jenv, jclass, jstring jStatus)
+Java_org_mozilla_gecko_GeckoAppShell_onChangeNetworkLinkStatus(JNIEnv *jenv, jclass, jstring jStatus, jstring jType)
{
if (!nsAppShell::gAppShell)
return;
@@ -153,6 +153,12 @@ Java_org_mozilla_gecko_GeckoAppShell_onChangeNetworkLinkStatus(JNIEnv *jenv, jcl
nsAppShell::gAppShell->NotifyObservers(nsnull,
NS_NETWORK_LINK_TOPIC,
sStatus.get());
+
+ nsJNIString sType(jType, jenv);
+
+ nsAppShell::gAppShell->NotifyObservers(nsnull,
+ NS_NETWORK_LINK_TYPE_TOPIC,
+ sType.get());
}
NS_EXPORT void JNICALL