merge in nyc-bugfix-release history after reset to nyc-dev
diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk
index 7f3fe22..7c8842c 100644
--- a/cmds/bootanimation/Android.mk
+++ b/cmds/bootanimation/Android.mk
@@ -23,8 +23,7 @@
     libEGL \
     libGLESv1_CM \
     libgui \
-    libtinyalsa \
-    libmedia
+    libtinyalsa
 
 LOCAL_MODULE:= bootanimation
 
diff --git a/cmds/bootanimation/AudioPlayer.cpp b/cmds/bootanimation/AudioPlayer.cpp
index f5acac4..2932130 100644
--- a/cmds/bootanimation/AudioPlayer.cpp
+++ b/cmds/bootanimation/AudioPlayer.cpp
@@ -23,7 +23,6 @@
 #include <tinyalsa/asoundlib.h>
 #include <utils/Log.h>
 #include <utils/String8.h>
-#include <media/AudioSystem.h>
 
 #define ID_RIFF 0x46464952
 #define ID_WAVE 0x45564157
@@ -144,9 +143,6 @@
     struct mixer* mixer = NULL;
     char    name[MAX_LINE_LENGTH];
 
-    // Fake call to wait for audio HAL initialization completion
-    AudioSystem::getParameters(String8(""));
-
     for (;;) {
         const char* endl = strstr(config, "\n");
         if (!endl) break;
diff --git a/media/java/android/media/ImageReader.java b/media/java/android/media/ImageReader.java
index ea51d4c..ec2d4bc 100644
--- a/media/java/android/media/ImageReader.java
+++ b/media/java/android/media/ImageReader.java
@@ -520,31 +520,6 @@
         }
     }
 
-    /**
-     * Discard any free buffers owned by this ImageReader.
-     *
-     * <p>
-     * Generally, the ImageReader caches buffers for reuse once they have been
-     * allocated, for best performance. However, sometimes it may be important to
-     * release all the cached, unused buffers to save on memory.
-     * </p>
-     * <p>
-     * Calling this method will discard all free cached buffers. This does not include any buffers
-     * associated with Images acquired from the ImageReader, any filled buffers waiting to be
-     * acquired, and any buffers currently in use by the source rendering buffers into the
-     * ImageReader's Surface.
-     * <p>
-     * The ImageReader continues to be usable after this call, but may need to reallocate buffers
-     * when more buffers are needed for rendering.
-     * </p>
-     * @hide
-     */
-    public void discardFreeBuffers() {
-        synchronized (mCloseLock) {
-            nativeDiscardFreeBuffers();
-        }
-    }
-
     @Override
     protected void finalize() throws Throwable {
         try {
@@ -897,7 +872,6 @@
     private synchronized native void nativeReleaseImage(Image i);
     private synchronized native Surface nativeGetSurface();
     private synchronized native int nativeDetachImage(Image i);
-    private synchronized native void nativeDiscardFreeBuffers();
 
     /**
      * @return A return code {@code ACQUIRE_*}
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index 724fc02..c3993ae 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -611,23 +611,6 @@
     return OK;
 }
 
-static void ImageReader_discardFreeBuffers(JNIEnv* env, jobject thiz) {
-    ALOGV("%s:", __FUNCTION__);
-    JNIImageReaderContext* ctx = ImageReader_getContext(env, thiz);
-    if (ctx == NULL) {
-        jniThrowException(env, "java/lang/IllegalStateException", "ImageReader was already closed");
-        return;
-    }
-
-    BufferItemConsumer* bufferConsumer = ctx->getBufferConsumer();
-    status_t res = bufferConsumer->discardFreeBuffers();
-    if (res != OK) {
-        ALOGE("Buffer discard failed: %s (%d)", strerror(-res), res);
-        jniThrowRuntimeException(env,
-                "nativeDicardFreebuffers failed");
-    }
-}
-
 static jobject ImageReader_getSurface(JNIEnv* env, jobject thiz)
 {
     ALOGV("%s: ", __FUNCTION__);
@@ -790,7 +773,6 @@
     {"nativeImageSetup",       "(Landroid/media/Image;)I",   (void*)ImageReader_imageSetup },
     {"nativeGetSurface",       "()Landroid/view/Surface;",   (void*)ImageReader_getSurface },
     {"nativeDetachImage",      "(Landroid/media/Image;)I",   (void*)ImageReader_detachImage },
-    {"nativeDiscardFreeBuffers", "()V",                      (void*)ImageReader_discardFreeBuffers }
 };
 
 static const JNINativeMethod gImageMethods[] = {
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index 92f1b18..380fcd4 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -360,18 +360,17 @@
     }
 
     public String getSavedNetworkSummary() {
-        WifiConfiguration config = mConfig;
-        if (config != null) {
+        if (mConfig != null) {
             PackageManager pm = mContext.getPackageManager();
             String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
-            int userId = UserHandle.getUserId(config.creatorUid);
+            int userId = UserHandle.getUserId(mConfig.creatorUid);
             ApplicationInfo appInfo = null;
-            if (config.creatorName != null && config.creatorName.equals(systemName)) {
+            if (mConfig.creatorName != null && mConfig.creatorName.equals(systemName)) {
                 appInfo = mContext.getApplicationInfo();
             } else {
                 try {
                     IPackageManager ipm = AppGlobals.getPackageManager();
-                    appInfo = ipm.getApplicationInfo(config.creatorName, 0 /* flags */, userId);
+                    appInfo = ipm.getApplicationInfo(mConfig.creatorName, 0 /* flags */, userId);
                 } catch (RemoteException rex) {
                 }
             }
