Project

General

Profile

« Previous | Next » 

Revision 36b9ee93

Added by Leszek Koltunski about 3 years ago

Attempt to programmatically catch the 'cube is sometimes not drawn' bug and report it to my server.

View differences:

src/main/java/org/distorted/scores/RubikScoresDownloader.java
19 19

  
20 20
package org.distorted.scores;
21 21

  
22
import android.app.Activity;
22 23
import android.content.pm.PackageInfo;
23 24
import android.content.pm.PackageManager;
24 25

  
......
50 51

  
51 52
  private static final int DOWNLOAD   = 0;
52 53
  private static final int SUBMIT     = 1;
53
  private static final int IDLE       = 2;
54
  private static final int ERROR      = 2;
55
  private static final int IDLE       = 3;
54 56

  
55 57
  private final String[] hex = {
56 58
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
......
99 101
  private static int mMode = IDLE;
100 102
  private static Receiver mReceiver;
101 103
  private static String mVersion;
104
  private static String mError = "";
102 105

  
103 106
///////////////////////////////////////////////////////////////////////////////////////////////////
104 107

  
......
381 384
    return url1 + "?" + url2 + "&h=" + hash;
382 385
    }
383 386

  
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

  
389
  private String constructErrorURL()
390
    {
391
    return "https://distorted.org/magic/cgi-bin/error.cgi?e="+URLencode(mError);
392
    }
393

  
384 394
///////////////////////////////////////////////////////////////////////////////////////////////////
385 395

  
386 396
  private boolean gottaDownload()
......
411 421
          success = network(constructSubmitURL());
412 422
          }
413 423
        }
424
      if( mMode==ERROR )
425
        {
426
        mRunning = true;
427
        success = network(constructErrorURL());
428
        }
414 429
      }
415 430
    catch( Exception e )
416 431
      {
417
      mReceiver.message("Exception downloading records: "+e.getMessage() );
418
      }
419

  
420
    if( mRunning )
421
      {
422
      success = fillValues();
423
      mRunning = false;
432
      if( mReceiver!=null )
433
        {
434
        mReceiver.message("Exception downloading records: "+e.getMessage() );
435
        }
424 436
      }
425 437

  
426
    if( success )
438
    if( mReceiver!=null )
427 439
      {
428
      mReceiver.receive(mCountry, mName, mTime);
440
      if( mRunning )
441
        {
442
        success = fillValues();
443
        mRunning = false;
444
        }
429 445

  
430
      if( mMode==SUBMIT )
446
      if( success )
431 447
        {
432
        RubikScores.getInstance().successfulSubmit();
448
        mReceiver.receive(mCountry, mName, mTime);
449

  
450
        if( mMode==SUBMIT )
451
          {
452
          RubikScores.getInstance().successfulSubmit();
453
          }
433 454
        }
434 455
      }
435 456
    }
......
464 485

  
465 486
///////////////////////////////////////////////////////////////////////////////////////////////////
466 487

  
467
  private void start(Receiver receiver, FragmentActivity act, int mode)
488
  private void start(Receiver receiver, Activity act, int mode)
468 489
    {
469 490
    mReceiver = receiver;
470 491
    mMode     = mode;
471 492

  
472 493
    try
473 494
      {
474
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
475
      mVersion = pInfo.versionName;
495
      if( act!=null )
496
        {
497
        PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
498
        mVersion = pInfo.versionName;
499
        }
476 500
      }
477 501
    catch (PackageManager.NameNotFoundException e)
478 502
      {
......
483 507
    networkThrd.start();
484 508
    }
485 509

  
510
///////////////////////////////////////////////////////////////////////////////////////////////////
511

  
512
  public void error(String error)
513
    {
514
    mError = error;
515
    start(null, null, ERROR);
516
    }
517

  
486 518
///////////////////////////////////////////////////////////////////////////////////////////////////
487 519

  
488 520
  public void download(Receiver receiver, FragmentActivity act)

Also available in: Unified diff