diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
commit | d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /core/jni/android_os_ParcelFileDescriptor.cpp | |
parent | 076357b8567458d4b6dfdcf839ef751634cd2bfb (diff) | |
download | frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.zip frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.gz frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'core/jni/android_os_ParcelFileDescriptor.cpp')
-rw-r--r-- | core/jni/android_os_ParcelFileDescriptor.cpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/core/jni/android_os_ParcelFileDescriptor.cpp b/core/jni/android_os_ParcelFileDescriptor.cpp deleted file mode 100644 index 465e233..0000000 --- a/core/jni/android_os_ParcelFileDescriptor.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* //device/libs/android_runtime/android_os_ParcelFileDescriptor.cpp -** -** Copyright 2008, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#include "JNIHelp.h" - -#include <fcntl.h> -#include <sys/stat.h> -#include <stdio.h> - -#include <utils/Log.h> - -#include <android_runtime/AndroidRuntime.h> - -namespace android -{ - -static struct file_descriptor_offsets_t -{ - jclass mClass; - jmethodID mConstructor; - jfieldID mDescriptor; -} gFileDescriptorOffsets; - -static struct socket_offsets_t -{ - jfieldID mSocketImpl; -} gSocketOffsets; - -static struct socket_impl_offsets_t -{ - jfieldID mFileDescriptor; -} gSocketImplOffsets; - - -static jobject android_os_ParcelFileDescriptor_getFileDescriptorFromSocket(JNIEnv* env, - jobject clazz, jobject object) -{ - jobject socketImpl = env->GetObjectField(object, gSocketOffsets.mSocketImpl); - jobject fileDescriptor = env->GetObjectField(socketImpl, gSocketImplOffsets.mFileDescriptor); - jint fd = env->GetIntField(fileDescriptor, gFileDescriptorOffsets.mDescriptor); - jobject fileDescriptorClone = env->NewObject(gFileDescriptorOffsets.mClass, - gFileDescriptorOffsets.mConstructor); - if (fileDescriptorClone != NULL) { - env->SetIntField(fileDescriptorClone, gFileDescriptorOffsets.mDescriptor, dup(fd)); - } - return fileDescriptorClone; -} - -static const JNINativeMethod gParcelFileDescriptorMethods[] = { - {"getFileDescriptorFromSocket", "(Ljava/net/Socket;)Ljava/io/FileDescriptor;", - (void*)android_os_ParcelFileDescriptor_getFileDescriptorFromSocket} -}; - -const char* const kParcelFileDescriptorPathName = "android/os/ParcelFileDescriptor"; - -int register_android_os_ParcelFileDescriptor(JNIEnv* env) -{ - jclass clazz; - - clazz = env->FindClass("java/net/Socket"); - LOG_FATAL_IF(clazz == NULL, "Unable to find class java.net.Socket"); - gSocketOffsets.mSocketImpl = env->GetFieldID(clazz, "impl", "Ljava/net/SocketImpl;"); - LOG_FATAL_IF(gSocketOffsets.mSocketImpl == NULL, - "Unable to find impl field in java.net.Socket"); - - clazz = env->FindClass("java/net/SocketImpl"); - LOG_FATAL_IF(clazz == NULL, "Unable to find class java.net.SocketImpl"); - gSocketImplOffsets.mFileDescriptor = env->GetFieldID(clazz, "fd", "Ljava/io/FileDescriptor;"); - LOG_FATAL_IF(gSocketImplOffsets.mFileDescriptor == NULL, - "Unable to find fd field in java.net.SocketImpl"); - - clazz = env->FindClass("java/io/FileDescriptor"); - LOG_FATAL_IF(clazz == NULL, "Unable to find class java.io.FileDescriptor"); - gFileDescriptorOffsets.mClass = (jclass) env->NewGlobalRef(clazz); - gFileDescriptorOffsets.mConstructor = env->GetMethodID(clazz, "<init>", "()V"); - gFileDescriptorOffsets.mDescriptor = env->GetFieldID(clazz, "descriptor", "I"); - LOG_FATAL_IF(gFileDescriptorOffsets.mDescriptor == NULL, - "Unable to find descriptor field in java.io.FileDescriptor"); - - clazz = env->FindClass(kParcelFileDescriptorPathName); - LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.ParcelFileDescriptor"); - - return AndroidRuntime::registerNativeMethods( - env, kParcelFileDescriptorPathName, - gParcelFileDescriptorMethods, NELEM(gParcelFileDescriptorMethods)); -} - -} |