Loading api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -29290,6 +29290,7 @@ package android.os { method public static final long getStartElapsedRealtime(); method public static final long getStartUptimeMillis(); method public static final int getThreadPriority(int) throws java.lang.IllegalArgumentException; method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException; method public static final int getUidForName(java.lang.String); method public static final boolean is64Bit(); method public static boolean isApplicationUid(int); core/java/android/os/Process.java +22 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package android.os; import android.annotation.TestApi; import android.net.LocalSocket; import android.net.LocalSocketAddress; import android.system.Os; import android.system.OsConstants; import android.util.Log; Loading Loading @@ -716,6 +719,24 @@ public class Process { public static final native int getThreadPriority(int tid) throws IllegalArgumentException; /** * Return the current scheduling policy of a thread, based on Linux. * * @param tid The identifier of the thread/process to get the scheduling policy. * * @throws IllegalArgumentException Throws IllegalArgumentException if * <var>tid</var> does not exist, or if <var>priority</var> is out of range for the policy. * @throws SecurityException Throws SecurityException if your process does * not have permission to modify the given thread, or to use the given * scheduling policy or priority. * * {@hide} */ @TestApi public static final native int getThreadScheduler(int tid) throws IllegalArgumentException; /** * Set the scheduling policy and priority of a thread, based on Linux. * Loading @@ -731,6 +752,7 @@ public class Process { * * {@hide} */ public static final native void setThreadScheduler(int tid, int policy, int priority) throws IllegalArgumentException; Loading core/jni/android_util_Process.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,23 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, #endif } jint android_os_Process_getThreadScheduler(JNIEnv* env, jclass clazz, jint tid) { int policy = 0; // linux has sched_getscheduler(), others don't. #if defined(__linux__) errno = 0; policy = sched_getscheduler(tid); if (errno != 0) { signalExceptionForPriorityError(env, errno); } #else signalExceptionForPriorityError(env, ENOSYS); #endif return policy; } void android_os_Process_setThreadScheduler(JNIEnv* env, jclass clazz, jint tid, jint policy, jint pri) { Loading Loading @@ -1189,6 +1206,7 @@ static const JNINativeMethod methods[] = { {"setCanSelfBackground", "(Z)V", (void*)android_os_Process_setCanSelfBackground}, {"setThreadPriority", "(I)V", (void*)android_os_Process_setCallingThreadPriority}, {"getThreadPriority", "(I)I", (void*)android_os_Process_getThreadPriority}, {"getThreadScheduler", "(I)I", (void*)android_os_Process_getThreadScheduler}, {"setThreadGroup", "(II)V", (void*)android_os_Process_setThreadGroup}, {"setProcessGroup", "(II)V", (void*)android_os_Process_setProcessGroup}, {"getProcessGroup", "(I)I", (void*)android_os_Process_getProcessGroup}, Loading Loading
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -29290,6 +29290,7 @@ package android.os { method public static final long getStartElapsedRealtime(); method public static final long getStartUptimeMillis(); method public static final int getThreadPriority(int) throws java.lang.IllegalArgumentException; method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException; method public static final int getUidForName(java.lang.String); method public static final boolean is64Bit(); method public static boolean isApplicationUid(int);
core/java/android/os/Process.java +22 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package android.os; import android.annotation.TestApi; import android.net.LocalSocket; import android.net.LocalSocketAddress; import android.system.Os; import android.system.OsConstants; import android.util.Log; Loading Loading @@ -716,6 +719,24 @@ public class Process { public static final native int getThreadPriority(int tid) throws IllegalArgumentException; /** * Return the current scheduling policy of a thread, based on Linux. * * @param tid The identifier of the thread/process to get the scheduling policy. * * @throws IllegalArgumentException Throws IllegalArgumentException if * <var>tid</var> does not exist, or if <var>priority</var> is out of range for the policy. * @throws SecurityException Throws SecurityException if your process does * not have permission to modify the given thread, or to use the given * scheduling policy or priority. * * {@hide} */ @TestApi public static final native int getThreadScheduler(int tid) throws IllegalArgumentException; /** * Set the scheduling policy and priority of a thread, based on Linux. * Loading @@ -731,6 +752,7 @@ public class Process { * * {@hide} */ public static final native void setThreadScheduler(int tid, int policy, int priority) throws IllegalArgumentException; Loading
core/jni/android_util_Process.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,23 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, #endif } jint android_os_Process_getThreadScheduler(JNIEnv* env, jclass clazz, jint tid) { int policy = 0; // linux has sched_getscheduler(), others don't. #if defined(__linux__) errno = 0; policy = sched_getscheduler(tid); if (errno != 0) { signalExceptionForPriorityError(env, errno); } #else signalExceptionForPriorityError(env, ENOSYS); #endif return policy; } void android_os_Process_setThreadScheduler(JNIEnv* env, jclass clazz, jint tid, jint policy, jint pri) { Loading Loading @@ -1189,6 +1206,7 @@ static const JNINativeMethod methods[] = { {"setCanSelfBackground", "(Z)V", (void*)android_os_Process_setCanSelfBackground}, {"setThreadPriority", "(I)V", (void*)android_os_Process_setCallingThreadPriority}, {"getThreadPriority", "(I)I", (void*)android_os_Process_getThreadPriority}, {"getThreadScheduler", "(I)I", (void*)android_os_Process_getThreadScheduler}, {"setThreadGroup", "(II)V", (void*)android_os_Process_setThreadGroup}, {"setProcessGroup", "(II)V", (void*)android_os_Process_setProcessGroup}, {"getProcessGroup", "(I)I", (void*)android_os_Process_getProcessGroup}, Loading