Merge "WifiP2pWfdInfo set device type bugfix"
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index e4fad09..b5e068d 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -209,7 +209,8 @@
 	libjpeg \
 	libusbhost \
 	libharfbuzz_ng \
-	libz
+	libz \
+	libnativebridge
 
 ifeq ($(USE_OPENGL_RENDERER),true)
 	LOCAL_SHARED_LIBRARIES += libhwui
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 98ea9a2..274d1a2 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -798,7 +798,7 @@
                                    "-Xmx", "-Xcompiler-option");
         if (skip_compilation) {
             addOption("-Xcompiler-option");
-            addOption("--compiler-filter=interpret-only");
+            addOption("--compiler-filter=verify-none");
         } else {
             parseCompilerOption("dalvik.vm.dex2oat-filter", dex2oatCompilerFilterBuf,
                                 "--compiler-filter=", "-Xcompiler-option");
diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp
index 9c44093..633a207 100644
--- a/core/jni/android_app_NativeActivity.cpp
+++ b/core/jni/android_app_NativeActivity.cpp
@@ -38,6 +38,8 @@
 #include "android_view_InputChannel.h"
 #include "android_view_KeyEvent.h"
 
+#include "nativebridge/native_bridge.h"
+
 #define LOG_TRACE(...)
 //#define LOG_TRACE(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
 
@@ -251,17 +253,29 @@
 
     const char* pathStr = env->GetStringUTFChars(path, NULL);
     NativeCode* code = NULL;
-    
+    bool needNativeBridge = false;
+
     void* handle = dlopen(pathStr, RTLD_LAZY);
-    
+    if (handle == NULL) {
+        if (NativeBridgeIsSupported(pathStr)) {
+            handle = NativeBridgeLoadLibrary(pathStr, RTLD_LAZY);
+            needNativeBridge = true;
+        }
+    }
     env->ReleaseStringUTFChars(path, pathStr);
-    
+
     if (handle != NULL) {
+        void* funcPtr = NULL;
         const char* funcStr = env->GetStringUTFChars(funcName, NULL);
-        code = new NativeCode(handle, (ANativeActivity_createFunc*)
-                dlsym(handle, funcStr));
+        if (needNativeBridge) {
+            funcPtr = NativeBridgeGetTrampoline(handle, funcStr, NULL, 0);
+        } else {
+            funcPtr = dlsym(handle, funcStr);
+        }
+
+        code = new NativeCode(handle, (ANativeActivity_createFunc*)funcPtr);
         env->ReleaseStringUTFChars(funcName, funcStr);
-        
+
         if (code->createActivityFunc == NULL) {
             ALOGW("ANativeActivity_onCreate not found");
             delete code;
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 4b2f740..e0003b8 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -1036,16 +1036,9 @@
 }
 
 // We only measure binder call durations to potentially log them if
-// we're on the main thread.  Unfortunately sim-eng doesn't seem to
-// have gettid, so we just ignore this and don't log if we can't
-// get the thread id.
+// we're on the main thread.
 static bool should_time_binder_calls() {
-#ifdef HAVE_GETTID
-  return (getpid() == androidGetTid());
-#else
-#warning no gettid(), so not logging Binder calls...
-  return false;
-#endif
+  return (getpid() == gettid());
 }
 
 static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj,
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 31876ce..fbe7a17 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -268,7 +268,7 @@
     // Establishes the calling thread as illegal to put into the background.
     // Typically used only for the system process's main looper.
 #if GUARD_THREAD_PRIORITY
-    ALOGV("Process.setCanSelfBackground(%d) : tid=%d", bgOk, androidGetTid());
+    ALOGV("Process.setCanSelfBackground(%d) : tid=%d", bgOk, gettid());
     {
         Mutex::Autolock _l(gKeyCreateMutex);
         if (gBgKey == -1) {
@@ -303,7 +303,7 @@
     // if we're putting the current thread into the background, check the TLS
     // to make sure this thread isn't guarded.  If it is, raise an exception.
     if (pri >= ANDROID_PRIORITY_BACKGROUND) {
-        if (pid == androidGetTid()) {
+        if (pid == gettid()) {
             void* bgOk = pthread_getspecific(gBgKey);
             if (bgOk == ((void*)0xbaad)) {
                 ALOGE("Thread marked fg-only put self in background!");
@@ -330,7 +330,7 @@
 void android_os_Process_setCallingThreadPriority(JNIEnv* env, jobject clazz,
                                                         jint pri)
 {
-    android_os_Process_setThreadPriority(env, clazz, androidGetTid(), pri);
+    android_os_Process_setThreadPriority(env, clazz, gettid(), pri);
 }
 
 jint android_os_Process_getThreadPriority(JNIEnv* env, jobject clazz,
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp
index a485d2b..5f6e831 100644
--- a/libs/androidfw/ZipFileRO.cpp
+++ b/libs/androidfw/ZipFileRO.cpp
@@ -50,8 +50,7 @@
     ZipEntryName name;
     void *cookie;
 
-    _ZipEntryRO() : cookie(NULL) {
-    }
+    _ZipEntryRO() : cookie(NULL) {}
 
     ~_ZipEntryRO() {
       EndIteration(cookie);
@@ -87,15 +86,15 @@
 ZipEntryRO ZipFileRO::findEntryByName(const char* entryName) const
 {
     _ZipEntryRO* data = new _ZipEntryRO;
-    const int32_t error = FindEntry(mHandle, entryName, &(data->entry));
+
+    data->name = ZipEntryName(entryName);
+
+    const int32_t error = FindEntry(mHandle, data->name, &(data->entry));
     if (error) {
         delete data;
         return NULL;
     }
 
-    data->name.name = entryName;
-    data->name.name_length = strlen(entryName);
-
     return (ZipEntryRO) data;
 }
 
diff --git a/tools/obbtool/Main.cpp b/tools/obbtool/Main.cpp
index b2152e8..64808c0 100644
--- a/tools/obbtool/Main.cpp
+++ b/tools/obbtool/Main.cpp
@@ -89,7 +89,7 @@
         "   Prints the OBB signature information of a file.\n\n", gProgName);
 }
 
-void doAdd(const char* filename, struct PackageInfo* info) {
+void doAdd(const char* filename, PackageInfo* info) {
     ObbFile *obb = new ObbFile();
     if (obb->readFrom(filename)) {
         fprintf(stderr, "ERROR: %s: OBB signature already present\n", filename);
@@ -182,7 +182,7 @@
 {
     int opt;
     int option_index = 0;
-    struct PackageInfo package_info;
+    PackageInfo package_info;
 
     int result = 1;    // pessimistically assume an error.