Some Android stuff, for piecing out into bugs later.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 20 May 2015 12:46:32 -0400
changeset 268045 e0a021a21d7fcbe8b8d056816ca1e1dc3e14b2e3
parent 268044 a76f443cf02f2a3df05dfd505a2933f341efa896
child 268046 2e220a479cdd7a345359fefbe05499b740c7a6ee
child 268047 cc8ba6f2884816b7dbe95148e402ca3554a8e2bb
push id2294
push userbsmedberg@mozilla.com
push dateWed, 27 May 2015 15:05:10 +0000
milestone41.0a1
Some Android stuff, for piecing out into bugs later.
js/xpconnect/src/XPCDebug.cpp
python/mozboot/mozboot/android.py
python/mozboot/mozboot/fedora.py
security/manager/ssl/src/nsNSSComponent.cpp
--- a/js/xpconnect/src/XPCDebug.cpp
+++ b/js/xpconnect/src/XPCDebug.cpp
@@ -7,16 +7,19 @@
 #include "xpcprivate.h"
 #include "jsprf.h"
 #include "nsThreadUtils.h"
 #include "nsContentUtils.h"
 
 #ifdef XP_WIN
 #include <windows.h>
 #endif
+#ifdef ANDROID
+#include <android/log.h>
+#endif
 
 static void DebugDump(const char* fmt, ...)
 {
   char buffer[2048];
   va_list ap;
   va_start(ap, fmt);
 #ifdef XPWIN
   _vsnprintf(buffer, sizeof(buffer), fmt, ap);
@@ -25,16 +28,19 @@ static void DebugDump(const char* fmt, .
 #endif
   buffer[sizeof(buffer)-1] = '\0';
   va_end(ap);
 #ifdef XP_WIN
   if (IsDebuggerPresent()) {
     OutputDebugStringA(buffer);
   }
 #endif
+#ifdef ANDROID
+  __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", buffer);
+#endif
   printf("%s", buffer);
 }
 
 bool
 xpc_DumpJSStack(bool showArgs, bool showLocals, bool showThisProps)
 {
     JSContext* cx = nsContentUtils::GetCurrentJSContextForThread();
     if (!cx) {
--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -9,17 +9,17 @@ import errno
 import os
 import subprocess
 
 
 # These are the platform and build-tools versions for building
 # mobile/android, respectively. Try to keep these in synch with the
 # build system and Mozilla's automation.
 ANDROID_PLATFORM = 'android-21'
-ANDROID_BUILD_TOOLS_VERSION = '21.1.2'
+ANDROID_BUILD_TOOLS_VERSION = '22.0.1'
 
 # These are the "Android packages" needed for building Firefox for Android.
 # Use |android list sdk --extended| to see these identifiers.
 ANDROID_PACKAGES = [
     'tools',
     'platform-tools',
     'build-tools-%s' % ANDROID_BUILD_TOOLS_VERSION,
     ANDROID_PLATFORM,
--- a/python/mozboot/mozboot/fedora.py
+++ b/python/mozboot/mozboot/fedora.py
@@ -1,13 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from mozboot.base import BaseBootstrapper
+import os
+import sys
 
 
 class FedoraBootstrapper(BaseBootstrapper):
     def __init__(self, version, dist_id, **kwargs):
         BaseBootstrapper.__init__(self, **kwargs)
 
         self.version = version
         self.dist_id = dist_id
@@ -43,10 +45,57 @@ class FedoraBootstrapper(BaseBootstrappe
     def install_system_packages(self):
         self.yum_groupinstall(*self.group_packages)
         self.yum_install(*self.packages)
 
     def install_browser_packages(self):
         self.yum_groupinstall(*self.browser_group_packages)
         self.yum_install(*self.browser_packages)
 
+    def install_mobile_android_packages(self):
+        import android
+
+        # Multi-part process:
+        # 1. System packages.
+        # 2. Android SDK and NDK.
+        # 3. Android packages.
+
+        # 1. This is hard to believe, but the Android SDK binaries are 32-bit
+        # and that conflicts with 64-bit Debian and Ubuntu installations out of
+        # the box.  The solution is to add the i386 architecture.  See
+        # "Troubleshooting Ubuntu" at
+        # http://developer.android.com/sdk/installing/index.html?pkg=tools.
+        #self.run_as_root(['dpkg', '--add-architecture', 'i386'])
+        # After adding a new arch, the list of packages has to be updated
+        #self.apt_update()
+        #self.apt_install(*self.mobile_android_packages)
+
+        # 2. The user may have an external Android SDK (in which case we save
+        # them a lengthy download), or they may have already completed the
+        # download. We unpack to ~/.mozbuild/{android-sdk-linux, android-ndk-r8e}.
+        mozbuild_path = os.environ.get('MOZBUILD_STATE_PATH', os.path.expanduser(os.path.join('~', '.mozbuild')))
+        self.sdk_path = os.environ.get('ANDROID_SDK_HOME', os.path.join(mozbuild_path, 'android-sdk-linux'))
+        self.ndk_path = os.environ.get('ANDROID_NDK_HOME', os.path.join(mozbuild_path, 'android-ndk-r8e'))
+        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-linux.tgz'
+        is_64bits = sys.maxsize > 2**32
+        if is_64bits:
+            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2'
+        else:
+            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2'
+        android.ensure_android_sdk_and_ndk(path=mozbuild_path,
+                                           sdk_path=self.sdk_path, sdk_url=self.sdk_url,
+                                           ndk_path=self.ndk_path, ndk_url=self.ndk_url)
+
+        # 3. We expect the |android| tool to at
+        # ~/.mozbuild/android-sdk-linux/tools/android.
+        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
+        android.ensure_android_packages(android_tool=android_tool)
+
+    def suggest_mobile_android_mozconfig(self):
+        import android
+
+        # The SDK path that mozconfig wants includes platforms/android-21.
+        sdk_path = os.path.join(self.sdk_path, 'platforms', android.ANDROID_PLATFORM)
+        android.suggest_mozconfig(sdk_path=sdk_path,
+                                  ndk_path=self.ndk_path)
+
     def upgrade_mercurial(self, current):
         self.yum_update('mercurial')
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -963,19 +963,23 @@ GetNSSProfilePath(nsAutoCString& aProfil
     MOZ_LOG(gPIPNSSLog, PR_LOG_ERROR,
            ("Could not get native path for profile directory.\n"));
     return rv;
   }
 
   return NS_OK;
 }
 
+NS_EXTERN_C NS_IMPORT void DumpJSStack();
+
 nsresult
 nsNSSComponent::InitializeNSS()
 {
+  DumpJSStack();
+
   // Can be called both during init and profile change.
   // Needs mutex protection.
 
   MOZ_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsNSSComponent::InitializeNSS\n"));
 
   static_assert(nsINSSErrorsService::NSS_SEC_ERROR_BASE == SEC_ERROR_BASE &&
                 nsINSSErrorsService::NSS_SEC_ERROR_LIMIT == SEC_ERROR_LIMIT &&
                 nsINSSErrorsService::NSS_SSL_ERROR_BASE == SSL_ERROR_BASE &&