@@ -96,25 +96,21 @@ public BacktraceDatabase(Context context, BacktraceDatabaseSettings databaseSett
9696 throw new IllegalArgumentException ("Database settings or application context is null" );
9797 }
9898
99- if (databaseSettings .getDatabasePath () == null || databaseSettings .getDatabasePath ()
100- .isEmpty ()) {
99+ if (databaseSettings .getDatabasePath () == null || databaseSettings .getDatabasePath ().isEmpty ()) {
101100 throw new IllegalArgumentException ("Database path is null or empty" );
102101 }
103102
104103 if (!FileHelper .isFileExists (databaseSettings .getDatabasePath ())) {
105104 boolean createDirs = new File (databaseSettings .getDatabasePath ()).mkdirs ();
106105 if (!createDirs || !FileHelper .isFileExists (databaseSettings .getDatabasePath ())) {
107- throw new IllegalArgumentException ("Incorrect database path or application " +
108- "doesn't have permission to write to this path" );
106+ throw new IllegalArgumentException ("Incorrect database path or application " + "doesn't have permission to write to this path" );
109107 }
110108 }
111109
112110 this ._applicationContext = context ;
113111 this .databaseSettings = databaseSettings ;
114112 this .backtraceDatabaseContext = new BacktraceDatabaseContext (databaseSettings );
115- this .backtraceDatabaseFileContext = new BacktraceDatabaseFileContext (this .getDatabasePath (),
116- this .databaseSettings .getMaxDatabaseSize (), this .databaseSettings
117- .getMaxRecordCount ());
113+ this .backtraceDatabaseFileContext = new BacktraceDatabaseFileContext (this .getDatabasePath (), this .databaseSettings .getMaxDatabaseSize (), this .databaseSettings .getMaxRecordCount ());
118114 this .breadcrumbs = new BacktraceBreadcrumbs (getDatabasePath ());
119115 this .crashHandlerConfiguration = new CrashHandlerConfiguration ();
120116 }
@@ -140,8 +136,7 @@ public Boolean setupNativeIntegration(BacktraceBase client, BacktraceCredentials
140136 * @param credentials Backtrace credentials
141137 * @param enableClientSideUnwinding Enable client side unwinding
142138 */
143- public Boolean setupNativeIntegration (BacktraceBase client , BacktraceCredentials credentials ,
144- boolean enableClientSideUnwinding ) {
139+ public Boolean setupNativeIntegration (BacktraceBase client , BacktraceCredentials credentials , boolean enableClientSideUnwinding ) {
145140 return setupNativeIntegration (client , credentials , enableClientSideUnwinding , UnwindingMode .REMOTE_DUMPWITHOUTCRASH );
146141 }
147142
@@ -158,10 +153,10 @@ public void useNativeCommunication(NativeCommunication nativeCommunication) {
158153 * @param client Backtrace client
159154 * @param credentials Backtrace credentials
160155 * @param enableClientSideUnwinding Enable client side unwinding
161- * @param unwindingMode Unwinding mode to use for client side unwinding
156+ * @param unwindingMode Unwinding mode to use for client side
157+ * unwinding
162158 */
163- public Boolean setupNativeIntegration (BacktraceBase client , BacktraceCredentials credentials ,
164- boolean enableClientSideUnwinding , UnwindingMode unwindingMode ) {
159+ public Boolean setupNativeIntegration (BacktraceBase client , BacktraceCredentials credentials , boolean enableClientSideUnwinding , UnwindingMode unwindingMode ) {
165160 // avoid initialization when database doesn't exist
166161 if (_enable == false || getSettings () == null ) {
167162 return false ;
@@ -199,15 +194,7 @@ public Boolean setupNativeIntegration(BacktraceBase client, BacktraceCredentials
199194
200195 ApplicationInfo applicationInfo = _applicationContext .getApplicationInfo ();
201196
202- _enabledNativeIntegration =
203- nativeCommunication .initializeJavaCrashHandler (minidumpSubmissionUrl ,
204- crashpadDatabaseDirectory ,
205- this .crashHandlerConfiguration .getClassPath (),
206- keys ,
207- values ,
208- attachmentPaths ,
209- this .crashHandlerConfiguration .getCrashHandlerEnvironmentVariables (applicationInfo ).toArray (new String [0 ])
210- );
197+ _enabledNativeIntegration = nativeCommunication .initializeJavaCrashHandler (minidumpSubmissionUrl , crashpadDatabaseDirectory , this .crashHandlerConfiguration .getClassPath (), keys , values , attachmentPaths , this .crashHandlerConfiguration .getCrashHandlerEnvironmentVariables (applicationInfo ).toArray (new String [0 ]));
211198
212199 if (_enabledNativeIntegration && this .breadcrumbs .isEnabled ()) {
213200 this .breadcrumbs .setOnSuccessfulBreadcrumbAddEventListener (breadcrumbId -> {
@@ -265,8 +252,7 @@ public void start() {
265252
266253 this .removeOrphaned ();
267254
268- if (databaseSettings .getRetryBehavior () == RetryBehavior .ByInterval || databaseSettings
269- .isAutoSendMode ()) {
255+ if (databaseSettings .getRetryBehavior () == RetryBehavior .ByInterval || databaseSettings .isAutoSendMode ()) {
270256 setupTimer ();
271257 }
272258
@@ -284,20 +270,18 @@ public BacktraceDatabaseSettings getSettings() {
284270
285271 private void setupTimer () {
286272 _timer = new Timer ();
287- _timer .scheduleAtFixedRate (new TimerTask () {
273+ _timer .schedule (new TimerTask () {
288274 @ Override
289275 public void run () {
290276 String dateTimeNow = Calendar .getInstance ().getTime ().toString ();
291277 BacktraceLogger .d (LOG_TAG , "Timer - " + dateTimeNow );
292278 if (backtraceDatabaseContext == null ) {
293- BacktraceLogger .w (LOG_TAG , "Timer - database context is null: " +
294- dateTimeNow );
279+ BacktraceLogger .w (LOG_TAG , "Timer - database context is null: " + dateTimeNow );
295280 return ;
296281 }
297282
298283 if (backtraceDatabaseContext .isEmpty ()) {
299- BacktraceLogger .d (LOG_TAG , "Timer - database is empty (no records): " +
300- dateTimeNow );
284+ BacktraceLogger .d (LOG_TAG , "Timer - database is empty (no records): " + dateTimeNow );
301285 return ;
302286 }
303287
@@ -317,8 +301,7 @@ public void run() {
317301 final CountDownLatch threadWaiter = new CountDownLatch (1 );
318302 BacktraceData backtraceData = record .getBacktraceData ();
319303 if (backtraceData == null || backtraceData .getReport () == null ) {
320- BacktraceLogger .d (LOG_TAG , "Timer - backtrace data or report is null - " +
321- "deleting record" );
304+ BacktraceLogger .d (LOG_TAG , "Timer - backtrace data or report is null - " + "deleting record" );
322305 delete (record );
323306 } else {
324307 final BacktraceDatabaseRecord currentRecord = record ;
@@ -331,17 +314,16 @@ public void onEvent(BacktraceResult backtraceResult) {
331314 } else {
332315 BacktraceLogger .d (LOG_TAG , "Timer - closing record" );
333316 currentRecord .close ();
334- // backtraceDatabaseContext.incrementBatchRetry(); TODO: consider another way to remove some records after few retries
317+ // backtraceDatabaseContext.incrementBatchRetry(); TODO: consider another way to
318+ // remove some records after few retries
335319 }
336320 threadWaiter .countDown ();
337321 }
338322 });
339323 try {
340324 threadWaiter .await ();
341325 } catch (Exception ex ) {
342- BacktraceLogger .e (LOG_TAG ,
343- "Error during waiting for result in Timer" , ex
344- );
326+ BacktraceLogger .e (LOG_TAG , "Error during waiting for result in Timer" , ex );
345327 }
346328 if (currentRecord .valid () && !currentRecord .locked ) {
347329 BacktraceLogger .d (LOG_TAG , "Timer - record is valid and unlocked" );
@@ -354,13 +336,12 @@ record = backtraceDatabaseContext.first();
354336 _timerBackgroundWork = false ;
355337 setupTimer ();
356338 }
357- }, databaseSettings .getRetryInterval () * 1000 , databaseSettings . getRetryInterval () * 1000 );
339+ }, databaseSettings .getRetryInterval () * 1000L );
358340 }
359341
360342 public void flush () {
361343 if (this .BacktraceApi == null ) {
362- throw new IllegalArgumentException ("BacktraceApi is required " +
363- "if you want to use Flush method" );
344+ throw new IllegalArgumentException ("BacktraceApi is required " + "if you want to use Flush method" );
364345 }
365346
366347 BacktraceDatabaseRecord record = backtraceDatabaseContext .first ();
@@ -396,13 +377,11 @@ public boolean validConsistency() {
396377 return backtraceDatabaseFileContext .validFileConsistency ();
397378 }
398379
399- public BacktraceDatabaseRecord add (BacktraceReport backtraceReport , Map <String , Object >
400- attributes ) {
380+ public BacktraceDatabaseRecord add (BacktraceReport backtraceReport , Map <String , Object > attributes ) {
401381 return add (backtraceReport , attributes , false );
402382 }
403383
404- public BacktraceDatabaseRecord add (BacktraceReport backtraceReport , Map <String , Object >
405- attributes , boolean isProguardEnabled ) {
384+ public BacktraceDatabaseRecord add (BacktraceReport backtraceReport , Map <String , Object > attributes , boolean isProguardEnabled ) {
406385 if (!this ._enable || backtraceReport == null ) {
407386 return null ;
408387 }
@@ -446,8 +425,7 @@ private void loadReports() {
446425
447426 final long endLoadingReportsTime = System .currentTimeMillis ();
448427
449- BacktraceLogger .d (LOG_TAG , "Loading " + backtraceDatabaseContext .count () +
450- " reports took " + (endLoadingReportsTime - startLoadingReportsTime ) + " milliseconds" );
428+ BacktraceLogger .d (LOG_TAG , "Loading " + backtraceDatabaseContext .count () + " reports took " + (endLoadingReportsTime - startLoadingReportsTime ) + " milliseconds" );
451429 }
452430
453431 private void loadReportsToDbContext () {
@@ -482,19 +460,16 @@ private boolean validateDatabaseSize() {
482460 // Check how many records are stored in database
483461 // Remove in case when we want to store one more than expected number
484462 // If record count == 0 then we ignore this condition
485- if (backtraceDatabaseContext .count () + 1 > databaseSettings .getMaxRecordCount () &&
486- databaseSettings .getMaxRecordCount () != 0 ) {
463+ if (backtraceDatabaseContext .count () + 1 > databaseSettings .getMaxRecordCount () && databaseSettings .getMaxRecordCount () != 0 ) {
487464 if (!backtraceDatabaseContext .removeOldestRecord ()) {
488465 BacktraceLogger .e (LOG_TAG , "Can't remove last record. Database size is invalid" );
489466 return false ;
490467 }
491468 }
492469
493- if (databaseSettings .getMaxDatabaseSize () != 0 && backtraceDatabaseContext
494- .getDatabaseSize () > databaseSettings .getMaxDatabaseSize ()) {
470+ if (databaseSettings .getMaxDatabaseSize () != 0 && backtraceDatabaseContext .getDatabaseSize () > databaseSettings .getMaxDatabaseSize ()) {
495471 int deletePolicyRetry = 5 ;
496- while (backtraceDatabaseContext .getDatabaseSize () > databaseSettings
497- .getMaxDatabaseSize ()) {
472+ while (backtraceDatabaseContext .getDatabaseSize () > databaseSettings .getMaxDatabaseSize ()) {
498473 backtraceDatabaseContext .removeOldestRecord ();
499474 deletePolicyRetry --; // avoid infinity loop
500475 if (deletePolicyRetry == 0 ) {
0 commit comments