Expose scheduler through FabricUIManager

Summary:
Allows to access `react::renderer::Scheduler` given `FabricUIManager` from Java side.

Changelog: [Added] Added `FabricUIManager` binding with FBJNI

Reviewed By: javache

Differential Revision: D35313399

fbshipit-source-id: 54e7adcceae40368c2735ddfc8a083f87b08dc5e
This commit is contained in:
Nicola Corti
2022-04-26 05:11:05 -07:00
committed by Facebook GitHub Bot
parent e51e19ecc1
commit 1730949e94
3 changed files with 45 additions and 1 deletions
@@ -43,6 +43,8 @@ class Binding : public jni::HybridClass<Binding>,
static void registerNatives();
std::shared_ptr<Scheduler> getScheduler();
private:
void setConstraints(
jint surfaceId,
@@ -133,7 +135,6 @@ class Binding : public jni::HybridClass<Binding>,
std::shared_ptr<FabricMountingManager> mountingManager_;
std::shared_ptr<Scheduler> scheduler_;
std::shared_ptr<Scheduler> getScheduler();
std::shared_ptr<FabricMountingManager> verifyMountingManager(
std::string const &locationHint);
@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "JFabricUIManager.h"
namespace facebook::react {
Binding *JFabricUIManager::getBinding() {
static const auto bindingField =
javaClassStatic()->getField<Binding::javaobject>("mBinding");
return getFieldValue(bindingField)->cthis();
}
} // namespace facebook::react
@@ -0,0 +1,25 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <fbjni/fbjni.h>
#include "Binding.h"
using namespace facebook::jni;
namespace facebook::react {
class JFabricUIManager : public JavaClass<JFabricUIManager> {
public:
static constexpr auto kJavaDescriptor =
"Lcom/facebook/react/fabric/FabricUIManager;";
Binding *getBinding();
};
} // namespace facebook::react