diff --git a/widget/src/android/AndroidBridge.cpp b/widget/src/android/AndroidBridge.cpp index b3b5f23aa4d7..193966e25206 100644 --- a/widget/src/android/AndroidBridge.cpp +++ b/widget/src/android/AndroidBridge.cpp @@ -642,6 +642,23 @@ AndroidBridge::CallEglCreateWindowSurface(void *dpy, void *config, AndroidGeckoS return (void*) realSurface; } +bool +AndroidBridge::GetStaticIntField(const char *className, const char *fieldName, PRInt32* aInt) +{ + AutoLocalJNIFrame jniFrame(3); + jclass cls = mJNIEnv->FindClass(className); + if (!cls) + return false; + + jfieldID field = mJNIEnv->GetStaticFieldID(cls, fieldName, "I"); + if (!field) + return false; + + *aInt = static_cast(mJNIEnv->GetStaticIntField(cls, field)); + + return true; +} + bool AndroidBridge::GetStaticStringField(const char *className, const char *fieldName, nsAString &result) { diff --git a/widget/src/android/AndroidBridge.h b/widget/src/android/AndroidBridge.h index c5bd4c8ed429..2e7d9e3245f7 100644 --- a/widget/src/android/AndroidBridge.h +++ b/widget/src/android/AndroidBridge.h @@ -217,6 +217,8 @@ public: bool GetStaticStringField(const char *classID, const char *field, nsAString &result); + bool GetStaticIntField(const char *className, const char *fieldName, PRInt32* aInt); + void SetKeepScreenOn(bool on); protected: diff --git a/xpcom/base/nsSystemInfo.cpp b/xpcom/base/nsSystemInfo.cpp index 0279a225b968..1afab5f5ed25 100644 --- a/xpcom/base/nsSystemInfo.cpp +++ b/xpcom/base/nsSystemInfo.cpp @@ -149,8 +149,22 @@ nsSystemInfo::Init() SetPropertyAsAString(NS_LITERAL_STRING("device"), str); if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", str)) SetPropertyAsAString(NS_LITERAL_STRING("manufacturer"), str); - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) + PRInt32 version; + if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &version)) + version = 0; + if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) SetPropertyAsAString(NS_LITERAL_STRING("hardware"), str); + SetPropertyAsAString(NS_LITERAL_STRING("shellName"), NS_LITERAL_STRING("Android")); + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "CODENAME", str)) { + if (version) { + str.Append(NS_LITERAL_STRING(" (")); + str.AppendInt(version); + str.Append(NS_LITERAL_STRING(")")); + } + SetPropertyAsAString(NS_LITERAL_STRING("shellVersion"), str); + } + + } #endif return NS_OK;