1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_IPC_JNI_REMOTE_OBJECT_H 17 #define OHOS_IPC_JNI_REMOTE_OBJECT_H 18 19 #include <jni.h> 20 #include "refbase.h" 21 #include "iremote_object.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 /* 27 * Class: ohos.rpc.IPCSkeleton 28 * Method: nativeGetContextObject 29 * Signature: (V)Lohos/rpc/IRemoteObject; 30 */ 31 jobject JNICALL Java_ohos_rpc_IPCSkeleton_nativeGetContextObject(JNIEnv *env, jclass clazz); 32 33 /* 34 * Class: ohos.rpc.IPCSkeleton 35 * Method: nativeGetCallingPid 36 * Signature: (V)I 37 */ 38 jint JNICALL Java_ohos_rpc_IPCSkeleton_nativeGetCallingPid(JNIEnv *env, jclass clazz); 39 40 /* 41 * Class: ohos.rpc.IPCSkeleton 42 * Method: nativeGetCallingUid 43 * Signature: (V)I 44 */ 45 jint JNICALL Java_ohos_rpc_IPCSkeleton_nativeGetCallingUid(JNIEnv *env, jclass clazz); 46 47 /* 48 * Class: ohos.rpc.IPCSkeleton 49 * Method: nativeGetCallingDeviceID 50 * Signature: (V)Lohos/rpc/IRemoteObject; 51 */ 52 jstring JNICALL Java_ohos_rpc_IPCSkeleton_nativeGetCallingDeviceID(JNIEnv *env, jclass clazz); 53 54 /* 55 * Class: ohos.rpc.IPCSkeleton 56 * Method: nativeGetLocalDeviceID 57 * Signature: (V)Lohos/rpc/IRemoteObject; 58 */ 59 jstring JNICALL Java_ohos_rpc_IPCSkeleton_nativeGetLocalDeviceID(JNIEnv *env, jclass clazz); 60 61 /* 62 * Class: ohos.rpc.IPCSkeleton 63 * Method: nativeIsLocalCalling 64 * Signature: (V)Z 65 */ 66 jboolean JNICALL Java_ohos_rpc_IPCSkeleton_nativeIsLocalCalling(JNIEnv *env, jclass clazz); 67 68 /* 69 * Class: ohos.rpc.IPCSkeleton 70 * Method: nativeFlushCommands 71 * Signature: (Lohos/rpc/IRemoteObject;)I; 72 */ 73 jint JNICALL Java_ohos_rpc_IPCSkeleton_nativeFlushCommands(JNIEnv *env, jclass clazz, jobject object); 74 75 /* 76 * Class: ohos.rpc.IPCSkeleton 77 * Method: nativeResetCallingIdentity 78 * Signature: (Lohos/rpc/IRemoteObject;)I; 79 */ 80 jstring JNICALL Java_ohos_rpc_IPCSkeleton_nativeResetCallingIdentity(JNIEnv *env, jclass clazz); 81 82 /* 83 * Class: ohos.rpc.IPCSkeleton 84 * Method: nativeSetCallingIdentity 85 * Signature: (Lohos/rpc/IRemoteObject;)I; 86 */ 87 jboolean JNICALL Java_ohos_rpc_IPCSkeleton_nativeSetCallingIdentity(JNIEnv *env, jclass clazz, jstring identity, 88 jint len); 89 90 /* 91 * Class: ohos.rpc.RemoteObject 92 * Method: nativeGetObjectHolder 93 * Signature: (Ljava/lang/String;I)J 94 */ 95 jlong JNICALL Java_ohos_rpc_RemoteObject_nativeGetObjectHolder(JNIEnv *env, jclass clazz, jstring value, jint len); 96 97 /* 98 * Free local Object Holder of RemoteObject. 99 * Class: ohos.rpc.RemoteObject 100 * Method: nativeFreeObjectHolder 101 * Signature: (J)V 102 */ 103 void JNICALL Java_ohos_rpc_RemoteObject_nativeFreeObjectHolder(JNIEnv *env, jclass clazz, jlong holder); 104 105 /* 106 * Get calling pid from native. 107 * Class: ohos.rpc.RemoteObject 108 * Method: nativeGetCallingPid 109 * Signature: (V)I 110 */ 111 jint JNICALL Java_ohos_rpc_RemoteObject_nativeGetCallingPid(JNIEnv *env, jclass object); 112 113 /* 114 * Get calling UID from native. 115 * Class: ohos.rpc.RemoteObject 116 * Method: nativeGetCallingUid 117 * Signature: (V)I 118 */ 119 jint JNICALL Java_ohos_rpc_RemoteObject_nativeGetCallingUid(JNIEnv *env, jclass object); 120 121 /* 122 * Class: ohos_rpc_RemoteProxy 123 * Method: nativeFreeProxyHolder 124 * Signature: (J)V 125 */ 126 void JNICALL Java_ohos_rpc_RemoteProxy_nativeFreeProxyHolder(JNIEnv *env, jclass clazz, jlong holder); 127 128 /* 129 * Class: ohos.rpc.RemoteProxy 130 * Method: nativeSendRequest 131 * Signature: (ILohos/rpc/MessageParcel;Lohos/rpc/Parcel;Lohos/rpc/MessageOption;)Z 132 */ 133 jboolean JNICALL Java_ohos_rpc_RemoteProxy_nativeSendRequest(JNIEnv *env, jobject object, jint code, jobject data, 134 jobject reply, jobject option); 135 136 /* 137 * Class: ohos.rpc.RemoteProxy 138 * Method: nativeAddDeathRecipient 139 * Signature: (Lohos/rpc/IRemoteObject$DeathRecipient;I)Z 140 */ 141 jboolean JNICALL Java_ohos_rpc_RemoteProxy_nativeAddDeathRecipient(JNIEnv *env, jobject clazz, jobject recipient, 142 jint flags); 143 144 /* 145 * Class: ohos.rpc.RemoteProxy 146 * Method: nativeRemoveDeathRecipient 147 * Signature: (Lohos/rpc/IRemoteObject$DeathRecipient;I)Z 148 */ 149 jboolean JNICALL Java_ohos_rpc_RemoteProxy_nativeRemoveDeathRecipient(JNIEnv *env, jobject clazz, jobject recipient, 150 jint flags); 151 152 /* 153 * Class: ohos_rpc_RemoteProxy 154 * Method: nativeGetInterfaceDescriptor 155 * Signature: ()Ljava/lang/String; 156 */ 157 jstring JNICALL Java_ohos_rpc_RemoteProxy_nativeGetInterfaceDescriptor(JNIEnv *env, jobject clazz); 158 159 /* 160 * Class: ohos.rpc.RemoteProxy 161 * Method: nativeIsObjectDead 162 * Signature: (V)Z 163 */ 164 jboolean JNICALL Java_ohos_rpc_RemoteProxy_nativeIsObjectDead(JNIEnv *env, jobject object); 165 166 /* 167 * Class: ohos.rpc.RemoteProxy 168 * Method: nativeGetHandle 169 * Signature: (V)J 170 */ 171 jlong JNICALL Java_ohos_rpc_RemoteProxy_nativeGetHandle(JNIEnv *env, jobject object); 172 173 #ifdef __cplusplus 174 } 175 #endif 176 namespace OHOS { 177 sptr<IRemoteObject> Java_ohos_rpc_getNativeRemoteObject(JNIEnv *env, jobject object); 178 179 jobject Java_ohos_rpc_getJavaRemoteObject(JNIEnv *env, const sptr<IRemoteObject> target); 180 } // namespace OHOS 181 #endif // OHOS_IPC_JNI_REMOTE_OBJECT_H 182