Andreas Huber | c0b6c53 | 2016-08-15 09:25:02 -0700 | [diff] [blame] | 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 | jclass mClass; |
| 57 | jobject mObject; |
| 58 | |
| 59 | hardware::Parcel *mParcel; |
| 60 | bool mOwnsParcel; |
| 61 | |
| 62 | EphemeralStorage mStorage; |
| 63 | |
| 64 | ::android::hardware::IBinder::TransactCallback mTransactCallback; |
| 65 | bool mWasSent; |
| 66 | |
| 67 | DISALLOW_COPY_AND_ASSIGN(JHwParcel); |
| 68 | }; |
| 69 | |
| 70 | void signalExceptionForError(JNIEnv *env, status_t err); |
| 71 | int register_android_os_HwParcel(JNIEnv *env); |
| 72 | |
| 73 | } // namespace android |
| 74 | |
| 75 | #endif // ANDROID_OS_HW_PARCEL_H |