Handle code_cache dir creation in libnativebridge

Also:

- add kPreInitiliazed state to native bridge with check transition:
kOpened->kPreInitialized->kInitialized
- made sure we free the memory for the code_cache_path
- tidy up some error messages
- tidy up tests
- add a dummy native bridge to test with

Bug: 18027433
Bug: 18097480

(cherry picked from commit f9d9e2a2d96559c3165405d572b08e260156074a)

Change-Id: I9ce578949dbe522d5033465df7ca49fdd3aa3cbf
diff --git a/libnativebridge/tests/Android.mk b/libnativebridge/tests/Android.mk
index 9c7e1b8..3373473 100644
--- a/libnativebridge/tests/Android.mk
+++ b/libnativebridge/tests/Android.mk
@@ -1,19 +1,27 @@
 # Build the unit tests.
 LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Android.nativebridge-dummy.mk
+
 include $(CLEAR_VARS)
 
 # Build the unit tests.
 test_src_files := \
+    CompleteFlow_test.cpp \
     InvalidCharsNativeBridge_test.cpp \
     NeedsNativeBridge_test.cpp \
     PreInitializeNativeBridge_test.cpp \
+    PreInitializeNativeBridgeFail1_test.cpp \
+    PreInitializeNativeBridgeFail2_test.cpp \
     ReSetupNativeBridge_test.cpp \
     UnavailableNativeBridge_test.cpp \
     ValidNameNativeBridge_test.cpp
 
+
 shared_libraries := \
     liblog \
-    libnativebridge
+    libnativebridge \
+    libnativebridge-dummy
 
 $(foreach file,$(test_src_files), \
     $(eval include $(CLEAR_VARS)) \
@@ -33,4 +41,4 @@
     $(eval LOCAL_SRC_FILES := $(file)) \
     $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
     $(eval include $(BUILD_HOST_NATIVE_TEST)) \
-)
\ No newline at end of file
+)