Skip to content

Commit

Permalink
fix(🤖): Regression with java exceptions on Android (Shopify#2808)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Dec 15, 2024
1 parent 1908603 commit 9ce6660
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Choreographer;

import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
Expand All @@ -27,6 +25,8 @@ public class PlatformContext {

private final String TAG = "PlatformContext";

private final Handler mainHandler = new Handler(Looper.getMainLooper());

public PlatformContext(ReactContext reactContext) {
mContext = reactContext;
mHybridData = initHybrid(reactContext.getResources().getDisplayMetrics().density);
Expand Down Expand Up @@ -105,6 +105,16 @@ protected void finalize() throws Throwable {
super.finalize();
}

@DoNotStrip
public void raise(final String message) {
mainHandler.post(new Runnable() {
@Override
public void run() {
mContext.handleException(new Exception(message));
}
});
}

// Private c++ native methods
private native HybridData initHybrid(float pixelDensity);
}
}

0 comments on commit 9ce6660

Please sign in to comment.