-
public class InstrumentUtility
-
-
Field Summary
Fields Modifier and Type Field Description private final String
ANALYSIS_REPORT_PREFIX
private final String
ANR_REPORT_PREFIX
private final String
CRASH_REPORT_PREFIX
private final String
CRASH_SHIELD_PREFIX
private final String
THREAD_CHECK_PREFIX
private final String
ERROR_REPORT_PREFIX
public final static InstrumentUtility
INSTANCE
-
Method Summary
Modifier and Type Method Description final static String
getCause(Throwable e)
Get the cause of the raised exception. final static String
getStackTrace(Throwable e)
Get the iterated call stack traces of the raised exception. final static String
getStackTrace(Thread thread)
Get the stack trace of the input Thread. final static Boolean
isSDKRelatedException(Throwable e)
Check whether a Throwable is related to Facebook SDK by looking at iterated stack traces and return true if one of the traces has prefix "com.facebook". final static Boolean
isSDKRelatedThread(Thread thread)
Check whether an Thread is related to Facebook SDK by looking at iterated stack traces final static Array<File>
listAnrReportFiles()
Get the list of anr report files from instrument report directory defined in InstrumentUtility.getInstrumentReportDir method. final static Array<File>
listExceptionAnalysisReportFiles()
Get the list of exception analysis report files from instrument report directory defined in InstrumentUtility.getInstrumentReportDir method. final static Array<File>
listExceptionReportFiles()
Get the list of exception report files from instrument report directory defined in method. final static JSONObject
readFile(String filename, Boolean deleteOnException)
Read the content from the file which is denoted by filename and the directory is the instrument report directory defined in InstrumentUtility.getInstrumentReportDir method. final static Unit
writeFile(String filename, String content)
Write the content to the file which is denoted by filename and the file will be put in instrument report directory defined in InstrumentUtility.getInstrumentReportDir method. final static Boolean
deleteFile(String filename)
Deletes the cache file under instrument report directory. final static Unit
sendReports(String key, JSONArray reports, GraphRequest.Callback callback)
Create Graph Request for Instrument reports and send the reports to Facebook. final static File
getInstrumentReportDir()
Get the instrument directory for report if the directory exists. final String
getANALYSIS_REPORT_PREFIX()
final String
getANR_REPORT_PREFIX()
final String
getCRASH_REPORT_PREFIX()
final String
getCRASH_SHIELD_PREFIX()
final String
getTHREAD_CHECK_PREFIX()
final String
getERROR_REPORT_PREFIX()
-
-
Method Detail
-
getCause
final static String getCause(Throwable e)
Get the cause of the raised exception.
- Parameters:
e
- The Throwable containing the exception that was raised
-
getStackTrace
final static String getStackTrace(Throwable e)
Get the iterated call stack traces of the raised exception.
- Parameters:
e
- The Throwable containing the exception that was raised
-
getStackTrace
final static String getStackTrace(Thread thread)
Get the stack trace of the input Thread.
- Parameters:
thread
- The Thread to obtain the stack trace
-
isSDKRelatedException
final static Boolean isSDKRelatedException(Throwable e)
Check whether a Throwable is related to Facebook SDK by looking at iterated stack traces and return true if one of the traces has prefix "com.facebook".
- Parameters:
e
- The Throwable containing the exception that was raised
-
isSDKRelatedThread
final static Boolean isSDKRelatedThread(Thread thread)
Check whether an Thread is related to Facebook SDK by looking at iterated stack traces
- Parameters:
thread
- The Thread to obtain the stack trace
-
listAnrReportFiles
final static Array<File> listAnrReportFiles()
Get the list of anr report files from instrument report directory defined in InstrumentUtility.getInstrumentReportDir method.
Note that the function should be called after FacebookSdk is initialized. Otherwise, exception FacebookSdkNotInitializedException will be thrown.
-
listExceptionAnalysisReportFiles
final static Array<File> listExceptionAnalysisReportFiles()
Get the list of exception analysis report files from instrument report directory defined in InstrumentUtility.getInstrumentReportDir method.
Note that the function should be called after FacebookSdk is initialized. Otherwise, exception FacebookSdkNotInitializedException will be thrown.
-
listExceptionReportFiles
final static Array<File> listExceptionReportFiles()
-
readFile
final static JSONObject readFile(String filename, Boolean deleteOnException)
Read the content from the file which is denoted by filename and the directory is the instrument report directory defined in InstrumentUtility.getInstrumentReportDir method.
Note that the function should be called after FacebookSdk is initialized. Otherwise, exception FacebookSdkNotInitializedException will be thrown.
-
writeFile
final static Unit writeFile(String filename, String content)
Write the content to the file which is denoted by filename and the file will be put in instrument report directory defined in InstrumentUtility.getInstrumentReportDir method.
Note that the function should be called after FacebookSdk is initialized. Otherwise, exception FacebookSdkNotInitializedException will be thrown.
-
deleteFile
final static Boolean deleteFile(String filename)
Deletes the cache file under instrument report directory. If the instrument report directory exists and the file exists under the directory, the file will be deleted.
Note that the function should be called after FacebookSdk is initialized. Otherwise, exception FacebookSdkNotInitializedException will be thrown.
-
sendReports
final static Unit sendReports(String key, JSONArray reports, GraphRequest.Callback callback)
Create Graph Request for Instrument reports and send the reports to Facebook.
-
getInstrumentReportDir
final static File getInstrumentReportDir()
Get the instrument directory for report if the directory exists. If the directory doesn't exist, will attempt to create the directory. Note that, the instrument directory is under cache directory of the Application.
Note that the function should be called after FacebookSdk is initialized. Otherwise, exception FacebookSdkNotInitializedException will be thrown.
-
getANALYSIS_REPORT_PREFIX
final String getANALYSIS_REPORT_PREFIX()
-
getANR_REPORT_PREFIX
final String getANR_REPORT_PREFIX()
-
getCRASH_REPORT_PREFIX
final String getCRASH_REPORT_PREFIX()
-
getCRASH_SHIELD_PREFIX
final String getCRASH_SHIELD_PREFIX()
-
getTHREAD_CHECK_PREFIX
final String getTHREAD_CHECK_PREFIX()
-
getERROR_REPORT_PREFIX
final String getERROR_REPORT_PREFIX()
-
-
-
-