1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_OS_HW_PARCEL_H 18 #define ANDROID_OS_HW_PARCEL_H 19 20 #include "hwbinder/EphemeralStorage.h" 21 22 #include <android-base/macros.h> 23 #include <hwbinder/IBinder.h> 24 #include <hwbinder/Parcel.h> 25 #include <jni.h> 26 #include <utils/RefBase.h> 27 28 namespace android { 29 30 struct JHwParcel : public RefBase { 31 static void InitClass(JNIEnv *env); 32 33 static sp<JHwParcel> SetNativeContext( 34 JNIEnv *env, jobject thiz, const sp<JHwParcel> &context); 35 36 static sp<JHwParcel> GetNativeContext(JNIEnv *env, jobject thiz); 37 38 static jobject NewObject(JNIEnv *env); 39 40 JHwParcel(JNIEnv *env, jobject thiz); 41 42 void setParcel(hardware::Parcel *parcel, bool assumeOwnership); 43 hardware::Parcel *getParcel(); 44 45 EphemeralStorage *getStorage(); 46 47 void setTransactCallback(::android::hardware::IBinder::TransactCallback cb); 48 49 void send(); 50 bool wasSent() const; 51 52 protected: 53 virtual ~JHwParcel(); 54 55 private: 56 hardware::Parcel *mParcel; 57 bool mOwnsParcel; 58 59 EphemeralStorage mStorage; 60 61 ::android::hardware::IBinder::TransactCallback mTransactCallback; 62 bool mWasSent; 63 64 DISALLOW_COPY_AND_ASSIGN(JHwParcel); 65 }; 66 67 void signalExceptionForError(JNIEnv *env, status_t err, bool canThrowRemoteException = false); 68 int register_android_os_HwParcel(JNIEnv *env); 69 70 } // namespace android 71 72 #endif // ANDROID_OS_HW_PARCEL_H 73