diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-12-10 07:05:18 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-10 07:05:18 -0800 |
commit | 314664d2479a55b182035f0585eadd40a0e6833d (patch) | |
tree | e9b3af06b61b6038d83871779b9ef52e3aa6e00d /core/jni | |
parent | 5b214e0f9670af7dad5dc40189778f9f4e6d41a8 (diff) | |
parent | 68a3b8b66044d0a9fa901ad306fc6db6d13f94d3 (diff) | |
download | frameworks_base-314664d2479a55b182035f0585eadd40a0e6833d.zip frameworks_base-314664d2479a55b182035f0585eadd40a0e6833d.tar.gz frameworks_base-314664d2479a55b182035f0585eadd40a0e6833d.tar.bz2 |
am 68a3b8b6: am 24eca800: Merge change I887f355f into eclair-mr2
Merge commit '68a3b8b66044d0a9fa901ad306fc6db6d13f94d3'
* commit '68a3b8b66044d0a9fa901ad306fc6db6d13f94d3':
Propagate background scheduling class across processes.
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android_util_Binder.cpp | 7 | ||||
-rw-r--r-- | core/jni/android_util_Process.cpp | 39 |
2 files changed, 19 insertions, 27 deletions
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index f0885fd..627fcbf 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -670,6 +670,12 @@ static void android_os_BinderInternal_joinThreadPool(JNIEnv* env, jobject clazz) android::IPCThreadState::self()->joinThreadPool(); } +static void android_os_BinderInternal_disableBackgroundScheduling(JNIEnv* env, + jobject clazz, jboolean disable) +{ + IPCThreadState::disableBackgroundScheduling(disable ? true : false); +} + static void android_os_BinderInternal_handleGc(JNIEnv* env, jobject clazz) { LOGV("Gc has executed, clearing binder ops"); @@ -682,6 +688,7 @@ static const JNINativeMethod gBinderInternalMethods[] = { /* name, signature, funcPtr */ { "getContextObject", "()Landroid/os/IBinder;", (void*)android_os_BinderInternal_getContextObject }, { "joinThreadPool", "()V", (void*)android_os_BinderInternal_joinThreadPool }, + { "disableBackgroundScheduling", "(Z)V", (void*)android_os_BinderInternal_disableBackgroundScheduling }, { "handleGc", "()V", (void*)android_os_BinderInternal_handleGc } }; diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index 094b02d..e84f2e5 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -120,11 +120,7 @@ jint android_os_Process_myUid(JNIEnv* env, jobject clazz) jint android_os_Process_myTid(JNIEnv* env, jobject clazz) { -#ifdef HAVE_GETTID - return gettid(); -#else - return getpid(); -#endif + return androidGetTid(); } jint android_os_Process_getUidForName(JNIEnv* env, jobject clazz, jstring name) @@ -191,15 +187,11 @@ jint android_os_Process_getGidForName(JNIEnv* env, jobject clazz, jstring name) void android_os_Process_setThreadGroup(JNIEnv* env, jobject clazz, int pid, jint grp) { - if (grp > ANDROID_TGROUP_MAX || grp < 0) { - signalExceptionForGroupError(env, clazz, EINVAL); + int res = androidSetThreadSchedulingGroup(pid, grp); + if (res != NO_ERROR) { + signalExceptionForGroupError(env, clazz, res == BAD_VALUE ? EINVAL : errno); return; } - - if (set_sched_policy(pid, (grp == ANDROID_TGROUP_BG_NONINTERACT) ? - SP_BACKGROUND : SP_FOREGROUND)) { - signalExceptionForGroupError(env, clazz, errno); - } } void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jint grp) @@ -275,22 +267,15 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz, jint pid, jint pri) { - int rc = 0; - - if (pri >= ANDROID_PRIORITY_BACKGROUND) { - rc = set_sched_policy(pid, SP_BACKGROUND); - } else if (getpriority(PRIO_PROCESS, pid) >= ANDROID_PRIORITY_BACKGROUND) { - rc = set_sched_policy(pid, SP_FOREGROUND); - } - - if (rc) { - signalExceptionForGroupError(env, clazz, errno); - return; - } - - if (setpriority(PRIO_PROCESS, pid, pri) < 0) { - signalExceptionForPriorityError(env, clazz, errno); + int rc = androidSetThreadPriority(pid, pri); + if (rc != 0) { + if (rc == INVALID_OPERATION) { + signalExceptionForPriorityError(env, clazz, errno); + } else { + signalExceptionForGroupError(env, clazz, errno); + } } + //LOGI("Setting priority of %d: %d, getpriority returns %d\n", // pid, pri, getpriority(PRIO_PROCESS, pid)); } |