From c8f3b43984d8be9598e0c523472996dcfcefe87a Mon Sep 17 00:00:00 2001 From: Marc Horowitz Date: Fri, 20 Nov 2015 12:16:39 -0800 Subject: [PATCH] Don't use the Bridge from CatalystInstance. Summary: getBridge() is annotated VisibleForTesting, but still used in DevSupportManager. Instead, add the necessary methods to the CatalystInstance interface. public Reviewed By: astreet Differential Revision: D2651265 fb-gh-sync-id: 395893a961c32843871de4451eeccb33135b7ede --- .../react/bridge/CatalystInstance.java | 21 +++++++++++++++++++ .../react/devsupport/DevSupportManager.java | 8 +++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java index f8d7bff45..ee9138022 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java @@ -306,6 +306,27 @@ public class CatalystInstance { mBridgeIdleListeners.remove(listener); } + public boolean supportsProfiling() { + if (mBridge == null) { + return false; + } + return mBridge.supportsProfiling(); + } + + public void startProfiler(String title) { + if (mBridge == null) { + return; + } + mBridge.startProfiler(title); + } + + public void stopProfiler(String title, String filename) { + if (mBridge == null) { + return; + } + mBridge.stopProfiler(title, filename); + } + private String buildModulesConfigJSONProperty( NativeModuleRegistry nativeModuleRegistry, JavaScriptModulesConfig jsModulesConfig) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java index bd8add591..0a5d1da14 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java @@ -285,8 +285,7 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler { if (mCurrentContext != null && mCurrentContext.getCatalystInstance() != null && !mCurrentContext.getCatalystInstance().isDestroyed() && - mCurrentContext.getCatalystInstance().getBridge() != null && - mCurrentContext.getCatalystInstance().getBridge().supportsProfiling()) { + mCurrentContext.getCatalystInstance().supportsProfiling()) { options.put( mApplicationContext.getString( mIsCurrentlyProfiling ? R.string.catalyst_stop_profile : @@ -302,7 +301,6 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler { mProfileIndex++; Debug.stopMethodTracing(); mCurrentContext.getCatalystInstance() - .getBridge() .stopProfiler("profile", profileName); Toast.makeText( mCurrentContext, @@ -310,7 +308,7 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler { Toast.LENGTH_LONG).show(); } else { mIsCurrentlyProfiling = true; - mCurrentContext.getCatalystInstance().getBridge().startProfiler("profile"); + mCurrentContext.getCatalystInstance().startProfiler("profile"); Debug.startMethodTracingSampling( profileName, JAVA_SAMPLING_PROFILE_MEMORY_BYTES, @@ -476,7 +474,7 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler { "/profile_" + mProfileIndex + ".json"); mProfileIndex++; Debug.stopMethodTracing(); - mCurrentContext.getCatalystInstance().getBridge().stopProfiler("profile", profileName); + mCurrentContext.getCatalystInstance().stopProfiler("profile", profileName); } mCurrentContext = reactContext;