Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert FpsDebugFrameCallback/AnimationsDebugModule to Kotlin #44475

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 35 additions & 26 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -2085,8 +2085,7 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
protected fun getCurrentContext ()Lcom/facebook/react/bridge/ReactContext;
public fun getDevLoadingViewManager ()Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;
public fun getDevServerHelper ()Lcom/facebook/react/devsupport/DevServerHelper;
public fun getDevSettings ()Lcom/facebook/react/devsupport/DevInternalSettings;
public synthetic fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
public fun getDevSupportEnabled ()Z
public fun getDownloadedJSBundleFile ()Ljava/lang/String;
public fun getJSAppBundleName ()Ljava/lang/String;
Expand Down Expand Up @@ -2220,8 +2219,7 @@ public class com/facebook/react/devsupport/PackagerStatusCheck {

public final class com/facebook/react/devsupport/PerftestDevSupportManager : com/facebook/react/devsupport/ReleaseDevSupportManager {
public fun <init> (Landroid/content/Context;)V
public fun getDevSettings ()Lcom/facebook/react/devsupport/DevInternalSettings;
public synthetic fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
public fun startInspector ()V
public fun stopInspector ()V
}
Expand Down Expand Up @@ -3191,33 +3189,34 @@ public final class com/facebook/react/modules/debug/DevSettingsModule : com/face
public fun toggleElementInspector ()V
}

