diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ActivityThread.java | 2 | ||||
-rw-r--r-- | core/java/android/os/Process.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/AbsListView.java | 4 | ||||
-rw-r--r-- | core/java/com/android/internal/app/ExternalMediaFormatActivity.java | 5 | ||||
-rw-r--r-- | core/java/com/android/internal/os/Zygote.java | 35 | ||||
-rw-r--r-- | core/java/com/android/internal/os/ZygoteConnection.java | 36 | ||||
-rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 70 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_net_LocalSocketImpl.cpp | 44 | ||||
-rw-r--r-- | core/jni/android_os_MessageQueue.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_os_SELinux.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_server_NetworkManagementSocketTagger.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_util_Binder.cpp | 27 | ||||
-rw-r--r-- | core/jni/android_util_Process.cpp | 6 | ||||
-rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 43 | ||||
-rw-r--r-- | core/jni/com_android_internal_os_ZygoteInit.cpp | 18 | ||||
-rw-r--r-- | core/res/res/values/config.xml | 20 |
17 files changed, 111 insertions, 221 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 3a39900..58d5096a 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1940,7 +1940,7 @@ public final class ActivityThread { if (dumpFullInfo) { printRow(pw, HEAP_FULL_COLUMN, "", "Pss", "Pss", "Shared", "Private", "Shared", "Private", "Swapped", "Heap", "Heap", "Heap"); - printRow(pw, HEAP_FULL_COLUMN, "", "Total", "Clean", "Dirty", "", + printRow(pw, HEAP_FULL_COLUMN, "", "Total", "Clean", "Dirty", "Dirty", "Clean", "Clean", "Dirty", "Size", "Alloc", "Free"); printRow(pw, HEAP_FULL_COLUMN, "", "------", "------", "------", "------", "------", "------", "------", "------", "------", "------"); diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index c3ac012..b2ebc31 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -468,6 +468,7 @@ public class Process { * @param targetSdkVersion The target SDK version for the app. * @param seInfo null-ok SELinux information for the new process. * @param abi non-null the ABI this app should be started with. + * @param instructionSet null-ok the instruction set to use. * @param zygoteArgs Additional arguments to supply to the zygote process. * * @return An object that describes the result of the attempt to start the process. @@ -482,11 +483,12 @@ public class Process { int targetSdkVersion, String seInfo, String abi, + String instructionSet, String[] zygoteArgs) { try { return startViaZygote(processClass, niceName, uid, gid, gids, debugFlags, mountExternal, targetSdkVersion, seInfo, - abi, zygoteArgs); + abi, instructionSet, zygoteArgs); } catch (ZygoteStartFailedEx ex) { Log.e(LOG_TAG, "Starting VM process through Zygote failed"); @@ -589,6 +591,7 @@ public class Process { * @param targetSdkVersion The target SDK version for the app. * @param seInfo null-ok SELinux information for the new process. * @param abi the ABI the process should use. + * @param instructionSet null-ok the instruction set to use. * @param extraArgs Additional arguments to supply to the zygote process. * @return An object that describes the result of the attempt to start the process. * @throws ZygoteStartFailedEx if process start failed for any reason @@ -601,6 +604,7 @@ public class Process { int targetSdkVersion, String seInfo, String abi, + String instructionSet, String[] extraArgs) throws ZygoteStartFailedEx { synchronized(Process.class) { @@ -660,6 +664,10 @@ public class Process { argsForZygote.add("--seinfo=" + seInfo); } + if (instructionSet != null) { + argsForZygote.add("--instruction-set=" + instructionSet); + } + argsForZygote.add(processClass); if (extraArgs != null) { diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index eef8554..026cfc1 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2378,7 +2378,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te 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.DialogInterface; 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 @@ public class ExternalMediaFormatActivity extends AlertActivity implements Dialog 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/Zygote.java b/core/java/com/android/internal/os/Zygote.java index c5211bb..f23326c 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -20,12 +20,9 @@ package com.android.internal.os; import dalvik.system.ZygoteHooks; import android.system.ErrnoException; import android.system.Os; -import android.os.SystemClock; -import android.util.Slog; /** @hide */ public final class Zygote { - private static final String TAG = "Zygote"; /* * Bit values for "debugFlags" argument. The definitions are duplicated * in the native code. @@ -78,37 +75,25 @@ public final class Zygote { * file descriptor numbers that are to be closed by the child * (and replaced by /dev/null) after forking. An integer value * of -1 in any entry in the array means "ignore this one". + * @param instructionSet null-ok the instruction set to use. * * @return 0 if this is the child, pid of the child * if this is the parent, or -1 on error. */ public static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags, - int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose) { - long startTime = SystemClock.elapsedRealtime(); + int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose, + String instructionSet) { VM_HOOKS.preFork(); - checkTime(startTime, "Zygote.preFork"); int pid = nativeForkAndSpecialize( - uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose); - checkTime(startTime, "Zygote.nativeForkAndSpecialize"); + uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, + instructionSet); VM_HOOKS.postForkCommon(); - checkTime(startTime, "Zygote.postForkCommon"); return pid; } native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int debugFlags, - int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose); - - /** - * Temporary hack: check time since start time and log if over a fixed threshold. - * - */ - private static void checkTime(long startTime, String where) { - long now = SystemClock.elapsedRealtime(); - if ((now-startTime) > 1000) { - // If we are taking more than a second, log about it. - Slog.w(TAG, "Slow operation: " + (now-startTime) + "ms so far, now at " + where); - } - } + int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose, + String instructionSet); /** * Special method to start the system server process. In addition to the @@ -145,10 +130,8 @@ public final class Zygote { native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, long permittedCapabilities, long effectiveCapabilities); - private static void callPostForkChildHooks(int debugFlags) { - long startTime = SystemClock.elapsedRealtime(); - VM_HOOKS.postForkChild(debugFlags); - checkTime(startTime, "Zygote.callPostForkChildHooks"); + private static void callPostForkChildHooks(int debugFlags, String instructionSet) { + VM_HOOKS.postForkChild(debugFlags, instructionSet); } diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index b4c4da6..8388037 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -37,8 +37,6 @@ import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import libcore.io.IoUtils; -import android.os.SystemClock; -import android.util.Slog; /** * A connection that can make spawn requests. @@ -105,23 +103,11 @@ class ZygoteConnection { } /** - * Temporary hack: check time since start time and log if over a fixed threshold. - * - */ - private void checkTime(long startTime, String where) { - long now = SystemClock.elapsedRealtime(); - if ((now-startTime) > 1000) { - // If we are taking more than a second, log about it. - Slog.w(TAG, "Slow operation: " + (now-startTime) + "ms so far, now at " + where); - } - } - - /** * Returns the file descriptor of the associated socket. * * @return null-ok; file descriptor */ - FileDescriptor getFileDescriptor() { + FileDescriptor getFileDesciptor() { return mSocket.getFileDescriptor(); } @@ -145,8 +131,6 @@ class ZygoteConnection { Arguments parsedArgs = null; FileDescriptor[] descriptors; - long startTime = SystemClock.elapsedRealtime(); - try { args = readArgumentList(); descriptors = mSocket.getAncillaryFileDescriptors(); @@ -156,7 +140,6 @@ class ZygoteConnection { return true; } - checkTime(startTime, "zygoteConnection.runOnce: readArgumentList"); if (args == null) { // EOF reached. closeSocket(); @@ -188,19 +171,14 @@ class ZygoteConnection { ", effective=0x" + Long.toHexString(parsedArgs.effectiveCapabilities)); } - applyUidSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyRlimitSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyInvokeWithSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyseInfoSecurityPolicy(parsedArgs, peer, peerSecurityContext); - checkTime(startTime, "zygoteConnection.runOnce: apply security policies"); - applyDebuggerSystemProperty(parsedArgs); applyInvokeWithSystemProperty(parsedArgs); - checkTime(startTime, "zygoteConnection.runOnce: apply security policies"); - int[][] rlimits = null; if (parsedArgs.rlimits != null) { @@ -242,11 +220,9 @@ class ZygoteConnection { fd = null; - checkTime(startTime, "zygoteConnection.runOnce: preForkAndSpecialize"); pid = Zygote.forkAndSpecialize(parsedArgs.uid, parsedArgs.gid, parsedArgs.gids, parsedArgs.debugFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo, - parsedArgs.niceName, fdsToClose); - checkTime(startTime, "zygoteConnection.runOnce: postForkAndSpecialize"); + parsedArgs.niceName, fdsToClose, parsedArgs.instructionSet); } catch (IOException ex) { logAndPrintError(newStderr, "Exception creating pipe", ex); } catch (ErrnoException ex) { @@ -335,6 +311,7 @@ class ZygoteConnection { * [--] <args for RuntimeInit > * <li> If <code>--runtime-init</code> is absent: * [--] <classname> [args...] + * <li> --instruction-set=<i>instruction-set-string</i> which instruction set to use/emulate. * </ul> */ static class Arguments { @@ -398,6 +375,11 @@ class ZygoteConnection { boolean abiListQuery; /** + * The instruction set to use, or null when not important. + */ + String instructionSet; + + /** * Constructs instance and parses args * @param args zygote command-line args * @throws IllegalArgumentException @@ -552,6 +534,8 @@ class ZygoteConnection { mountExternal = Zygote.MOUNT_EXTERNAL_MULTIUSER_ALL; } else if (arg.equals("--query-abi-list")) { abiListQuery = true; + } else if (arg.startsWith("--instruction-set=")) { + instructionSet = arg.substring(arg.indexOf('=') + 1); } else { break; } diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 0aee0e3..87e8ebd 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -91,12 +91,6 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { // 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 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { * 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 @@ public class ZygoteInit { System.gc(); runtime.runFinalizationSync(); System.gc(); - runtime.runFinalizationSync(); - System.gc(); - runtime.runFinalizationSync(); } /** @@ -668,7 +622,7 @@ public class ZygoteInit { 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 @@ public class ZygoteInit { 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); @@ -770,7 +706,7 @@ public class ZygoteInit { } else if (index == 0) { ZygoteConnection newPeer = acceptCommandPeer(abiList); peers.add(newPeer); - fds.add(newPeer.getFileDescriptor()); + fds.add(newPeer.getFileDesciptor()); } else { boolean done; done = peers.get(index).runOnce(); diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 62d8036..d61dd30 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -876,7 +876,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) parseRuntimeOption("dalvik.vm.profiler.type", profileType, "-Xprofile-type:"); // Depth of bounded stack data - parseRuntimeOption("dalvik.vm.profile.max-stack-depth", + parseRuntimeOption("dalvik.vm.profile.stack-depth", profileMaxStackDepth, "-Xprofile-max-stack-depth:"); 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 @@ socket_connect_local(JNIEnv *env, jobject object, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -95,7 +95,7 @@ socket_bind_local (JNIEnv *env, jobject object, jobject fileDescriptor, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -118,7 +118,7 @@ socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, jint backlog fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -154,7 +154,7 @@ socket_accept (JNIEnv *env, jobject object, jobject fileDescriptor, jobject s) fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return NULL; } @@ -184,7 +184,7 @@ socket_shutdown (JNIEnv *env, jobject object, jobject fileDescriptor, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -246,7 +246,7 @@ socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, jint optID fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return 0; } @@ -293,7 +293,7 @@ static void socket_setOption( fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -353,7 +353,7 @@ static jint socket_pending (JNIEnv *env, jobject object, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return (jint)-1; } @@ -378,7 +378,7 @@ static jint socket_available (JNIEnv *env, jobject object, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return (jint)-1; } @@ -459,20 +459,20 @@ static int socket_process_cmsg(JNIEnv *env, jobject thisJ, struct msghdr * pMsg) 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 @@ static int socket_write_all(JNIEnv *env, jobject object, int fd, = (jobjectArray)env->GetObjectField( object, field_outboundFileDescriptors); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return -1; } @@ -570,18 +570,18 @@ static int socket_write_all(JNIEnv *env, jobject object, int fd, // 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 @@ static jint socket_read (JNIEnv *env, jobject object, jobject fileDescriptor) fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return (jint)0; } @@ -683,7 +683,7 @@ static jint socket_readba (JNIEnv *env, jobject object, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return (jint)-1; } @@ -717,7 +717,7 @@ static void socket_write (JNIEnv *env, jobject object, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -745,7 +745,7 @@ static void socket_writeba (JNIEnv *env, jobject object, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -777,7 +777,7 @@ static jobject socket_get_peer_credentials(JNIEnv *env, fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return NULL; } @@ -816,7 +816,7 @@ static jobject socket_getSockName(JNIEnv *env, 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 @@ MessageQueue::~MessageQueue() { } 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 @@ static jstring getPeerCon(JNIEnv *env, jobject, jobject fileDescriptor) { } 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 @@ static jint QTagUid_tagSocketFd(JNIEnv* env, jclass, 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 @@ static jint QTagUid_untagSocketFd(JNIEnv* env, jclass, 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 @@ protected: //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 @@ protected: 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 @@ public: 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 @@ static void conditionally_log_binder_call(int64_t start_millis, } // 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 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, // 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 @@ void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz, // 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_setThreadPriority(JNIEnv* env, jobject clazz, 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_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 3d2d471..f029cf0 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -43,7 +43,6 @@ #include <utils/String8.h> #include <selinux/android.h> #include <processgroup/processgroup.h> -#include <inttypes.h> #include "android_runtime/AndroidRuntime.h" #include "JNIHelp.h" @@ -399,32 +398,15 @@ void SetThreadName(const char* thread_name) { } } - // Temporary timing check. -uint64_t MsTime() { - timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000) + now.tv_nsec / UINT64_C(1000000); -} - - -void ckTime(uint64_t start, const char* where) { - uint64_t now = MsTime(); - if ((now-start) > 1000) { - // If we are taking more than a second, log about it. - ALOGW("Slow operation: %"PRIu64" ms in %s", (uint64_t)(now-start), where); - } -} - // Utility routine to fork zygote and specialize the child process. static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, jint debug_flags, jobjectArray javaRlimits, jlong permittedCapabilities, jlong effectiveCapabilities, jint mount_external, jstring java_se_info, jstring java_se_name, - bool is_system_server, jintArray fdsToClose) { - uint64_t start = MsTime(); + bool is_system_server, jintArray fdsToClose, + jstring instructionSet) { SetSigChldHandler(); - ckTime(start, "ForkAndSpecializeCommon:SetSigChldHandler"); pid_t pid = fork(); @@ -432,12 +414,9 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra // The child process. gMallocLeakZygoteChild = 1; - // Clean up any descriptors which must be closed immediately DetachDescriptors(env, fdsToClose); - ckTime(start, "ForkAndSpecializeCommon:Fork and detach"); - // Keep capabilities across UID change, unless we're staying root. if (uid != 0) { EnableKeepCapabilities(env); @@ -540,10 +519,8 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra UnsetSigChldHandler(); - ckTime(start, "ForkAndSpecializeCommon:child process setup"); - - env->CallStaticVoidMethod(gZygoteClass, gCallPostForkChildHooks, debug_flags); - ckTime(start, "ForkAndSpecializeCommon:PostForkChildHooks returns"); + env->CallStaticVoidMethod(gZygoteClass, gCallPostForkChildHooks, debug_flags, + is_system_server ? NULL : instructionSet); if (env->ExceptionCheck()) { ALOGE("Error calling post fork hooks."); RuntimeAbort(env); @@ -561,7 +538,7 @@ static jint com_android_internal_os_Zygote_nativeForkAndSpecialize( JNIEnv* env, jclass, jint uid, jint gid, jintArray gids, jint debug_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring se_name, - jintArray fdsToClose) { + jintArray fdsToClose, jstring instructionSet) { // Grant CAP_WAKE_ALARM to the Bluetooth process. jlong capabilities = 0; if (uid == AID_BLUETOOTH) { @@ -570,7 +547,7 @@ static jint com_android_internal_os_Zygote_nativeForkAndSpecialize( return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags, rlimits, capabilities, capabilities, mount_external, se_info, - se_name, false, fdsToClose); + se_name, false, fdsToClose, instructionSet); } static jint com_android_internal_os_Zygote_nativeForkSystemServer( @@ -580,7 +557,7 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer( pid_t pid = ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags, rlimits, permittedCapabilities, effectiveCapabilities, - MOUNT_EXTERNAL_NONE, NULL, NULL, true, NULL); + MOUNT_EXTERNAL_NONE, NULL, NULL, true, NULL, NULL); if (pid > 0) { // The zygote process checks whether the child process has died or not. ALOGI("System server process %d has been created", pid); @@ -598,7 +575,8 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer( } static JNINativeMethod gMethods[] = { - { "nativeForkAndSpecialize", "(II[II[[IILjava/lang/String;Ljava/lang/String;[I)I", + { "nativeForkAndSpecialize", + "(II[II[[IILjava/lang/String;Ljava/lang/String;[ILjava/lang/String;)I", (void *) com_android_internal_os_Zygote_nativeForkAndSpecialize }, { "nativeForkSystemServer", "(II[II[[IJJ)I", (void *) com_android_internal_os_Zygote_nativeForkSystemServer } @@ -609,7 +587,8 @@ int register_com_android_internal_os_Zygote(JNIEnv* env) { if (gZygoteClass == NULL) { RuntimeAbort(env); } - gCallPostForkChildHooks = env->GetStaticMethodID(gZygoteClass, "callPostForkChildHooks", "(I)V"); + gCallPostForkChildHooks = env->GetStaticMethodID(gZygoteClass, "callPostForkChildHooks", + "(ILjava/lang/String;)V"); return AndroidRuntime::registerNativeMethods(env, "com/android/internal/os/Zygote", gMethods, NELEM(gMethods)); 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 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env, fd = jniGetFDFromFileDescriptor(env, in); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -106,7 +106,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env, fd = jniGetFDFromFileDescriptor(env, out); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -116,7 +116,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env, fd = jniGetFDFromFileDescriptor(env, errfd); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -134,7 +134,7 @@ static void com_android_internal_os_ZygoteInit_setCloseOnExec (JNIEnv *env, fd = jniGetFDFromFileDescriptor(env, descriptor); - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return; } @@ -170,7 +170,7 @@ static jint com_android_internal_os_ZygoteInit_selectReadable ( jsize length = env->GetArrayLength(fds); fd_set fdset; - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionCheck()) { return -1; } @@ -179,14 +179,14 @@ static jint com_android_internal_os_ZygoteInit_selectReadable ( 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 @@ static jint com_android_internal_os_ZygoteInit_selectReadable ( 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 f3b3077..5330f47 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -503,10 +503,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> @@ -1007,7 +1007,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 @@ -1019,7 +1019,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. @@ -1027,7 +1027,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. @@ -1212,7 +1212,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> @@ -1489,17 +1489,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. @@ -1512,7 +1512,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. --> |