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_REMOTE_BINDER_H |
| 18 | #define ANDROID_OS_HW_REMOTE_BINDER_H |
| 19 | |
| 20 | #include <android-base/macros.h> |
| 21 | #include <hwbinder/Binder.h> |
| 22 | #include <jni.h> |
| 23 | #include <utils/RefBase.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | struct JHwRemoteBinder : public RefBase { |
| 28 | static void InitClass(JNIEnv *env); |
| 29 | |
| 30 | static sp<JHwRemoteBinder> SetNativeContext( |
| 31 | JNIEnv *env, jobject thiz, const sp<JHwRemoteBinder> &context); |
| 32 | |
| 33 | static sp<JHwRemoteBinder> GetNativeContext(JNIEnv *env, jobject thiz); |
| 34 | |
| 35 | static jobject NewObject(JNIEnv *env, const sp<hardware::IBinder> &binder); |
| 36 | |
| 37 | JHwRemoteBinder( |
| 38 | JNIEnv *env, jobject thiz, const sp<hardware::IBinder> &binder); |
| 39 | |
| 40 | sp<hardware::IBinder> getBinder(); |
| 41 | void setBinder(const sp<hardware::IBinder> &binder); |
| 42 | |
| 43 | protected: |
| 44 | virtual ~JHwRemoteBinder(); |
| 45 | |
| 46 | private: |
| 47 | jclass mClass; |
| 48 | jobject mObject; |
| 49 | |
| 50 | sp<hardware::IBinder> mBinder; |
| 51 | |
| 52 | DISALLOW_COPY_AND_ASSIGN(JHwRemoteBinder); |
| 53 | }; |
| 54 | |
| 55 | int register_android_os_HwRemoteBinder(JNIEnv *env); |
| 56 | |
| 57 | } // namespace android |
| 58 | |
| 59 | #endif // ANDROID_OS_HW_REMOTE_BINDER_H |
| 60 | |