Backed out changeset 8d3ff1d1a809 (bug 1220344) for failing android tests
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 05 Nov 2015 11:48:06 +0100
changeset 306859 0d761deb68d9652924487dbf96d710c91e24c772
parent 306858 627c94419617d5237bdae594ce033b5d6e374ad2
child 306860 40f682605bd05d9ce1a2e15e643f553d2cd44ad0
push id7204
push usercku@mozilla.com
push dateThu, 05 Nov 2015 15:38:26 +0000
bugs1220344
milestone45.0a1
backs out8d3ff1d1a8097b865b9e3123ee89d4f75cb6867a
Backed out changeset 8d3ff1d1a809 (bug 1220344) for failing android tests
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
xpcom/base/nsSystemInfo.cpp
xpcom/base/nsSystemInfo.h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5733,28 +5733,16 @@ ContentParent::RecvGetDeviceStorageLocat
 #ifdef MOZ_WIDGET_ANDROID
   mozilla::AndroidBridge::GetExternalPublicDirectory(aType, *aPath);
   return true;
 #else
   return false;
 #endif
 }
 
-bool
-ContentParent::RecvGetAndroidSystemInfo(AndroidSystemInfo* aInfo)
-{
-#ifdef MOZ_WIDGET_ANDROID
-  nsSystemInfo::GetAndroidSystemInfo(aInfo);
-  return true;
-#else
-  MOZ_CRASH("wrong platform!");
-  return false;
-#endif
-}
-
 } // namespace dom
 } // namespace mozilla
 
 NS_IMPL_ISUPPORTS(ParentIdleListener, nsIObserver)
 
 NS_IMETHODIMP
 ParentIdleListener::Observe(nsISupports*, const char* aTopic, const char16_t* aData) {
     mozilla::Unused << mParent->SendNotifyIdleObserver(mObserver,
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -935,19 +935,16 @@ private:
 
     virtual bool RecvGamepadListenerAdded() override;
     virtual bool RecvGamepadListenerRemoved() override;
     virtual bool RecvProfile(const nsCString& aProfile) override;
     virtual bool RecvGetGraphicsDeviceInitData(DeviceInitData* aOut) override;
 
     virtual bool RecvGetDeviceStorageLocation(const nsString& aType,
                                               nsString* aPath) override;
-
-    virtual bool RecvGetAndroidSystemInfo(AndroidSystemInfo* aInfo) override;
-
     // If you add strong pointers to cycle collected objects here, be sure to
     // release these objects in ShutDownProcess.  See the comment there for more
     // details.
 
     GeckoChildProcessHost* mSubprocess;
     ContentParent* mOpener;
 
     ContentParentId mChildID;
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -411,26 +411,16 @@ union GamepadChangeEvent {
 };
 
 struct FrameScriptInfo
 {
     nsString url;
     bool runInGlobalScope;
 };
 
-struct AndroidSystemInfo
-{
-    nsString device;
-    nsString manufacturer;
-    nsString release_version;
-    nsString hardware;
-    uint32_t sdk_version;
-    bool     isTablet;
-};
-
 prio(normal upto urgent) sync protocol PContent
 {
     parent spawns PPluginModule;
 
     parent opens PCompositor;
     parent opens PProcessHangMonitor;
     parent opens PSharedBufferManager;
     parent opens PImageBridge;
@@ -1139,18 +1129,15 @@ parent:
       returns (nsresult rv,
                bool windowOpened,
                FrameScriptInfo[] frameScripts,
                nsCString urlToLoad);
 
     sync GetDeviceStorageLocation(nsString type)
         returns (nsString path);
 
-    sync GetAndroidSystemInfo()
-        returns (AndroidSystemInfo info);
-
 both:
      AsyncMessage(nsString aMessage, ClonedMessageData aData,
                   CpowEntry[] aCpows, Principal aPrincipal);
 };
 
 }
 }
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -37,17 +37,16 @@
 #include "nsCharSeparatedTokenizer.h"
 
 #include <map>
 #include <string>
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
-#include "mozilla/dom/ContentChild.h"
 #endif
 
 #ifdef MOZ_WIDGET_GONK
 #include <sys/system_properties.h>
 #include "mozilla/Preferences.h"
 #include "nsPrintfCString.h"
 #endif
 