@@ -386,33 +385,29 @@
     }
 
     public String getSummary() {
-        return getSettingsSummary(mConfig);
+        return getSettingsSummary();
     }
 
     public String getSettingsSummary() {
-        return getSettingsSummary(mConfig);
-    }
-
-    private String getSettingsSummary(WifiConfiguration config) {
         // Update to new summary
         StringBuilder summary = new StringBuilder();
 
-        if (isActive() && config != null && config.isPasspoint()) {
+        if (isActive() && mConfig != null && mConfig.isPasspoint()) {
             // This is the active connection on passpoint
             summary.append(getSummary(mContext, getDetailedState(),
-                    false, config.providerFriendlyName));
+                    false, mConfig.providerFriendlyName));
         } else if (isActive()) {
             // This is the active connection on non-passpoint network
             summary.append(getSummary(mContext, getDetailedState(),
                     mInfo != null && mInfo.isEphemeral()));
-        } else if (config != null && config.isPasspoint()) {
+        } else if (mConfig != null && mConfig.isPasspoint()) {
             String format = mContext.getString(R.string.available_via_passpoint);
-            summary.append(String.format(format, config.providerFriendlyName));
-        } else if (config != null && config.hasNoInternetAccess()) {
+            summary.append(String.format(format, mConfig.providerFriendlyName));
+        } else if (mConfig != null && mConfig.hasNoInternetAccess()) {
             summary.append(mContext.getString(R.string.wifi_no_internet));
-        } else if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
+        } else if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
             WifiConfiguration.NetworkSelectionStatus networkStatus =
-                    config.getNetworkSelectionStatus();
+                    mConfig.getNetworkSelectionStatus();
             switch (networkStatus.getNetworkSelectionDisableReason()) {
                 case WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_FAILURE:
                     summary.append(mContext.getString(R.string.wifi_disabled_password_failure));
@@ -428,7 +423,7 @@
         } else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
             summary.append(mContext.getString(R.string.wifi_not_in_range));
         } else { // In range, not disabled.
-            if (config != null) { // Is saved network
+            if (mConfig != null) { // Is saved network
                 summary.append(mContext.getString(R.string.wifi_remembered));
             }
         }
@@ -440,11 +435,11 @@
                 summary.append(" f=" + Integer.toString(mInfo.getFrequency()));
             }
             summary.append(" " + getVisibilityStatus());
-            if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
-                summary.append(" (" + config.getNetworkSelectionStatus().getNetworkStatusString());
-                if (config.getNetworkSelectionStatus().getDisableTime() > 0) {
+            if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
+                summary.append(" (" + mConfig.getNetworkSelectionStatus().getNetworkStatusString());
+                if (mConfig.getNetworkSelectionStatus().getDisableTime() > 0) {
                     long now = System.currentTimeMillis();
-                    long diff = (now - config.getNetworkSelectionStatus().getDisableTime()) / 1000;
+                    long diff = (now - mConfig.getNetworkSelectionStatus().getDisableTime()) / 1000;
                     long sec = diff%60; //seconds
                     long min = (diff/60)%60; //minutes
                     long hour = (min/60)%60; //hours
@@ -456,9 +451,9 @@
                 summary.append(")");
             }
 
-            if (config != null) {
+            if (mConfig != null) {
                 WifiConfiguration.NetworkSelectionStatus networkStatus =
-                        config.getNetworkSelectionStatus();
+                        mConfig.getNetworkSelectionStatus();
                 for (int index = WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
                         index < WifiConfiguration.NetworkSelectionStatus
                         .NETWORK_SELECTION_DISABLED_MAX; index++) {
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index 64ca2e3..36ec2eb 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -150,7 +150,7 @@
     // used internally for synchronization
     private final Object mLock = new Object();
 
-    // --- fields below are final after systemRunning() ---
+    // --- fields below are final after systemReady() ---
     private LocationFudger mLocationFudger;
     private GeofenceManager mGeofenceManager;
     private PackageManager mPackageManager;
@@ -168,7 +168,6 @@
 
     // --- fields below are protected by mLock ---
     // Set of providers that are explicitly enabled
-    // Only used by passive, fused & test.  Network & GPS are controlled separately, and not listed.
     private final Set<String> mEnabledProviders = new HashSet<String>();
 
     // Set of providers that are explicitly disabled
@@ -237,12 +236,12 @@
 
         if (D) Log.d(TAG, "Constructed");
 
-        // most startup is deferred until systemRunning()
+        // most startup is deferred until systemReady()
     }
 
     public void systemRunning() {
         synchronized (mLock) {
-            if (D) Log.d(TAG, "systemRunning()");
+            if (D) Log.d(TAG, "systemReady()");
 
             // fetch package manager
             mPackageManager = mContext.getPackageManager();
@@ -322,11 +321,7 @@
                         || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) {
                     updateUserProfiles(mCurrentUserId);
                 } else if (Intent.ACTION_SHUTDOWN.equals(action)) {
-                    // shutdown only if UserId indicates whole system, not just one user
-                    if(D) Log.d(TAG, "Shutdown received with UserId: " + getSendingUserId());
-                    if (getSendingUserId() == UserHandle.USER_ALL) {
-                        shutdownComponents();
-                    }
+                    shutdownComponents();
                 }
             }
         }, UserHandle.ALL, intentFilter, null, mLocationHandler);