public class com/facebook/react/modules/debug/FpsDebugFrameCallback : android/view/Choreographer$FrameCallback {
public final class com/facebook/react/modules/debug/FpsDebugFrameCallback : android/view/Choreographer$FrameCallback {
public fun <init> (Lcom/facebook/react/bridge/ReactContext;)V
public fun doFrame (J)V
public fun get4PlusFrameStutters ()I
public fun getExpectedNumFrames ()I
public fun getFPS ()D
public fun getFpsInfo (J)Lcom/facebook/react/modules/debug/FpsDebugFrameCallback$FpsInfo;
public fun getJSFPS ()D
public fun getNumFrames ()I
public fun getNumJSFrames ()I
public fun getTotalTimeMS ()I
public fun reset ()V
public fun start ()V
public fun start (D)V
public fun startAndRecordFpsAtEachFrame ()V
public fun stop ()V
public final fun get4PlusFrameStutters ()I
public final fun getExpectedNumFrames ()I
public final fun getFPS ()D
public final fun getFpsInfo (J)Lcom/facebook/react/modules/debug/FpsDebugFrameCallback$FpsInfo;
public final fun getJSFPS ()D
public final fun getNumFrames ()I
public final fun getNumJSFrames ()I
public final fun getTotalTimeMS ()I
public final fun reset ()V
public final fun start ()V
public final fun start (D)V
public static synthetic fun start$default (Lcom/facebook/react/modules/debug/FpsDebugFrameCallback;DILjava/lang/Object;)V
public final fun startAndRecordFpsAtEachFrame ()V
public final fun stop ()V
}

public class com/facebook/react/modules/debug/FpsDebugFrameCallback$FpsInfo {
public final field fps D
public final field jsFps D
public final field total4PlusFrameStutters I
public final field totalExpectedFrames I
public final field totalFrames I
public final field totalJsFrames I
public final field totalTimeMs I
public final class com/facebook/react/modules/debug/FpsDebugFrameCallback$FpsInfo {
public fun <init> (IIIIDDI)V
public final fun getFps ()D
public final fun getJsFps ()D
public final fun getTotal4PlusFrameStutters ()I
public final fun getTotalExpectedFrames ()I
public final fun getTotalFrames ()I
public final fun getTotalJsFrames ()I
public final fun getTotalTimeMs ()I
}

public class com/facebook/react/modules/debug/SourceCodeModule : com/facebook/fbreact/specs/NativeSourceCodeSpec {
Expand All @@ -3227,15 +3226,25 @@ public class com/facebook/react/modules/debug/SourceCodeModule : com/facebook/fb

public abstract interface class com/facebook/react/modules/debug/interfaces/DeveloperSettings {
public abstract fun addMenuItem (Ljava/lang/String;)V
public abstract fun getPackagerConnectionSettings ()Lcom/facebook/react/packagerconnection/PackagerConnectionSettings;
public abstract fun isAnimationFpsDebugEnabled ()Z
public abstract fun isDeviceDebugEnabled ()Z
public abstract fun isElementInspectorEnabled ()Z
public abstract fun isFpsDebugEnabled ()Z
public abstract fun isHotModuleReplacementEnabled ()Z
public abstract fun isJSDevModeEnabled ()Z
public abstract fun isJSMinifyEnabled ()Z
public abstract fun isRemoteJSDebugEnabled ()Z
public abstract fun isStartSamplingProfilerOnInit ()Z
public abstract fun setAnimationFpsDebugEnabled (Z)V
public abstract fun setDeviceDebugEnabled (Z)V
public abstract fun setElementInspectorEnabled (Z)V
public abstract fun setFpsDebugEnabled (Z)V
public abstract fun setHotModuleReplacementEnabled (Z)V
public abstract fun setJSDevModeEnabled (Z)V
public abstract fun setJSMinifyEnabled (Z)V
public abstract fun setRemoteJSDebugEnabled (Z)V
public abstract fun setStartSamplingProfilerOnInit (Z)V
}

public class com/facebook/react/modules/deviceinfo/DeviceInfoModule : com/facebook/fbreact/specs/NativeDeviceInfoSpec, com/facebook/react/bridge/LifecycleEventListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,36 @@ internal class DevInternalSettings(applicationContext: Context, private val list
DeveloperSettings, OnSharedPreferenceChangeListener {
private val preferences: SharedPreferences =
PreferenceManager.getDefaultSharedPreferences(applicationContext)
val packagerConnectionSettings: PackagerConnectionSettings
override val packagerConnectionSettings: PackagerConnectionSettings =
PackagerConnectionSettings(applicationContext)

init {
preferences.registerOnSharedPreferenceChangeListener(this)
packagerConnectionSettings = PackagerConnectionSettings(applicationContext)
}

override fun isFpsDebugEnabled(): Boolean = preferences.getBoolean(PREFS_FPS_DEBUG_KEY, false)
override var isFpsDebugEnabled: Boolean
get() = preferences.getBoolean(PREFS_FPS_DEBUG_KEY, false)
set(value) {
preferences.edit().putBoolean(PREFS_FPS_DEBUG_KEY, value).apply()
}

override fun isAnimationFpsDebugEnabled(): Boolean =
preferences.getBoolean(PREFS_ANIMATIONS_DEBUG_KEY, false)
override var isAnimationFpsDebugEnabled: Boolean
get() = preferences.getBoolean(PREFS_ANIMATIONS_DEBUG_KEY, false)
set(_) {
// not used
}

override fun isJSDevModeEnabled(): Boolean =
preferences.getBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, true)
override var isJSDevModeEnabled: Boolean
get() = preferences.getBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, true)
set(value) {
preferences.edit().putBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, value).apply()
}

override fun isJSMinifyEnabled(): Boolean =
preferences.getBoolean(PREFS_JS_MINIFY_DEBUG_KEY, false)
override var isJSMinifyEnabled: Boolean
get() = preferences.getBoolean(PREFS_JS_MINIFY_DEBUG_KEY, false)
set(_) {
// not used
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
if (listener != null) {
Expand All @@ -55,42 +68,35 @@ internal class DevInternalSettings(applicationContext: Context, private val list
}
}

override fun isElementInspectorEnabled(): Boolean =
preferences.getBoolean(PREFS_INSPECTOR_DEBUG_KEY, false)

override fun isDeviceDebugEnabled(): Boolean = ReactBuildConfig.DEBUG
override var isElementInspectorEnabled: Boolean
get() = preferences.getBoolean(PREFS_INSPECTOR_DEBUG_KEY, false)
set(value) {
preferences.edit().putBoolean(PREFS_INSPECTOR_DEBUG_KEY, value).apply()
}

override fun isRemoteJSDebugEnabled(): Boolean =
preferences.getBoolean(PREFS_REMOTE_JS_DEBUG_KEY, false)
override var isDeviceDebugEnabled: Boolean = ReactBuildConfig.DEBUG

override fun setRemoteJSDebugEnabled(remoteJSDebugEnabled: Boolean) {
preferences.edit().putBoolean(PREFS_REMOTE_JS_DEBUG_KEY, remoteJSDebugEnabled).apply()
}
override var isRemoteJSDebugEnabled: Boolean
get() = preferences.getBoolean(PREFS_REMOTE_JS_DEBUG_KEY, false)
set(value) {
preferences.edit().putBoolean(PREFS_REMOTE_JS_DEBUG_KEY, value).apply()
}

override fun isStartSamplingProfilerOnInit(): Boolean =
preferences.getBoolean(PREFS_START_SAMPLING_PROFILER_ON_INIT, false)
override var isStartSamplingProfilerOnInit: Boolean
get() = preferences.getBoolean(PREFS_START_SAMPLING_PROFILER_ON_INIT, false)
set(_) {
// not used
}

// Not supported.
override fun addMenuItem(title: String) = Unit

fun setElementInspectorEnabled(enabled: Boolean) {
preferences.edit().putBoolean(PREFS_INSPECTOR_DEBUG_KEY, enabled).apply()
}

var isHotModuleReplacementEnabled: Boolean
override var isHotModuleReplacementEnabled: Boolean
get() = preferences.getBoolean(PREFS_HOT_MODULE_REPLACEMENT_KEY, true)
set(enabled) {
preferences.edit().putBoolean(PREFS_HOT_MODULE_REPLACEMENT_KEY, enabled).apply()
}

fun setJSDevModeEnabled(value: Boolean) {
preferences.edit().putBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, value).apply()
}

fun setFpsDebugEnabled(enabled: Boolean) {
preferences.edit().putBoolean(PREFS_FPS_DEBUG_KEY, enabled).apply()
}

interface Listener {
fun onInternalSettingsChanged()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.facebook.react.devsupport.interfaces.RedBoxHandler;
import com.facebook.react.devsupport.interfaces.StackFrame;
import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
import com.facebook.react.packagerconnection.RequestHandler;
import com.facebook.react.packagerconnection.Responder;
import java.io.File;
Expand Down Expand Up @@ -107,7 +108,7 @@ public interface CallbackWithBundleLoader {
private boolean mDevLoadingViewVisible = false;
private int mPendingJSSplitBundleRequests = 0;
private @Nullable ReactContext mCurrentContext;
private final DevInternalSettings mDevSettings;
private final DeveloperSettings mDevSettings;
private boolean mIsReceiverRegistered = false;
private boolean mIsShakeDetectorStarted = false;
private boolean mIsDevSupportEnabled = false;
Expand Down Expand Up @@ -593,7 +594,7 @@ public boolean getDevSupportEnabled() {
}

@Override
public DevInternalSettings getDevSettings() {
public DeveloperSettings getDevSettings() {
return mDevSettings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.content.Context;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;

/**
* Interface for accessing and interacting with development features related to performance testing.
Expand All @@ -17,7 +18,7 @@
@Nullsafe(Nullsafe.Mode.LOCAL)
public final class PerftestDevSupportManager extends ReleaseDevSupportManager {
private final DevServerHelper mDevServerHelper;
private final DevInternalSettings mDevSettings;
private final DeveloperSettings mDevSettings;

public PerftestDevSupportManager(Context applicationContext) {
mDevSettings =
Expand All @@ -35,7 +36,7 @@ public void onInternalSettingsChanged() {}
}

@Override
public DevInternalSettings getDevSettings() {
public DeveloperSettings getDevSettings() {
return mDevSettings;
}

Expand Down

This file was deleted.

Loading
Loading