@@ -688,26 +687,50 @@ nsSystemInfo::Init()
     PR_smprintf_free(gtkver);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
-  AndroidSystemInfo info;
-  if (XRE_IsContentProcess()) {
-    dom::ContentChild* child = dom::ContentChild::GetSingleton();
-    if (child) {
-      child->SendGetAndroidSystemInfo(&info);
-      SetupAndroidInfo(info);
+  if (mozilla::AndroidBridge::Bridge()) {
+    nsAutoString str;
+    if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
+          "android/os/Build", "MODEL", str)) {
+      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$VERSION", "RELEASE", str)) {
+      SetPropertyAsAString(NS_LITERAL_STRING("release_version"), str);
     }
-  } else {
-    GetAndroidSystemInfo(&info);
-    SetupAndroidInfo(info);
+    int32_t version;
+    if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField(
+          "android/os/Build$VERSION", "SDK_INT", &version)) {
+      version = 0;
+    }
+    android_sdk_version = version;
+    if (version >= 8 &&
+        mozilla::AndroidBridge::Bridge()->GetStaticStringField(
+          "android/os/Build", "HARDWARE", str)) {
+      SetPropertyAsAString(NS_LITERAL_STRING("hardware"), str);
+    }
+    bool isTablet = mozilla::widget::GeckoAppShell::IsTablet();
+    SetPropertyAsBool(NS_LITERAL_STRING("tablet"), isTablet);
+    // NSPR "version" is the kernel version. For Android we want the Android version.
+    // Rename SDK version to version and put the kernel version into kernel_version.
+    rv = GetPropertyAsAString(NS_LITERAL_STRING("version"), str);
+    if (NS_SUCCEEDED(rv)) {
+      SetPropertyAsAString(NS_LITERAL_STRING("kernel_version"), str);
+    }
+    SetPropertyAsInt32(NS_LITERAL_STRING("version"), android_sdk_version);
   }
 #endif
 
 #ifdef MOZ_WIDGET_GONK
   char sdk[PROP_VALUE_MAX];
   if (__system_property_get("ro.build.version.sdk", sdk)) {
     android_sdk_version = atoi(sdk);
     SetPropertyAsInt32(NS_LITERAL_STRING("sdk_version"), android_sdk_version);
@@ -765,81 +788,16 @@ nsSystemInfo::Init()
     SetPropertyAsBool(NS_LITERAL_STRING("canSandboxMedia"),
                       sandInfo.CanSandboxMedia());
   }
 #endif // XP_LINUX && MOZ_SANDBOX
 
   return NS_OK;
 }
 
