am f654d5b2: am 2954d35a: Merge "Revert "Annotate @SystemApi on some WifiManager methods."" into lmp-dev

* commit 'f654d5b210419e90ba674c73a20a3bcfa9f394e6':
  Revert "Annotate @SystemApi on some WifiManager methods."
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 60ef693..1f25c1e 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -2379,7 +2379,9 @@
             lp.itemId = mAdapter.getItemId(position);
         }
         lp.viewType = mAdapter.getItemViewType(position);
-        child.setLayoutParams(lp);
+        if (lp != vlp) {
+          child.setLayoutParams(lp);
+        }
     }
 
     class ListItemAccessibilityDelegate extends AccessibilityDelegate {
diff --git a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java
index 6ed3bdc..fc213c5 100644
--- a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java
+++ b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java
@@ -25,6 +25,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Bundle;
+import android.os.storage.StorageVolume;
 import android.util.Log;
 
 /**
@@ -94,6 +95,10 @@
         if (which == POSITIVE_BUTTON) {
             Intent intent = new Intent(ExternalStorageFormatter.FORMAT_ONLY);
             intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
+            // Transfer the storage volume to the new intent
+            final StorageVolume storageVolume = getIntent().getParcelableExtra(
+                    StorageVolume.EXTRA_STORAGE_VOLUME);
+            intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, storageVolume);
             startService(intent);
         }
 
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 051de6e..87e8ebd 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -91,12 +91,6 @@
     private static Resources mResources;
 
     /**
-     * The number of times that the main Zygote loop
-     * should run before calling gc() again.
-     */
-    static final int GC_LOOP_COUNT = 10;
-
-    /**
      * The name of a resource file that contains classes to preload.
      */
     private static final String PRELOADED_CLASSES = "preloaded-classes";
@@ -293,11 +287,6 @@
             float defaultUtilization = runtime.getTargetHeapUtilization();
             runtime.setTargetHeapUtilization(0.8f);
 
-            // Start with a clean slate.
-            System.gc();
-            runtime.runFinalizationSync();
-            Debug.startAllocCounting();
-
             try {
                 BufferedReader br
                     = new BufferedReader(new InputStreamReader(is), 256);
@@ -316,15 +305,6 @@
                             Log.v(TAG, "Preloading " + line + "...");
                         }
                         Class.forName(line);
-                        if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) {
-                            if (false) {
-                                Log.v(TAG,
-                                    " GC at " + Debug.getGlobalAllocSize());
-                            }
-                            System.gc();
-                            runtime.runFinalizationSync();
-                            Debug.resetGlobalAllocSize();
-                        }
                         count++;
                     } catch (ClassNotFoundException e) {
                         Log.w(TAG, "Class not found for preloading: " + line);
@@ -354,8 +334,6 @@
                 // Fill in dex caches with classes, fields, and methods brought in by preloading.
                 runtime.preloadDexCaches();
 
-                Debug.stopAllocCounting();
-
                 // Bring back root. We'll need it later.
                 setEffectiveUser(ROOT_UID);
                 setEffectiveGroup(ROOT_GID);
@@ -373,10 +351,7 @@
     private static void preloadResources() {
         final VMRuntime runtime = VMRuntime.getRuntime();
 
-        Debug.startAllocCounting();
         try {
-            System.gc();
-            runtime.runFinalizationSync();
             mResources = Resources.getSystem();
             mResources.startPreloading();
             if (PRELOAD_RESOURCES) {
@@ -401,22 +376,12 @@
             mResources.finishPreloading();
         } catch (RuntimeException e) {
             Log.w(TAG, "Failure preloading resources", e);
-        } finally {
-            Debug.stopAllocCounting();
         }
     }
 
     private static int preloadColorStateLists(VMRuntime runtime, TypedArray ar) {
         int N = ar.length();
         for (int i=0; i<N; i++) {
-            if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) {
-                if (false) {
-                    Log.v(TAG, " GC at " + Debug.getGlobalAllocSize());
-                }
-                System.gc();
-                runtime.runFinalizationSync();
-                Debug.resetGlobalAllocSize();
-            }
             int id = ar.getResourceId(i, 0);
             if (false) {
                 Log.v(TAG, "Preloading resource #" + Integer.toHexString(id));
@@ -437,14 +402,6 @@
     private static int preloadDrawables(VMRuntime runtime, TypedArray ar) {
         int N = ar.length();
         for (int i=0; i<N; i++) {
-            if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) {
-                if (false) {
-                    Log.v(TAG, " GC at " + Debug.getGlobalAllocSize());
-                }
-                System.gc();
-                runtime.runFinalizationSync();
-                Debug.resetGlobalAllocSize();
-            }
             int id = ar.getResourceId(i, 0);
             if (false) {
                 Log.v(TAG, "Preloading resource #" + Integer.toHexString(id));
@@ -466,7 +423,7 @@
      * softly- and final-reachable objects, along with any other garbage.
      * This is only useful just before a fork().
      */
-    /*package*/ static void gc() {
+    /*package*/ static void gcAndFinalize() {
         final VMRuntime runtime = VMRuntime.getRuntime();
 
         /* runFinalizationSync() lets finalizers be called in Zygote,
@@ -475,9 +432,6 @@
         System.gc();
         runtime.runFinalizationSync();
         System.gc();
-        runtime.runFinalizationSync();
-        System.gc();
-        runtime.runFinalizationSync();
     }
 
     /**
@@ -668,7 +622,7 @@
             SamplingProfilerIntegration.writeZygoteSnapshot();
 
             // Do an initial gc to clean up after startup
-            gc();
+            gcAndFinalize();
 
             // Disable tracing so that forked processes do not inherit stale tracing tags from
             // Zygote.
@@ -737,27 +691,9 @@
         fds.add(sServerSocket.getFileDescriptor());
         peers.add(null);
 
-        int loopCount = GC_LOOP_COUNT;
         while (true) {
             int index;
 
-            /*
-             * Call gc() before we block in select().
-             * It's work that has to be done anyway, and it's better
-             * to avoid making every child do it.  It will also
-             * madvise() any free memory as a side-effect.
-             *
-             * Don't call it every time, because walking the entire
-             * heap is a lot of overhead to free a few hundred bytes.
-             */
-            if (loopCount <= 0) {
-                gc();
-                loopCount = GC_LOOP_COUNT;
-            } else {
-                loopCount--;
-            }
-
-
             try {
                 fdArray = fds.toArray(fdArray);
                 index = selectReadable(fdArray);
diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp
index 98f4bed..a408a96 100644
--- a/core/jni/android_net_LocalSocketImpl.cpp
+++ b/core/jni/android_net_LocalSocketImpl.cpp
@@ -57,7 +57,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -95,7 +95,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -118,7 +118,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -154,7 +154,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return NULL;
     }
 
@@ -184,7 +184,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -246,7 +246,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return 0;
     }
 
@@ -293,7 +293,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -353,7 +353,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return (jint)-1;
     }
 
@@ -378,7 +378,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return (jint)-1;
     }
 
@@ -459,20 +459,20 @@
                 jobject fdObject
                         = jniCreateFileDescriptor(env, pDescriptors[i]);
 
-                if (env->ExceptionOccurred() != NULL) {
+                if (env->ExceptionCheck()) {
                     return -1;
                 }
 
                 env->SetObjectArrayElement(fdArray, i, fdObject);
 
-                if (env->ExceptionOccurred() != NULL) {
+                if (env->ExceptionCheck()) {
                     return -1;
                 }
             }
 
             env->SetObjectField(thisJ, field_inboundFileDescriptors, fdArray);
 
-            if (env->ExceptionOccurred() != NULL) {
+            if (env->ExceptionCheck()) {
                 return -1;
             }
         }
@@ -558,7 +558,7 @@
             = (jobjectArray)env->GetObjectField(
                 object, field_outboundFileDescriptors);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return -1;
     }
 
@@ -570,18 +570,18 @@
     // Add any pending outbound file descriptors to the message
     if (outboundFds != NULL) {
 
-        if (env->ExceptionOccurred() != NULL) {
+        if (env->ExceptionCheck()) {
             return -1;
         }
 
         for (int i = 0; i < countFds; i++) {
             jobject fdObject = env->GetObjectArrayElement(outboundFds, i);
-            if (env->ExceptionOccurred() != NULL) {
+            if (env->ExceptionCheck()) {
                 return -1;
             }
 
             fds[i] = jniGetFDFromFileDescriptor(env, fdObject);
-            if (env->ExceptionOccurred() != NULL) {
+            if (env->ExceptionCheck()) {
                 return -1;
             }
         }
@@ -638,7 +638,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return (jint)0;
     }
 
@@ -683,7 +683,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return (jint)-1;
     }
 
@@ -717,7 +717,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -745,7 +745,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return;
     }
 
@@ -777,7 +777,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return NULL;
     }
 
@@ -816,7 +816,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return NULL;
     }
 
diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp
index a8ed895..15d62a2 100644
--- a/core/jni/android_os_MessageQueue.cpp
+++ b/core/jni/android_os_MessageQueue.cpp
@@ -54,8 +54,8 @@
 }
 
 bool MessageQueue::raiseAndClearException(JNIEnv* env, const char* msg) {
-    jthrowable exceptionObj = env->ExceptionOccurred();
-    if (exceptionObj) {
+    if (env->ExceptionCheck()) {
+        jthrowable exceptionObj = env->ExceptionOccurred();
         env->ExceptionClear();
         raiseException(env, msg, exceptionObj);
         env->DeleteLocalRef(exceptionObj);
diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp
index ffa569e..c282549 100644
--- a/core/jni/android_os_SELinux.cpp
+++ b/core/jni/android_os_SELinux.cpp
@@ -97,7 +97,7 @@
     }
 
     int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         ALOGE("getPeerCon => getFD for %p failed", fileDescriptor);
         return NULL;
     }
diff --git a/core/jni/android_server_NetworkManagementSocketTagger.cpp b/core/jni/android_server_NetworkManagementSocketTagger.cpp
index 7e12b1e..ca21fd7 100644
--- a/core/jni/android_server_NetworkManagementSocketTagger.cpp
+++ b/core/jni/android_server_NetworkManagementSocketTagger.cpp
@@ -35,7 +35,7 @@
                                 jint tagNum, jint uid) {
   int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-  if (env->ExceptionOccurred() != NULL) {
+  if (env->ExceptionCheck()) {
     ALOGE("Can't get FileDescriptor num");
     return (jint)-1;
   }
@@ -51,7 +51,7 @@
                                   jobject fileDescriptor) {
   int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
-  if (env->ExceptionOccurred() != NULL) {
+  if (env->ExceptionCheck()) {
     ALOGE("Can't get FileDescriptor num");
     return (jint)-1;
   }
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 81e887d..7f7cfce 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -272,9 +272,9 @@
         //printf("\n");
         jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
             code, reinterpret_cast<jlong>(&data), reinterpret_cast<jlong>(reply), flags);
-        jthrowable excep = env->ExceptionOccurred();
 
-        if (excep) {
+        if (env->ExceptionCheck()) {
+            jthrowable excep = env->ExceptionOccurred();
             report_exception(env, excep,
                 "*** Uncaught remote exception!  "
                 "(Exceptions are not yet supported across processes.)");
@@ -296,12 +296,12 @@
             set_dalvik_blockguard_policy(env, strict_policy_before);
         }
 
-        jthrowable excep2 = env->ExceptionOccurred();
-        if (excep2) {
-            report_exception(env, excep2,
+        if (env->ExceptionCheck()) {
+            jthrowable excep = env->ExceptionOccurred();
+            report_exception(env, excep,
                 "*** Uncaught exception in onBinderStrictModePolicyChange");
             /* clean up JNI local ref -- we don't return to Java code */
-            env->DeleteLocalRef(excep2);
+            env->DeleteLocalRef(excep);
         }
 
         // Need to always call through the native implementation of
@@ -403,8 +403,8 @@
 
             env->CallStaticVoidMethod(gBinderProxyOffsets.mClass,
                     gBinderProxyOffsets.mSendDeathNotice, mObject);
-            jthrowable excep = env->ExceptionOccurred();
-            if (excep) {
+            if (env->ExceptionCheck()) {
+                jthrowable excep = env->ExceptionOccurred();
                 report_exception(env, excep,
                         "*** Uncaught exception returned from death notification!");
             }
@@ -1068,16 +1068,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 aaa680f..6506190 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -271,7 +271,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) {
@@ -306,7 +306,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!");
@@ -333,7 +333,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/core/jni/com_android_internal_os_ZygoteInit.cpp b/core/jni/com_android_internal_os_ZygoteInit.cpp
index 2233ee3..10c6e2ce 100644
--- a/core/jni/com_android_internal_os_ZygoteInit.cpp
+++ b/core/jni/com_android_internal_os_ZygoteInit.cpp
@@ -96,7 +96,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, in);
 
-    if  (env->ExceptionOccurred() != NULL) {
+    if  (env->ExceptionCheck()) {
         return;
     }
 
@@ -106,7 +106,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, out);
 
-    if  (env->ExceptionOccurred() != NULL) {
+    if  (env->ExceptionCheck()) {
         return;
     }
 
@@ -116,7 +116,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, errfd);
 
-    if  (env->ExceptionOccurred() != NULL) {
+    if  (env->ExceptionCheck()) {
         return;
     }
 
@@ -134,7 +134,7 @@
 
     fd = jniGetFDFromFileDescriptor(env, descriptor);
 
-    if  (env->ExceptionOccurred() != NULL) {
+    if  (env->ExceptionCheck()) {
         return;
     }
 
@@ -170,7 +170,7 @@
     jsize length = env->GetArrayLength(fds);
     fd_set fdset;
 
-    if (env->ExceptionOccurred() != NULL) {
+    if (env->ExceptionCheck()) {
         return -1;
     }
 
@@ -179,14 +179,14 @@
     int nfds = 0;
     for (jsize i = 0; i < length; i++) {
         jobject fdObj = env->GetObjectArrayElement(fds, i);
-        if  (env->ExceptionOccurred() != NULL) {
+        if  (env->ExceptionCheck()) {
             return -1;
         }
         if (fdObj == NULL) {
             continue;
         }
         int fd = jniGetFDFromFileDescriptor(env, fdObj);
-        if  (env->ExceptionOccurred() != NULL) {
+        if  (env->ExceptionCheck()) {
             return -1;
         }
 
@@ -209,14 +209,14 @@
 
     for (jsize i = 0; i < length; i++) {
         jobject fdObj = env->GetObjectArrayElement(fds, i);
-        if  (env->ExceptionOccurred() != NULL) {
+        if  (env->ExceptionCheck()) {
             return -1;
         }
         if (fdObj == NULL) {
             continue;
         }
         int fd = jniGetFDFromFileDescriptor(env, fdObj);
-        if  (env->ExceptionOccurred() != NULL) {
+        if  (env->ExceptionCheck()) {
             return -1;
         }
         if (FD_ISSET(fd, &fdset)) {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index cf9a415..6dc9156 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -502,10 +502,10 @@
     <integer name="config_shortPressOnPowerBehavior">1</integer>
 
     <!-- Package name for default keyguard appwidget [DO NOT TRANSLATE] -->
-    <string name="widget_default_package_name"></string>
+    <string name="widget_default_package_name" translatable="false"></string>
 
     <!-- Class name for default keyguard appwidget [DO NOT TRANSLATE] -->
-    <string name="widget_default_class_name"></string>
+    <string name="widget_default_class_name" translatable="false"></string>
 
     <!-- Indicate whether the SD card is accessible without removing the battery. -->
     <bool name="config_batterySdCardAccessibility">false</bool>
@@ -994,7 +994,7 @@
          PERSIST may improve performance by reducing how often journal blocks are
          reallocated (compared to truncation) resulting in better data block locality
          and less churn of the storage media. -->
-    <string name="db_default_journal_mode">PERSIST</string>
+    <string name="db_default_journal_mode" translatable="false">PERSIST</string>
 
     <!-- Maximum size of the persistent journal file in bytes.
          If the journal file grows to be larger than this amount then SQLite will
@@ -1006,7 +1006,7 @@
          NORMAL also preserves durability in non-WAL modes and uses checksums to ensure
          integrity although there is a small chance that an error might go unnoticed.
          Choices are: FULL, NORMAL, OFF. -->
-    <string name="db_default_sync_mode">FULL</string>
+    <string name="db_default_sync_mode" translatable="false">FULL</string>
 
     <!-- The database synchronization mode when using Write-Ahead Logging.
          FULL is safest and preserves durability at the cost of extra fsyncs.
@@ -1014,7 +1014,7 @@
          and after checkpoint operations.  If checkpoints are infrequent and power loss
          occurs, then committed transactions could be lost and applications might break.
          Choices are: FULL, NORMAL, OFF. -->
-    <string name="db_wal_sync_mode">FULL</string>
+    <string name="db_wal_sync_mode" translatable="false">FULL</string>
 
     <!-- The Write-Ahead Log auto-checkpoint interval in database pages (typically 1 to 4KB).
          The log is checkpointed automatically whenever it exceeds this many pages.
@@ -1199,7 +1199,7 @@
     <!-- If supported and enabled, are dreams activated when asleep and charging? (by default) -->
     <bool name="config_dreamsActivatedOnSleepByDefault">false</bool>
     <!-- ComponentName of the default dream (Settings.Secure.DEFAULT_SCREENSAVER_COMPONENT) -->
-    <string name="config_dreamsDefaultComponent">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
+    <string name="config_dreamsDefaultComponent" translatable="false">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
 
     <!-- Are we allowed to dream while not plugged in? -->
     <bool name="config_dreamsEnabledOnBattery">false</bool>
@@ -1464,17 +1464,17 @@
 
     <!-- Class name of the framework account picker activity.
          Can be customized for other product types -->
-    <string name="config_chooseAccountActivity"
+    <string name="config_chooseAccountActivity" translatable="false"
             >android/android.accounts.ChooseAccountActivity</string>
     <!-- Class name of the account type and account picker activity.
          Can be customized for other product types -->
-    <string name="config_chooseTypeAndAccountActivity"
+    <string name="config_chooseTypeAndAccountActivity" translatable="false"
             >android/android.accounts.ChooseTypeAndAccountActivity</string>
 
     <!-- Component name of a custom ResolverActivity (Intent resolver) to be used instead of
          the default framework version. If left empty, then the framework version will be used.
          Example: com.google.android.myapp/.resolver.MyResolverActivity  -->
-    <string name="config_customResolverActivity"></string>
+    <string name="config_customResolverActivity" translatable="false"></string>
 
     <!-- Name of the activity or service that prompts the user to reject, accept, or whitelist
          an adb host's public key, when an unwhitelisted host connects to the local adbd.
@@ -1487,7 +1487,7 @@
             >com.android.vpndialogs/com.android.vpndialogs.ConfirmDialog</string>
 
     <!-- Apps that are authorized to access shared accounts, overridden by product overlays -->
-    <string name="config_appsAuthorizedForSharedAccounts">;com.android.settings;</string>
+    <string name="config_appsAuthorizedForSharedAccounts" translatable="false">;com.android.settings;</string>
 
     <!-- Flag indicating that the media framework should not allow changes or mute on any
          stream or master volumes. -->
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp
index 1ab18ad..5f6e831 100644
--- a/libs/androidfw/ZipFileRO.cpp
+++ b/libs/androidfw/ZipFileRO.cpp
@@ -50,7 +50,10 @@
     ZipEntryName name;
     void *cookie;
 
-    _ZipEntryRO() : cookie(NULL) {
+    _ZipEntryRO() : cookie(NULL) {}
+
+    ~_ZipEntryRO() {
+      EndIteration(cookie);
     }
 
 private:
@@ -83,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/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index dce5c37..f804736 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -28,6 +28,7 @@
 import android.os.UserHandle;
 import android.os.storage.StorageEventListener;
 import android.os.storage.StorageManager;
+import android.os.storage.StorageVolume;
 import android.provider.Settings;
 import android.util.Log;
 
@@ -198,6 +199,8 @@
              */
             Intent intent = new Intent();
             intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class);
+            intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME,
+                    getVolumeByPath(mStorageManager.getVolumeList(), path));
             PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
 
             setMediaStorageNotification(
@@ -212,6 +215,8 @@
              */
             Intent intent = new Intent();
             intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class);
+            intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME,
+                    getVolumeByPath(mStorageManager.getVolumeList(), path));
             PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
 
             setMediaStorageNotification(
@@ -247,6 +252,19 @@
     }
 
     /**
+     * Get the corresponding StorageVolume object for a specific path.
+     */
+    private final StorageVolume getVolumeByPath(StorageVolume[] volumes, String path) {
+        for (StorageVolume volume : volumes) {
+            if (volume.getPath().equals(path)) {
+                return volume;
+            }
+        }
+        Log.w(TAG, "No storage found");
+        return null;
+    }
+
+    /**
      * Update the state of the USB mass storage notification
      */
     void updateUsbMassStorageNotification(boolean available) {
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 6c5c508..2ee4ff2 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -605,52 +605,14 @@
         validate();
         rsnScriptInvoke(mContext, id, slot);
     }
-    native void rsnScriptForEach(long con, long id, int slot, long ain, long aout, byte[] params);
-    native void rsnScriptForEach(long con, long id, int slot, long ain, long aout);
-    native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, byte[] params,
-                                        int xstart, int xend, int ystart, int yend, int zstart, int zend);
-    native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout,
-                                        int xstart, int xend, int ystart, int yend, int zstart, int zend);
-    synchronized void nScriptForEach(long id, int slot, long ain, long aout, byte[] params) {
+
+    native void rsnScriptForEach(long con, long id, int slot, long[] ains,
+                                 long aout, byte[] params, int[] limits);
+
+    synchronized void nScriptForEach(long id, int slot, long[] ains, long aout,
+                                     byte[] params, int[] limits) {
         validate();
-        if (params == null) {
-            rsnScriptForEach(mContext, id, slot, ain, aout);
-        } else {
-            rsnScriptForEach(mContext, id, slot, ain, aout, params);
-        }
-    }
-
-    synchronized void nScriptForEachClipped(long id, int slot, long ain, long aout, byte[] params,
-                                            int xstart, int xend, int ystart, int yend, int zstart, int zend) {
-        validate();
-        if (params == null) {
-            rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend);
-        } else {
-            rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend);
-        }
-    }
-
-    /**
-     * Multi-input code.
-     *
-     */
-
-    // @hide
-    native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout, byte[] params,
-                                             int xstart, int xend, int ystart, int yend, int zstart, int zend);
-    // @hide
-    native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout,
-                                             int xstart, int xend, int ystart, int yend, int zstart, int zend);
-
-    // @hide
-    synchronized void nScriptForEachMultiClipped(long id, int slot, long[] ains, long aout, byte[] params,
-                                                 int xstart, int xend, int ystart, int yend, int zstart, int zend) {
-        validate();
-        if (params == null) {
-            rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, xstart, xend, ystart, yend, zstart, zend);
-        } else {
-            rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, params, xstart, xend, ystart, yend, zstart, zend);
-        }
+        rsnScriptForEach(mContext, id, slot, ains, aout, params, limits);
     }
 
     native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index c49ef94..eb1687a 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -48,7 +48,8 @@
     /**
      * Only to be used by generated reflected classes.
      */
-    protected KernelID createKernelID(int slot, int sig, Element ein, Element eout) {
+    protected KernelID createKernelID(int slot, int sig, Element ein,
+                                      Element eout) {
         KernelID k = mKIDs.get(slot);
         if (k != null) {
             return k;
@@ -127,59 +128,56 @@
      * Only intended for use by generated reflected code.
      *
      */
-    protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
-        mRS.validate();
-        mRS.validateObject(ain);
-        mRS.validateObject(aout);
-        if (ain == null && aout == null) {
-            throw new RSIllegalArgumentException(
-                "At least one of ain or aout is required to be non-null.");
-        }
-        long in_id = 0;
-        if (ain != null) {
-            in_id = ain.getID(mRS);
-        }
-        long out_id = 0;
-        if (aout != null) {
-            out_id = aout.getID(mRS);
-        }
-        byte[] params = null;
-        if (v != null) {
-            params = v.getData();
-        }
-        mRS.nScriptForEach(getID(mRS), slot, in_id, out_id, params);
+    protected void forEach(int slot, Allocation ain, Allocation aout,
+                           FieldPacker v) {
+        forEach(slot, ain, aout, v, null);
     }
 
     /**
      * Only intended for use by generated reflected code.
      *
      */
-    protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
+    protected void forEach(int slot, Allocation ain, Allocation aout,
+                           FieldPacker v, LaunchOptions sc) {
+        // TODO: Is this necessary if nScriptForEach calls validate as well?
         mRS.validate();
         mRS.validateObject(ain);
         mRS.validateObject(aout);
+
         if (ain == null && aout == null) {
             throw new RSIllegalArgumentException(
                 "At least one of ain or aout is required to be non-null.");
         }
 
-        if (sc == null) {
-            forEach(slot, ain, aout, v);
-            return;
-        }
-        long in_id = 0;
+        long[] in_ids = null;
         if (ain != null) {
-            in_id = ain.getID(mRS);
+            in_ids    = mInIdsBuffer;
+            in_ids[0] = ain.getID(mRS);
         }
+
         long out_id = 0;
         if (aout != null) {
             out_id = aout.getID(mRS);
         }
+
         byte[] params = null;
         if (v != null) {
             params = v.getData();
         }
-        mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend);
+
+        int[] limits = null;
+        if (sc != null) {
+            limits = new int[6];
+
+            limits[0] = sc.xstart;
+            limits[1] = sc.xend;
+            limits[2] = sc.ystart;
+            limits[3] = sc.yend;
+            limits[4] = sc.zstart;
+            limits[5] = sc.zend;
+        }
+
+        mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
     }
 
     /**
@@ -187,8 +185,9 @@
      *
      * @hide
      */
-    protected void forEach(int slot, Allocation[] ains, Allocation aout, FieldPacker v) {
-        forEach(slot, ains, aout, v, new LaunchOptions());
+    protected void forEach(int slot, Allocation[] ains, Allocation aout,
+                           FieldPacker v) {
+        forEach(slot, ains, aout, v, null);
     }
 
     /**
@@ -196,24 +195,20 @@
      *
      * @hide
      */
-    protected void forEach(int slot, Allocation[] ains, Allocation aout, FieldPacker v, LaunchOptions sc) {
+    protected void forEach(int slot, Allocation[] ains, Allocation aout,
+                           FieldPacker v, LaunchOptions sc) {
+        // TODO: Is this necessary if nScriptForEach calls validate as well?
         mRS.validate();
-
         for (Allocation ain : ains) {
           mRS.validateObject(ain);
         }
-
         mRS.validateObject(aout);
+
         if (ains == null && aout == null) {
             throw new RSIllegalArgumentException(
                 "At least one of ain or aout is required to be non-null.");
         }
 
-        if (sc == null) {
-            forEach(slot, ains, aout, v);
-            return;
-        }
-
         long[] in_ids = new long[ains.length];
         for (int index = 0; index < ains.length; ++index) {
             in_ids[index] = ains[index].getID(mRS);
@@ -223,15 +218,33 @@
         if (aout != null) {
             out_id = aout.getID(mRS);
         }
+
         byte[] params = null;
         if (v != null) {
             params = v.getData();
         }
-        mRS.nScriptForEachMultiClipped(getID(mRS), slot, in_ids, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend);
+
+        int[] limits = null;
+        if (sc != null) {
+            limits = new int[6];
+
+            limits[0] = sc.xstart;
+            limits[1] = sc.xend;
+            limits[2] = sc.ystart;
+            limits[3] = sc.yend;
+            limits[4] = sc.zstart;
+            limits[5] = sc.zend;
+        }
+
+        mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
     }
 
+    long[] mInIdsBuffer;
+
     Script(long id, RenderScript rs) {
         super(id, rs);
+
+        mInIdsBuffer = new long[1];
     }
 
 
@@ -243,11 +256,17 @@
         mRS.validate();
         mRS.validateObject(va);
         if (va != null) {
-            if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 20) {
+
+            android.content.Context context = mRS.getApplicationContext();
+
+            if (context.getApplicationInfo().targetSdkVersion >= 20) {
                 final Type t = va.mType;
-                if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) || (t.getZ() != 0)) {
+                if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) ||
+                    (t.getZ() != 0)) {
+
                     throw new RSIllegalArgumentException(
-                        "API 20+ only allows simple 1D allocations to be used with bind.");
+                        "API 20+ only allows simple 1D allocations to be " +
+                        "used with bind.");
                 }
             }
             mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
@@ -378,11 +397,14 @@
         protected Allocation mAllocation;
 
         protected void init(RenderScript rs, int dimx) {
-            mAllocation = Allocation.createSized(rs, mElement, dimx, Allocation.USAGE_SCRIPT);
+            mAllocation = Allocation.createSized(rs, mElement, dimx,
+                                                 Allocation.USAGE_SCRIPT);
         }
 
         protected void init(RenderScript rs, int dimx, int usages) {
-            mAllocation = Allocation.createSized(rs, mElement, dimx, Allocation.USAGE_SCRIPT | usages);
+            mAllocation =
+                Allocation.createSized(rs, mElement, dimx,
+                                       Allocation.USAGE_SCRIPT | usages);
         }
 
         protected FieldBase() {
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index 13a649a..eb2a438 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -1091,159 +1091,82 @@
 }
 
 static void
-nScriptForEach(JNIEnv *_env, jobject _this, jlong con,
-               jlong script, jint slot, jlong ain, jlong aout)
+nScriptForEach(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot,
+               jlongArray ains, jlong aout, jbyteArray params,
+               jintArray limits)
 {
-    LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
-    rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, NULL, 0);
-}
-static void
-nScriptForEachV(JNIEnv *_env, jobject _this, jlong con,
-                jlong script, jint slot, jlong ain, jlong aout, jbyteArray params)
-{
-    LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
-    jint len = _env->GetArrayLength(params);
-    jbyte *ptr = _env->GetByteArrayElements(params, NULL);
-    rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, NULL, 0);
-    _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
-}
+    LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con,
+            (void *)script, slot);
 
-static void
-nScriptForEachClipped(JNIEnv *_env, jobject _this, jlong con,
-                      jlong script, jint slot, jlong ain, jlong aout,
-                      jint xstart, jint xend,
-                      jint ystart, jint yend, jint zstart, jint zend)
-{
-    LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
-    RsScriptCall sc;
-    sc.xStart = xstart;
-    sc.xEnd = xend;
-    sc.yStart = ystart;
-    sc.yEnd = yend;
-    sc.zStart = zstart;
-    sc.zEnd = zend;
-    sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
-    sc.arrayStart = 0;
-    sc.arrayEnd = 0;
-    rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
-}
-
-static void
-nScriptForEachClippedV(JNIEnv *_env, jobject _this, jlong con,
-                       jlong script, jint slot, jlong ain, jlong aout,
-                       jbyteArray params, jint xstart, jint xend,
-                       jint ystart, jint yend, jint zstart, jint zend)
-{
-    LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
-    jint len = _env->GetArrayLength(params);
-    jbyte *ptr = _env->GetByteArrayElements(params, NULL);
-    RsScriptCall sc;
-    sc.xStart = xstart;
-    sc.xEnd = xend;
-    sc.yStart = ystart;
-    sc.yEnd = yend;
-    sc.zStart = zstart;
-    sc.zEnd = zend;
-    sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
-    sc.arrayStart = 0;
-    sc.arrayEnd = 0;
-    rsScriptForEach((RsContext)con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, &sc, sizeof(sc));
-    _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
-}
-
-static void
-nScriptForEachMultiClipped(JNIEnv *_env, jobject _this, jlong con,
-                      jlong script, jint slot, jlongArray ains, jlong aout,
-                      jint xstart, jint xend,
-                      jint ystart, jint yend, jint zstart, jint zend)
-{
-    LOG_API("nScriptForEachMultiClipped, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
-
-    jint   in_len = _env->GetArrayLength(ains);
-    jlong* in_ptr = _env->GetLongArrayElements(ains, NULL);
+    jint   in_len = 0;
+    jlong *in_ptr = NULL;
 
     RsAllocation *in_allocs = NULL;
 
-    if (sizeof(RsAllocation) == sizeof(jlong)) {
-      in_allocs = (RsAllocation*)in_ptr;
+    if (ains != NULL) {
+        in_len = _env->GetArrayLength(ains);
+        in_ptr = _env->GetLongArrayElements(ains, NULL);
 
-    } else {
-      // Convert from 64-bit jlong types to the native pointer type.
+        if (sizeof(RsAllocation) == sizeof(jlong)) {
+            in_allocs = (RsAllocation*)in_ptr;
 
-      in_allocs = new RsAllocation[in_len];
+        } else {
+            // Convert from 64-bit jlong types to the native pointer type.
 
-      for (int index = in_len; --index >= 0;) {
-        in_allocs[index] = (RsAllocation)in_ptr[index];
-      }
+            in_allocs = (RsAllocation*)alloca(in_len * sizeof(RsAllocation));
+
+            for (int index = in_len; --index >= 0;) {
+                in_allocs[index] = (RsAllocation)in_ptr[index];
+            }
+        }
     }
 
-    RsScriptCall sc;
-    sc.xStart = xstart;
-    sc.xEnd = xend;
-    sc.yStart = ystart;
-    sc.yEnd = yend;
-    sc.zStart = zstart;
-    sc.zEnd = zend;
-    sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
-    sc.arrayStart = 0;
-    sc.arrayEnd = 0;
+    jint   param_len = 0;
+    jbyte *param_ptr = NULL;
 
-    rsScriptForEachMulti((RsContext)con, (RsScript)script, slot, in_allocs, in_len, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
-
-    if (sizeof(RsAllocation) != sizeof(jlong)) {
-      delete[] in_allocs;
+    if (params != NULL) {
+        param_len = _env->GetArrayLength(params);
+        param_ptr = _env->GetByteArrayElements(params, NULL);
     }
 
-    _env->ReleaseLongArrayElements(ains, in_ptr, JNI_ABORT);
-}
+    RsScriptCall sc, *sca = NULL;
+    uint32_t sc_size = 0;
 
-static void
-nScriptForEachMultiClippedV(JNIEnv *_env, jobject _this, jlong con,
-                       jlong script, jint slot, jlongArray ains, jlong aout,
-                       jbyteArray params, jint xstart, jint xend,
-                       jint ystart, jint yend, jint zstart, jint zend)
-{
-    LOG_API("nScriptForEachMultiClippedV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
+    jint  limit_len = 0;
+    jint *limit_ptr = NULL;
 
-    jint   in_len = _env->GetArrayLength(ains);
-    jlong* in_ptr = _env->GetLongArrayElements(ains, NULL);
+    if (limits != NULL) {
+        limit_len = _env->GetArrayLength(limits);
+        limit_ptr = _env->GetIntArrayElements(limits, NULL);
 
-    RsAllocation *in_allocs = NULL;
+        assert(limit_len == 6);
 
-    if (sizeof(RsAllocation) == sizeof(jlong)) {
-      in_allocs = (RsAllocation*)in_ptr;
+        sc.xStart     = limit_ptr[0];
+        sc.xEnd       = limit_ptr[1];
+        sc.yStart     = limit_ptr[2];
+        sc.yEnd       = limit_ptr[3];
+        sc.zStart     = limit_ptr[4];
+        sc.zEnd       = limit_ptr[5];
+        sc.strategy   = RS_FOR_EACH_STRATEGY_DONT_CARE;
 
-    } else {
-      // Convert from 64-bit jlong types to the native pointer type.
-
-      in_allocs = new RsAllocation[in_len];
-
-      for (int index = in_len; --index >= 0;) {
-        in_allocs[index] = (RsAllocation)in_ptr[index];
-      }
+        sca = &sc;
     }
 
-    jint   param_len = _env->GetArrayLength(params);
-    jbyte* param_ptr = _env->GetByteArrayElements(params, NULL);
+    rsScriptForEachMulti((RsContext)con, (RsScript)script, slot,
+                         in_allocs, in_len, (RsAllocation)aout,
+                         param_ptr, param_len, sca, sc_size);
 
-    RsScriptCall sc;
-    sc.xStart = xstart;
-    sc.xEnd = xend;
-    sc.yStart = ystart;
-    sc.yEnd = yend;
-    sc.zStart = zstart;
-    sc.zEnd = zend;
-    sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
-    sc.arrayStart = 0;
-    sc.arrayEnd = 0;
-    rsScriptForEachMulti((RsContext)con, (RsScript)script, slot, in_allocs, in_len, (RsAllocation)aout, param_ptr, param_len, &sc, sizeof(sc));
-
-    if (sizeof(RsAllocation) != sizeof(jlong)) {
-      delete[] in_allocs;
+    if (ains != NULL) {
+        _env->ReleaseLongArrayElements(ains, in_ptr, JNI_ABORT);
     }
 
-    _env->ReleaseLongArrayElements(ains, in_ptr, JNI_ABORT);
-    _env->ReleaseByteArrayElements(params, param_ptr, JNI_ABORT);
+    if (params != NULL) {
+        _env->ReleaseByteArrayElements(params, param_ptr, JNI_ABORT);
+    }
+
+    if (limits != NULL) {
+        _env->ReleaseIntArrayElements(limits, limit_ptr, JNI_ABORT);
+    }
 }
 
 // -----------------------------------
@@ -1757,12 +1680,9 @@
 {"rsnScriptSetTimeZone",             "(JJ[B)V",                               (void*)nScriptSetTimeZone },
 {"rsnScriptInvoke",                  "(JJI)V",                                (void*)nScriptInvoke },
 {"rsnScriptInvokeV",                 "(JJI[B)V",                              (void*)nScriptInvokeV },
-{"rsnScriptForEach",                 "(JJIJJ)V",                              (void*)nScriptForEach },
-{"rsnScriptForEach",                 "(JJIJJ[B)V",                            (void*)nScriptForEachV },
-{"rsnScriptForEachClipped",          "(JJIJJIIIIII)V",                        (void*)nScriptForEachClipped },
-{"rsnScriptForEachClipped",          "(JJIJJ[BIIIIII)V",                      (void*)nScriptForEachClippedV },
-{"rsnScriptForEachMultiClipped",     "(JJI[JJIIIIII)V",                       (void*)nScriptForEachMultiClipped },
-{"rsnScriptForEachMultiClipped",     "(JJI[JJ[BIIIIII)V",                     (void*)nScriptForEachMultiClippedV },
+
+{"rsnScriptForEach",                 "(JJI[JJ[B[I)V",                         (void*)nScriptForEach },
+
 {"rsnScriptSetVarI",                 "(JJII)V",                               (void*)nScriptSetVarI },
 {"rsnScriptGetVarI",                 "(JJI)I",                                (void*)nScriptGetVarI },
 {"rsnScriptSetVarJ",                 "(JJIJ)V",                               (void*)nScriptSetVarJ },
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
old mode 100755
new mode 100644
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.
 
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java b/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
index d65d03e..92c7e36 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
@@ -77,6 +77,7 @@
 
     public boolean setDeviceType(int deviceType) {
         if (deviceType >= WFD_SOURCE && deviceType <= SOURCE_OR_PRIMARY_SINK) {
+            mDeviceInfo &= ~DEVICE_TYPE;
             mDeviceInfo |= deviceType;
             return true;
         }