From 03f021a930f4ac582a893ef39d2ad957b2cd18b9 Mon Sep 17 00:00:00 2001 From: Idean Labib Date: Mon, 4 Nov 2024 15:06:18 -0800 Subject: [PATCH] Add Parcel to fbjni Summary: Referenced AContext and AApplication. Parcel is a similar android construct that we need and this seems like the best location in the repo to share this code. Differential Revision: D59996746 fbshipit-source-id: fb7b5b9a1dd0fe6b48f2db8e91fd3d4b1ea9a4e3 --- cxx/fbjni/Parcel.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cxx/fbjni/Parcel.h diff --git a/cxx/fbjni/Parcel.h b/cxx/fbjni/Parcel.h new file mode 100644 index 0000000..17542da --- /dev/null +++ b/cxx/fbjni/Parcel.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +namespace facebook { +namespace jni { + +class AParcel : public JavaClass { + public: + static constexpr const char* kJavaDescriptor = "Landroid/os/Parcel;"; + + static facebook::jni::local_ref obtain() { + static const auto kMethod = + javaClassStatic()->getStaticMethod()>("obtain"); + return kMethod(javaClassStatic()); + } + + void recycle() { + static const auto kMethod = javaClassStatic()->getMethod("recycle"); + kMethod(self()); + } +}; + +} // namespace jni +} // namespace facebook