diff options
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 68 | ||||
| -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 | 16 | ||||
| -rw-r--r-- | core/jni/com_android_internal_os_ZygoteInit.cpp | 18 | ||||
| -rw-r--r-- | core/res/res/values/config.xml | 21 |
8 files changed, 57 insertions, 120 deletions
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 5ce658b74e04..eacfee551c5f 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -87,12 +87,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"; @@ -286,11 +280,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); @@ -309,15 +298,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); @@ -347,8 +327,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); @@ -366,10 +344,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) { @@ -394,22 +369,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)); @@ -430,14 +395,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)); @@ -459,7 +416,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, @@ -468,9 +425,6 @@ public class ZygoteInit { System.gc(); runtime.runFinalizationSync(); System.gc(); - runtime.runFinalizationSync(); - System.gc(); - runtime.runFinalizationSync(); } /** @@ -613,7 +567,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. @@ -682,27 +636,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); diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp index 98f4bed1fc90..a408a96cd2fa 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 a8ed89554261..15d62a2bd476 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 26405b59a386..cebcaae70037 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 7e12b1ea71b6..ca21fd716a5f 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 e0003b8150ac..fbe55e2f3aed 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!"); } diff --git a/core/jni/com_android_internal_os_ZygoteInit.cpp b/core/jni/com_android_internal_os_ZygoteInit.cpp index 2233ee3e012b..10c6e2ce3a83 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 a3b81327b738..a401deba8fd7 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -469,10 +469,10 @@ <integer name="config_longPressOnPowerBehavior">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> @@ -888,7 +888,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 @@ -900,7 +900,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. @@ -908,7 +908,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. @@ -1085,7 +1085,8 @@ <!-- 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.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> <!-- Base "touch slop" value used by ViewConfiguration as a movement threshold where scrolling should begin. --> @@ -1222,20 +1223,20 @@ <!-- 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> <!-- 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. --> |