DO NOT MERGE Reverse meaning of ANDROID_STUB C flag.

Also add defaults so that bluetoothd doesn't crash.

Change-Id: I263cfecff6889ce0530b31b98277df04dd270fb5
diff --git a/glib/Android.mk b/glib/Android.mk
index 975fe1e..de73704 100755
--- a/glib/Android.mk
+++ b/glib/Android.mk
@@ -40,6 +40,9 @@
 	$(LOCAL_PATH)/../ \
 	$(LOCAL_PATH)
 
+LOCAL_CFLAGS:= \
+	-DANDROID_STUB
+
 LOCAL_MODULE:=libglib_static
 
 include $(BUILD_STATIC_LIBRARY)
diff --git a/glib/galiasdef.c b/glib/galiasdef.c
index c8ba51c..f5d8a25 100644
--- a/glib/galiasdef.c
+++ b/glib/galiasdef.c
@@ -459,7 +459,7 @@
 #undef g_get_filename_charsets 
 extern __typeof (g_get_filename_charsets) g_get_filename_charsets __attribute((alias("IA__g_get_filename_charsets"), visibility("default")));
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #undef g_convert 
 extern __typeof (g_convert) g_convert __attribute((alias("IA__g_convert"), visibility("default")));
 #endif
@@ -467,7 +467,7 @@
 #undef g_convert_error_quark 
 extern __typeof (g_convert_error_quark) g_convert_error_quark __attribute((alias("IA__g_convert_error_quark"), visibility("default")));
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #undef g_convert_with_fallback 
 extern __typeof (g_convert_with_fallback) g_convert_with_fallback __attribute((alias("IA__g_convert_with_fallback"), visibility("default")));
 
@@ -2707,7 +2707,7 @@
 #undef g_ascii_dtostr 
 extern __typeof (g_ascii_dtostr) g_ascii_dtostr __attribute((alias("IA__g_ascii_dtostr"), visibility("default")));
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #undef g_ascii_formatd 
 extern __typeof (g_ascii_formatd) g_ascii_formatd __attribute((alias("IA__g_ascii_formatd"), visibility("default")));
 #endif
@@ -2715,7 +2715,7 @@
 #undef g_ascii_strdown 
 extern __typeof (g_ascii_strdown) g_ascii_strdown __attribute((alias("IA__g_ascii_strdown"), visibility("default")));
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #undef g_ascii_strtod 
 extern __typeof (g_ascii_strtod) g_ascii_strtod __attribute((alias("IA__g_ascii_strtod"), visibility("default")));
 #endif
diff --git a/glib/gconvert.c b/glib/gconvert.c
index c0952da..2f4d54f 100644
--- a/glib/gconvert.c
+++ b/glib/gconvert.c
@@ -25,7 +25,7 @@
 #include "glib.h"
 
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #ifndef G_OS_WIN32
 #include <iconv.h>
 #endif
@@ -74,7 +74,7 @@
 		const char *from_codeset,
 		iconv_t    *cd)
 {
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   *cd = iconv_open (to_codeset, from_codeset);
 
   if (*cd == (iconv_t)-1 && errno == EINVAL)
@@ -106,7 +106,7 @@
   return FALSE;
 }
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 G_GNUC_INTERNAL extern const char ** 
 _g_charset_get_aliases (const char *canonical_name);
 #endif
@@ -130,7 +130,7 @@
 g_iconv_open (const gchar  *to_codeset,
 	      const gchar  *from_codeset)
 {
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   iconv_t cd;
   
   if (!try_conversion (to_codeset, from_codeset, &cd))
@@ -188,7 +188,7 @@
 	 gchar  **outbuf,
 	 gsize   *outbytes_left)
 {
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   iconv_t cd = (iconv_t)converter;
 
   return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
@@ -215,7 +215,7 @@
 gint
 g_iconv_close (GIConv converter)
 {
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   iconv_t cd = (iconv_t)converter;
 
   return iconv_close (cd);
diff --git a/glib/gmain.c b/glib/gmain.c
index 61fcdde..47e124b 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -3665,7 +3665,7 @@
   sigaction (SIGCHLD, &action, NULL);
 }
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 G_GNUC_NORETURN static gpointer
 #else
 void
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index b076aa9..ed885fc 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -428,7 +428,7 @@
 
   fail_pos = NULL;
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   locale_data = localeconv ();
 
   decimal_point = locale_data->decimal_point;
@@ -645,7 +645,7 @@
       
   _g_snprintf (buffer, buf_len, format, d);
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   locale_data = localeconv ();
   decimal_point = locale_data->decimal_point;
   decimal_point_len = strlen (decimal_point);
diff --git a/glib/gutf8.c b/glib/gutf8.c
index 9f98cc1..a786aad 100644
--- a/glib/gutf8.c
+++ b/glib/gutf8.c
@@ -22,7 +22,7 @@
 #include "config.h"
 
 #include <stdlib.h>
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #ifdef HAVE_CODESET
 #include <langinfo.h>
 #endif
@@ -38,7 +38,7 @@
 #undef STRICT
 #endif
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #include "libcharset/libcharset.h"
 #endif
 
@@ -447,7 +447,7 @@
 /* As an abuse of the alias table, the following routines gets
  * the charsets that are aliases for the canonical name.
  */
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 G_GNUC_INTERNAL const char ** 
 _g_charset_get_aliases (const char *canonical_name)
 {
@@ -477,11 +477,10 @@
    * a lock, but has a memory leak and a missing memory
    * barrier, so we lock for it
    */
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   G_LOCK (aliases);
   charset = _g_locale_charset_unalias (raw_data);
   G_UNLOCK (aliases);
-#endif
   
   if (charset && *charset)
     {
@@ -492,6 +491,7 @@
       else
 	return FALSE;
     }
+#endif
 
   /* Assume this for compatibility at present.  */
   *a = "US-ASCII";
@@ -553,7 +553,7 @@
       g_static_private_set (&cache_private, cache, charset_cache_free);
     }
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
   raw = _g_locale_charset_raw ();
   
   if (!(cache->raw && strcmp (cache->raw, raw) == 0))
@@ -566,6 +566,9 @@
       cache->is_utf8 = g_utf8_get_charset_internal (raw, &new_charset);
       cache->charset = g_strdup (new_charset);
     }
+#else
+  cache->charset = g_strdup("UTF-8");
+  cache->is_utf8 = TRUE;
 #endif
   if (charset)
     *charset = cache->charset;
diff --git a/glib/gutils.c b/glib/gutils.c
index 8228bab..c8006e9 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -116,7 +116,7 @@
 #include <CoreServices/CoreServices.h>
 #endif
 
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
 #ifdef HAVE_CODESET
 #include <langinfo.h>
 #endif
@@ -1681,7 +1681,7 @@
     while (!pw);
 #  endif /* HAVE_POSIX_GETPWUID_R || HAVE_NONPOSIX_GETPWUID_R */
     
-#ifdef ANDROID_STUB
+#ifndef ANDROID_STUB
     if (!pw)
       {
 	setpwent ();
@@ -1693,7 +1693,7 @@
       {
 	g_user_name = g_strdup (pw->pw_name);
 
-	#ifdef ANDROID_STUB
+	#ifndef ANDROID_STUB
 	if (pw->pw_gecos && *pw->pw_gecos != '\0') 
 	  {
 	    gchar **gecos_fields;