forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intercepting all redboxes in Android Ads Manager
Summary: Implement a handler to allow intercepting all RN redboxes in Android, including exceptions in both JS and Java. The handler is not open sourced, so there is only an open-source interface called **RedBoxHandler** in //fbandroid/java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/devsupport//, meantime there is an internal class called **FBRedBoxHandler**, which implements **RedBoxHandler** and is located in //fbandroid/java/com/facebook/fbreact/redboxhandler//, actually handles the exception information. The code structure is as follows: - **AdsManagerActivity** has a member variable of **FBRedBoxHandler**. - **AdsManagerActivity** passes this handler all the way down to the **DevSupportManagerImpl**, through** ReactInstanceManager**, **ReactInstanceManagerImpl**, **DevSupportManagerFactory**. - **DevSupportManagerImpl** intercepts the exceptions just before showing the redboxes, like this: mRedBoxDialog.setExceptionDetails(message, stack); mRedBoxDialog.setErrorCookie(errorCookie); if (mRedBoxHandler != null) { mRedBoxHandler.handleRedbox(message, stack); } mRedBoxDialog.show(); By now, the internal class just prints information for each redbox to logcat, including exception message and stack trace. Reviewed By: mkonicek Differential Revision: D3369064 fbshipit-source-id: 199012c4b6ecf4b3d3aff51a26c9c9901847b6fc
- Loading branch information
Siqi Liu
authored and
Morgan Pretty
committed
Aug 24, 2016
1 parent
db2b976
commit 327247d
Showing
8 changed files
with
177 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
package com.facebook.react.devsupport; | ||
|
||
import com.facebook.react.devsupport.StackTraceHelper.StackFrame; | ||
|
||
/** | ||
* Interface used by {@link DevSupportManagerImpl} to allow interception on any redboxes | ||
* during development and handling the information from the redbox. | ||
* The implementation should be passed by {@link #setRedBoxHandler} in {@link ReactInstanceManager}. | ||
*/ | ||
public interface RedBoxHandler { | ||
void handleRedbox(String title, StackFrame[] stack); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters