diff options
| author | 2021-03-04 15:10:13 +0000 | |
|---|---|---|
| committer | 2021-03-04 15:29:25 +0000 | |
| commit | 9c5c46d2b30df70d951ed68cf4034e84874e7e46 (patch) | |
| tree | 504b09358640de916713f201c760281666efce1f | |
| parent | 039e79a2a562cfe9a5b15d87a0b7c842f5ef3c69 (diff) | |
Using jniThrowErrnoException in android_util_Process
Since libnativehelper now has an implementation of jniThrowErrnoException,
this method is now used when a system error occurs to avoid code
duplication.
Bug: 180958753
Test: m
Change-Id: I14b8f6c5fb7179624450ecaae10c6bb1f48b4029
| -rw-r--r-- | core/jni/android_util_Process.cpp | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index 6becb07d02a4..04faebc7beff 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -1290,24 +1290,6 @@ void android_os_Process_removeAllProcessGroups(JNIEnv* env, jobject clazz) return removeAllProcessGroups(); } -static void throwErrnoException(JNIEnv* env, const char* functionName, int error) { - ScopedLocalRef<jstring> detailMessage(env, env->NewStringUTF(functionName)); - if (detailMessage.get() == NULL) { - // Not really much we can do here. We're probably dead in the water, - // but let's try to stumble on... - env->ExceptionClear(); - } - static jclass errnoExceptionClass = - MakeGlobalRefOrDie(env, FindClassOrDie(env, "android/system/ErrnoException")); - - static jmethodID errnoExceptionCtor = - GetMethodIDOrDie(env, errnoExceptionClass, "<init>", "(Ljava/lang/String;I)V"); - - jobject exception = - env->NewObject(errnoExceptionClass, errnoExceptionCtor, detailMessage.get(), error); - env->Throw(reinterpret_cast<jthrowable>(exception)); -} - // Wrapper function to the syscall pidfd_open, which creates a file // descriptor that refers to the process whose PID is specified in pid. static inline int sys_pidfd_open(pid_t pid, unsigned int flags) { @@ -1317,7 +1299,7 @@ static inline int sys_pidfd_open(pid_t pid, unsigned int flags) { static jint android_os_Process_nativePidFdOpen(JNIEnv* env, jobject, jint pid, jint flags) { int fd = sys_pidfd_open(pid, flags); if (fd < 0) { - throwErrnoException(env, "nativePidFdOpen", errno); + jniThrowErrnoException(env, "nativePidFdOpen", errno); return -1; } return fd; |