am c67b2ed5
: Merge changes I80eaecff,Ia2b4f79b
* commit 'c67b2ed50226c4758d0fc1434d39f6add6a0a533': Switch Process.myTid over to the libcore JNI too. Replace native Process getpid/getuid with calls to libcore equivalents.
This commit is contained in:
@ -97,7 +97,9 @@ public class DdmHandleHello extends ChunkHandler {
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle introductory packet.
|
||||
* Handle introductory packet. This is called during JNI_CreateJavaVM
|
||||
* before frameworks native methods are registered, so be careful not
|
||||
* to call any APIs that depend on frameworks native code.
|
||||
*/
|
||||
private Chunk handleHELO(Chunk request) {
|
||||
if (false)
|
||||
|
@ -27,6 +27,8 @@ import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import libcore.io.Libcore;
|
||||
|
||||
/*package*/ class ZygoteStartFailedEx extends Exception {
|
||||
/**
|
||||
* Something prevented the zygote process startup from happening normally
|
||||
@ -647,13 +649,17 @@ public class Process {
|
||||
* Returns the identifier of this process, which can be used with
|
||||
* {@link #killProcess} and {@link #sendSignal}.
|
||||
*/
|
||||
public static final native int myPid();
|
||||
public static final int myPid() {
|
||||
return Libcore.os.getpid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of the calling thread, which be used with
|
||||
* {@link #setThreadPriority(int, int)}.
|
||||
*/
|
||||
public static final native int myTid();
|
||||
public static final int myTid() {
|
||||
return Libcore.os.gettid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of this process's uid. This is the kernel uid
|
||||
@ -661,7 +667,9 @@ public class Process {
|
||||
* app-specific sandbox. It is different from {@link #myUserHandle} in that
|
||||
* a uid identifies a specific app sandbox in a specific user.
|
||||
*/
|
||||
public static final native int myUid();
|
||||
public static final int myUid() {
|
||||
return Libcore.os.getuid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this process's user handle. This is the
|
||||
|
@ -94,21 +94,6 @@ static void signalExceptionForGroupError(JNIEnv* env, int err)
|
||||
}
|
||||
}
|
||||
|
||||
jint android_os_Process_myPid(JNIEnv* env, jobject clazz)
|
||||
{
|
||||
return getpid();
|
||||
}
|
||||
|
||||
jint android_os_Process_myUid(JNIEnv* env, jobject clazz)
|
||||
{
|
||||
return getuid();
|
||||
}
|
||||
|
||||
jint android_os_Process_myTid(JNIEnv* env, jobject clazz)
|
||||
{
|
||||
return androidGetTid();
|
||||
}
|
||||
|
||||
jint android_os_Process_getUidForName(JNIEnv* env, jobject clazz, jstring name)
|
||||
{
|
||||
if (name == NULL) {
|
||||
@ -343,8 +328,7 @@ void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz,
|
||||
void android_os_Process_setCallingThreadPriority(JNIEnv* env, jobject clazz,
|
||||
jint pri)
|
||||
{
|
||||
jint tid = android_os_Process_myTid(env, clazz);
|
||||
android_os_Process_setThreadPriority(env, clazz, tid, pri);
|
||||
android_os_Process_setThreadPriority(env, clazz, androidGetTid(), pri);
|
||||
}
|
||||
|
||||
jint android_os_Process_getThreadPriority(JNIEnv* env, jobject clazz,
|
||||
@ -989,9 +973,6 @@ jintArray android_os_Process_getPidsForCommands(JNIEnv* env, jobject clazz,
|
||||
}
|
||||
|
||||
static const JNINativeMethod methods[] = {
|
||||
{"myPid", "()I", (void*)android_os_Process_myPid},
|
||||
{"myTid", "()I", (void*)android_os_Process_myTid},
|
||||
{"myUid", "()I", (void*)android_os_Process_myUid},
|
||||
{"getUidForName", "(Ljava/lang/String;)I", (void*)android_os_Process_getUidForName},
|
||||
{"getGidForName", "(Ljava/lang/String;)I", (void*)android_os_Process_getGidForName},
|
||||
{"setThreadPriority", "(II)V", (void*)android_os_Process_setThreadPriority},
|
||||
|
Reference in New Issue
Block a user