| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef EPHEMERAL_STORAGE_H_ |
| 18 |
|
| 19 |
#define EPHEMERAL_STORAGE_H_ |
| 20 |
|
| 21 |
#include <android-base/macros.h> |
| 22 |
#include <hidl/HidlSupport.h> |
| 23 |
#include <jni.h> |
| 24 |
#include <utils/Vector.h> |
| 25 |
|
| 26 |
namespace android { |
| 27 |
|
| 28 |
#define DECLARE_ALLOC_METHODS(Suffix,Type) \ |
| 29 |
const ::android::hardware::hidl_vec<Type> * \ |
| 30 |
allocTemporary ## Suffix ## Vector( \ |
| 31 |
JNIEnv *env, Type ## Array arrayObj); |
| 32 |
|
| 33 |
struct EphemeralStorage { |
| 34 |
EphemeralStorage(); |
| 35 |
~EphemeralStorage(); |
| 36 |
|
| 37 |
void release(JNIEnv *env); |
| 38 |
|
| 39 |
hardware::hidl_string *allocStringArray(size_t size); |
| 40 |
|
| 41 |
void *allocTemporaryStorage(size_t size); |
| 42 |
|
| 43 |
const ::android::hardware::hidl_string *allocTemporaryString( |
| 44 |
JNIEnv *env, jstring stringObj); |
| 45 |
|
| 46 |
native_handle_t *allocTemporaryNativeHandle(int numFds, int numInts); |
| 47 |
|
| 48 |
DECLARE_ALLOC_METHODS(Int8,jbyte) |
| 49 |
DECLARE_ALLOC_METHODS(Int16,jshort) |
| 50 |
DECLARE_ALLOC_METHODS(Int32,jint) |
| 51 |
DECLARE_ALLOC_METHODS(Int64,jlong) |
| 52 |
DECLARE_ALLOC_METHODS(Float,jfloat) |
| 53 |
DECLARE_ALLOC_METHODS(Double,jdouble) |
| 54 |
|
| 55 |
private: |
| 56 |
enum Type { |
| 57 |
TYPE_STRING_ARRAY, |
| 58 |
TYPE_STORAGE, |
| 59 |
TYPE_STRING, |
| 60 |
TYPE_Int8_ARRAY, |
| 61 |
TYPE_Int16_ARRAY, |
| 62 |
TYPE_Int32_ARRAY, |
| 63 |
TYPE_Int64_ARRAY, |
| 64 |
TYPE_Float_ARRAY, |
| 65 |
TYPE_Double_ARRAY, |
| 66 |
TYPE_NATIVE_HANDLE, |
| 67 |
}; |
| 68 |
|
| 69 |
struct Item { |
| 70 |
Type mType; |
| 71 |
jobject mObj; |
| 72 |
void *mPtr; |
| 73 |
}; |
| 74 |
|
| 75 |
Vector<Item> mItems; |
| 76 |
|
| 77 |
DISALLOW_COPY_AND_ASSIGN(EphemeralStorage); |
| 78 |
}; |
| 79 |
|
| 80 |
#undef DECLARE_ALLOC_METHODS |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
#endif |