-#ifdef MOZ_WIDGET_ANDROID
-/* static */
-void
-nsSystemInfo::GetAndroidSystemInfo(AndroidSystemInfo* aInfo)
-{
-  MOZ_ASSERT(XRE_IsParentProcess());
-
-  if (!mozilla::AndroidBridge::Bridge()) {
-    return;
-  }
-
-  nsAutoString str;
-  if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
-      "android/os/Build", "MODEL", str)) {
-    aInfo->device() = str;
-  }
-  if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
-      "android/os/Build", "MANUFACTURER", str)) {
-    aInfo->manufacturer() = str;
-  }
-  if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
-      "android/os/Build$VERSION", "RELEASE", str)) {
-    aInfo->release_version() = str;
-  }
-  if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
-      "android/os/Build", "HARDWARE", str)) {
-    aInfo->hardware() = str;
-  }
-  int32_t sdk_version;
-  if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField(
-      "android/os/Build$VERSION", "SDK_INT", &sdk_version)) {
-    sdk_version = 0;
-  }
-  aInfo->sdk_version() = sdk_version;
-  aInfo->isTablet() = mozilla::widget::GeckoAppShell::IsTablet();
-}
-
-void
-nsSystemInfo::SetupAndroidInfo(const AndroidSystemInfo& aInfo)
-{
-  if (!aInfo.device().IsEmpty()) {
-    SetPropertyAsAString(NS_LITERAL_STRING("device"), aInfo.device());
-  }
-  if (!aInfo.manufacturer().IsEmpty()) {
-    SetPropertyAsAString(NS_LITERAL_STRING("manufacturer"), aInfo.manufacturer());
-  }
-  if (!aInfo.release_version().IsEmpty()) {
-    SetPropertyAsAString(NS_LITERAL_STRING("release_version"), aInfo.release_version());
-  }
-  android_sdk_version = aInfo.sdk_version();
-  if (android_sdk_version >= 8 && !aInfo.hardware().IsEmpty()) {
-    SetPropertyAsAString(NS_LITERAL_STRING("hardware"), aInfo.hardware());
-  }
-  SetPropertyAsBool(NS_LITERAL_STRING("tablet"), aInfo.isTablet());
-  // NSPR "version" is the kernel version. For Android we want the Android version.
-  // Rename SDK version to version and put the kernel version into kernel_version.
-  nsAutoString str;
-  nsresult rv = GetPropertyAsAString(NS_LITERAL_STRING("version"), str);
-  if (NS_SUCCEEDED(rv)) {
-    SetPropertyAsAString(NS_LITERAL_STRING("kernel_version"), str);
-  }
-  SetPropertyAsInt32(NS_LITERAL_STRING("version"), android_sdk_version);
-}
-#endif // MOZ_WIDGET_ANDROID
-
 void
 nsSystemInfo::SetInt32Property(const nsAString& aPropertyName,
                                const int32_t aValue)
 {
   NS_WARN_IF_FALSE(aValue > 0, "Unable to read system value");
   if (aValue > 0) {
 #ifdef DEBUG
     nsresult rv =
--- a/xpcom/base/nsSystemInfo.h
+++ b/xpcom/base/nsSystemInfo.h
@@ -7,20 +7,16 @@
 #ifndef _NSSYSTEMINFO_H_
 #define _NSSYSTEMINFO_H_
 
 #include "nsHashPropertyBag.h"
 #if defined(XP_WIN)
 #include "nsIObserver.h"
 #endif // defined(XP_WIN)
 
-#ifdef MOZ_WIDGET_ANDROID
-#include "mozilla/dom/PContent.h"
-#endif // MOZ_WIDGET_ANDROID
-
 class nsSystemInfo final
   : public nsHashPropertyBag
 #if defined(XP_WIN)
   , public nsIObserver
 #endif // defined(XP_WIN)
 {
 public:
 #if defined(XP_WIN)
@@ -31,22 +27,16 @@ public:
   nsSystemInfo();
 
   nsresult Init();
 
   // Slot for NS_InitXPCOM2 to pass information to nsSystemInfo::Init.
   // See comments above the variable definition and in NS_InitXPCOM2.
   static uint32_t gUserUmask;
 
-#ifdef MOZ_WIDGET_ANDROID
-  static void GetAndroidSystemInfo(mozilla::dom::AndroidSystemInfo* aInfo);
-  protected:
-    void SetupAndroidInfo(const mozilla::dom::AndroidSystemInfo&);
-#endif
-
 protected:
   void SetInt32Property(const nsAString& aPropertyName,
                         const int32_t aValue);
   void SetUint32Property(const nsAString& aPropertyName,
                          const uint32_t aValue);
   void SetUint64Property(const nsAString& aPropertyName,
                          const uint64_t aValue);