Merge "Fix not to show a log with empty default ime"
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 42feab4..961054f 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -232,7 +232,7 @@
     return (jint) check_AudioSystem_Command(AudioSystem::setMasterMute(mute));
 }
 
-static jfloat
+static jboolean
 android_media_AudioSystem_getMasterMute(JNIEnv *env, jobject thiz)
 {
     bool mute;
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 6dc29ed..627a2b8 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -429,13 +429,22 @@
 
     DropCapabilitiesBoundingSet(env);
 
-    bool need_native_bridge = false;
-    if (instructionSet != NULL) {
+    bool use_native_bridge = !is_system_server && (instructionSet != NULL)
+        && android::NativeBridgeAvailable();
+    if (use_native_bridge) {
       ScopedUtfChars isa_string(env, instructionSet);
-      need_native_bridge = android::NeedsNativeBridge(isa_string.c_str());
+      use_native_bridge = android::NeedsNativeBridge(isa_string.c_str());
+    }
+    if (use_native_bridge && dataDir == NULL) {
+      // dataDir should never be null if we need to use a native bridge.
+      // In general, dataDir will never be null for normal applications. It can only happen in
+      // special cases (for isolated processes which are not associated with any app). These are
+      // launched by the framework and should not be emulated anyway.
+      use_native_bridge = false;
+      ALOGW("Native bridge will not be used because dataDir == NULL.");
     }
 
-    if (!MountEmulatedStorage(uid, mount_external, need_native_bridge)) {
+    if (!MountEmulatedStorage(uid, mount_external, use_native_bridge)) {
       ALOGW("Failed to mount emulated storage: %s", strerror(errno));
       if (errno == ENOTCONN || errno == EROFS) {
         // When device is actively encrypting, we get ENOTCONN here
@@ -453,15 +462,10 @@
 
     SetRLimits(env, javaRlimits);
 
-    if (!is_system_server && need_native_bridge) {
-      // Set the environment for the apps running with native bridge.
-      ScopedUtfChars isa_string(env, instructionSet);  // Known non-null because of need_native_...
-      if (dataDir == NULL) {
-        android::PreInitializeNativeBridge(NULL, isa_string.c_str());
-      } else {
-        ScopedUtfChars data_dir(env, dataDir);
-        android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str());
-      }
+    if (use_native_bridge) {
+      ScopedUtfChars isa_string(env, instructionSet);
+      ScopedUtfChars data_dir(env, dataDir);
+      android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str());
     }
 
     int rc = setresgid(gid, gid, gid);
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index 490921e..a2e4769 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -2,6 +2,14 @@
 include $(CLEAR_VARS)
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
+# Too many unused parameters in external/skia/include and this directory.
+# getConfig in external/skia/include/core/SkBitmap.h is deprecated.
+# Allow Gnu extension: in-class initializer of static 'const float' member.
+LOCAL_CLANG_CFLAGS += \
+    -Wno-unused-parameter \
+    -Wno-deprecated-declarations \
+    -Wno-gnu-static-float-init
+
 # Only build libhwui when USE_OPENGL_RENDERER is
 # defined in the current device/board configuration
 ifeq ($(USE_OPENGL_RENDERER),true)
diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h
index 1cd5f1c..4fc60b8 100644
--- a/libs/hwui/DisplayList.h
+++ b/libs/hwui/DisplayList.h
@@ -57,9 +57,9 @@
 class DisplayListRenderer;
 class OpenGLRenderer;
 class Rect;
-class Layer;
-class SkiaColorFilter;
-class SkiaShader;
+struct Layer;
+struct SkiaColorFilter;
+struct SkiaShader;
 
 class ClipRectOp;
 class SaveLayerOp;
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index b70042f..f965123 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -44,7 +44,7 @@
 class OpenGLRenderer;
 class DisplayList;
 class DeferredDisplayList;
-class DeferStateStruct;
+struct DeferStateStruct;
 
 /**
  * A layer has dimensions and is backed by an OpenGL texture or FBO.
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index c13e614..8eb1f92 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2239,7 +2239,9 @@
 
     const uint32_t count = meshWidth * meshHeight * 6;
 
-    ColorTextureVertex mesh[count];
+    Vector<ColorTextureVertex> meshVector; // TODO: use C++11 unique_ptr
+    meshVector.setCapacity(count);
+    ColorTextureVertex* mesh = meshVector.editArray();
     ColorTextureVertex* vertex = mesh;
 
     bool cleanupColors = false;
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 2e03a1b..3fbbe52 100755
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -1126,7 +1126,7 @@
     String8 mName;
 
     friend class DisplayListRenderer;
-    friend class Layer;
+    friend struct Layer;
     friend class TextSetupFunctor;
     friend class DrawBitmapOp;
     friend class DrawPatchOp;
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 24f88f1..4fecd77 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -32,7 +32,7 @@
 class SkCanvas;
 class SkPaint;
 class SkPath;
-class SkRect;
+struct SkRect;
 
 namespace android {
 namespace uirenderer {
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index aba2a98..f8a4249 100644
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -732,7 +732,7 @@
         AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
             @Override
             public void run() {
-                GpsXtraDownloader xtraDownloader = new GpsXtraDownloader(mContext, mProperties);
+                GpsXtraDownloader xtraDownloader = new GpsXtraDownloader(mProperties);
                 byte[] data = xtraDownloader.downloadXtraData();
                 if (data != null) {
                     if (DEBUG) {
diff --git a/services/java/com/android/server/location/GpsXtraDownloader.java b/services/java/com/android/server/location/GpsXtraDownloader.java
index e420073..a1c23ae 100644
--- a/services/java/com/android/server/location/GpsXtraDownloader.java
+++ b/services/java/com/android/server/location/GpsXtraDownloader.java
@@ -17,20 +17,13 @@
 package com.android.server.location;
 
 import android.content.Context;
-import android.net.Proxy;
-import android.net.http.AndroidHttpClient;
 import android.util.Log;
 
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.conn.params.ConnRouteParams;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import libcore.io.IoUtils;
+import libcore.io.Streams;
 
-import java.io.DataInputStream;
 import java.io.IOException;
 import java.util.Properties;
 import java.util.Random;
@@ -44,15 +37,12 @@
 
     private static final String TAG = "GpsXtraDownloader";
     static final boolean DEBUG = false;
-    
-    private Context mContext;
-    private String[] mXtraServers;
+
+    private final String[] mXtraServers;
     // to load balance our server requests
     private int mNextServerIndex;
 
-    GpsXtraDownloader(Context context, Properties properties) {
-        mContext = context;
-
+    GpsXtraDownloader(Properties properties) {
         // read XTRA servers from the Properties object
         int count = 0;
         String server1 = properties.getProperty("XTRA_SERVER_1");
@@ -64,7 +54,7 @@
         
         if (count == 0) {
             Log.e(TAG, "No XTRA servers were specified in the GPS configuration");
-            return;
+            mXtraServers = null;
         } else {
             mXtraServers = new String[count];
             count = 0;
@@ -79,9 +69,6 @@
     }
 
     byte[] downloadXtraData() {
-        String proxyHost = Proxy.getHost(mContext);
-        int proxyPort = Proxy.getPort(mContext);
-        boolean useProxy = (proxyHost != null && proxyPort != -1);
         byte[] result = null;
         int startIndex = mNextServerIndex;
 
@@ -91,7 +78,7 @@
 
         // load balance our requests among the available servers
         while (result == null) {
-            result = doDownload(mXtraServers[mNextServerIndex], useProxy, proxyHost, proxyPort);
+            result = doDownload(mXtraServers[mNextServerIndex]);
             
             // increment mNextServerIndex and wrap around if necessary
             mNextServerIndex++;
@@ -105,64 +92,32 @@
         return result;
     }
 
-    protected static byte[] doDownload(String url, boolean isProxySet, 
-            String proxyHost, int proxyPort) {
+    protected static byte[] doDownload(String url) {
         if (DEBUG) Log.d(TAG, "Downloading XTRA data from " + url);
 
-        AndroidHttpClient client = null;
+        HttpURLConnection connection = null;
         try {
-            client = AndroidHttpClient.newInstance("Android");
-            HttpUriRequest req = new HttpGet(url);
-
-            if (isProxySet) {
-                HttpHost proxy = new HttpHost(proxyHost, proxyPort);
-                ConnRouteParams.setDefaultProxy(req.getParams(), proxy);
-            }
-
-            req.addHeader(
+            connection = (HttpURLConnection) (new URL(url)).openConnection();
+            connection.setRequestProperty(
                     "Accept",
                     "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
-
-            req.addHeader(
+            connection.setRequestProperty(
                     "x-wap-profile",
                     "http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20021212#");
 
-            HttpResponse response = client.execute(req);
-            StatusLine status = response.getStatusLine();
-            if (status.getStatusCode() != 200) { // HTTP 200 is success.
-                if (DEBUG) Log.d(TAG, "HTTP error: " + status.getReasonPhrase());
+            connection.connect();
+            int statusCode = connection.getResponseCode();
+            if (statusCode != HttpURLConnection.HTTP_OK) {
+                if (DEBUG) Log.d(TAG, "HTTP error downloading gps XTRA: " + statusCode);
                 return null;
             }
 
-            HttpEntity entity = response.getEntity();
-            byte[] body = null;
-            if (entity != null) {
-                try {
-                    if (entity.getContentLength() > 0) {
-                        body = new byte[(int) entity.getContentLength()];
-                        DataInputStream dis = new DataInputStream(entity.getContent());
-                        try {
-                            dis.readFully(body);
-                        } finally {
-                            try {
-                                dis.close();
-                            } catch (IOException e) {
-                                Log.e(TAG, "Unexpected IOException.", e);
-                            }
-                        }
-                    }
-                } finally {
-                    if (entity != null) {
-                        entity.consumeContent();
-                    }
-                }
-            }
-            return body;
-        } catch (Exception e) {
-            if (DEBUG) Log.d(TAG, "error " + e);
+            return Streams.readFully(connection.getInputStream());
+        } catch (IOException ioe) {
+            if (DEBUG) Log.d(TAG, "Error downloading gps XTRA: ", ioe);
         } finally {
-            if (client != null) {
-                client.close();
+            if (connection != null) {
+                connection.disconnect();
             }
         }
         return null;
diff --git a/tests/SslLoad/Android.mk b/tests/SslLoad/Android.mk
deleted file mode 100644
index f75be8d..0000000
--- a/tests/SslLoad/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := SslLoad
-
-include $(BUILD_PACKAGE)
diff --git a/tests/SslLoad/AndroidManifest.xml b/tests/SslLoad/AndroidManifest.xml
deleted file mode 100644
index 497b1c7..0000000
--- a/tests/SslLoad/AndroidManifest.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.sslload">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <activity android:name="SslLoad" android:label="SSL Load">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-    </application>
-</manifest> 
diff --git a/tests/SslLoad/src/com/android/sslload/SslLoad.java b/tests/SslLoad/src/com/android/sslload/SslLoad.java
deleted file mode 100644
index 62aa524..0000000
--- a/tests/SslLoad/src/com/android/sslload/SslLoad.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sslload;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Calendar;
-import java.util.Map;
-
-import android.app.Activity;
-import android.content.res.Resources;
-import android.media.MediaPlayer;
-import android.os.Handler;
-import android.os.Vibrator;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-import android.util.Log;
-import android.net.http.AndroidHttpClient;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.HttpResponse;
-
-public class SslLoad extends Activity implements OnClickListener, Runnable {
-
-    private static final String TAG = SslLoad.class.getSimpleName();
-
-    private Button button;
-    private boolean running = false;
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-
-        Thread requestThread = new Thread(this);
-        requestThread.setDaemon(true);
-        requestThread.start();
-
-        button = new Button(this);
-        button.setText("GO");
-        button.setOnClickListener(this);
-
-        setContentView(button);
-    }
-    
-    @Override
-    protected void onStop() {
-        super.onStop();
-
-        synchronized (this) {
-            running = false;
-        }
-    }
-
-    public void onClick(View v) {
-        synchronized (this) {
-            running = !running;
-            button.setText(running ? "STOP" : "GO");
-            if (running) {
-                this.notifyAll();
-            }
-        }
-    }
-
-    public void run() {
-        boolean error = false;
-        while (true) {
-            synchronized (this) {
-                while (!running) {
-                    try {
-                        this.wait();
-                    } catch (InterruptedException e) { /* ignored */ }
-                }
-            }
-
-            AndroidHttpClient client = AndroidHttpClient.newInstance(
-                    "Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101");
-            try {
-                // Cert. is for "www.google.com", not "google.com".
-                String url = error ? "https://google.com/"
-                        : "https://www.google.com";
-                client.execute(new HttpGet(url),
-                        new ResponseHandler<Void>() {
-                            public Void handleResponse(HttpResponse response) {
-                                /* ignore */
-                                return null;
-                            }
-                        });
-                Log.i(TAG, "Request succeeded.");
-            } catch (IOException e) {
-                Log.w(TAG, "Request failed.", e);
-            }
-
-            client.close();
-            
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException e) { /* ignored */ }
-
-            error = !error;
-        }
-    }
-}