Revision 1fa125c2
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/config/ConfigObjectLibInterface.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
public class ConfigObjectLibInterface implements ObjectLibInterface |
32 | 32 |
{ |
33 |
public void onWinEffectFinished(String debug, int scrambleNum) { } |
|
33 |
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
|
|
34 | 34 |
public void onScrambleEffectFinished() { } |
35 | 35 |
public void onBeginRotation() { } |
36 | 36 |
public void onSolved() { } |
src/main/java/org/distorted/main/RubikObjectLibInterface.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
import org.distorted.library.message.EffectMessageSender; |
36 | 36 |
|
37 |
import org.distorted.network.RubikNetwork; |
|
37 | 38 |
import org.distorted.objectlib.BuildConfig; |
38 | 39 |
import org.distorted.objectlib.helpers.BlockController; |
39 | 40 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
... | ... | |
96 | 97 |
|
97 | 98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
98 | 99 |
|
99 |
private void reportRecord(RubikActivity act, String debug, int scrambleNum) |
|
100 |
private void reportRecord(RubikActivity act, long startTime, long endTime, String debug, int scrambleNum)
|
|
100 | 101 |
{ |
101 | 102 |
RubikScreenPlay play= (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
102 | 103 |
RubikScores scores = RubikScores.getInstance(); |
... | ... | |
116 | 117 |
} |
117 | 118 |
else |
118 | 119 |
{ |
120 |
long timeNow = System.currentTimeMillis(); |
|
121 |
long elapsed = timeNow - startTime; |
|
122 |
|
|
123 |
if( level>=9 && mNewRecord<300*level ) |
|
124 |
{ |
|
125 |
String suspicious ="start"+startTime+"end"+endTime+"elapsed"+elapsed+"obj"+objName+"level"+level+"record"+mNewRecord+"scrambles"+scrambleNum+debug; |
|
126 |
RubikNetwork network = RubikNetwork.getInstance(); |
|
127 |
network.suspicious(act,suspicious); |
|
128 |
} |
|
129 |
|
|
119 | 130 |
FirebaseAnalytics analytics = act.getAnalytics(); |
120 | 131 |
|
121 | 132 |
if( analytics!=null ) |
... | ... | |
183 | 194 |
|
184 | 195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
185 | 196 |
|
186 |
public void onWinEffectFinished(String debug, int scrambleNum) |
|
197 |
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum)
|
|
187 | 198 |
{ |
188 | 199 |
if( ScreenList.getCurrentScreen()== ScreenList.SOLV ) |
189 | 200 |
{ |
... | ... | |
191 | 202 |
Bundle bundle = new Bundle(); |
192 | 203 |
bundle.putLong("time", mNewRecord ); |
193 | 204 |
|
194 |
reportRecord(act,debug,scrambleNum); |
|
205 |
reportRecord(act,startTime,endTime,debug,scrambleNum);
|
|
195 | 206 |
requestReview(act); |
196 | 207 |
|
197 | 208 |
if( mIsNewRecord ) |
src/main/java/org/distorted/network/RubikNetwork.java | ||
---|---|---|
36 | 36 |
import androidx.fragment.app.FragmentActivity; |
37 | 37 |
|
38 | 38 |
import org.distorted.library.main.DistortedLibrary; |
39 |
import org.distorted.objects.RubikObject; |
|
40 | 39 |
import org.distorted.objects.RubikObjectList; |
41 | 40 |
|
42 | 41 |
import static org.distorted.objects.RubikObjectList.MAX_LEVEL; |
... | ... | |
57 | 56 |
private static final int DOWNLOAD = 0; |
58 | 57 |
private static final int SUBMIT = 1; |
59 | 58 |
private static final int DEBUG = 2; |
60 |
private static final int IDLE = 3; |
|
59 |
private static final int SUSPICIOUS = 3; |
|
60 |
private static final int IDLE = 4; |
|
61 | 61 |
|
62 | 62 |
private static final int REND_ADRENO= 0; |
63 | 63 |
private static final int REND_MALI = 1; |
... | ... | |
110 | 110 |
private static int mMode = IDLE; |
111 | 111 |
private static Receiver mReceiver; |
112 | 112 |
private static String mVersion; |
113 |
private static String mDebug; |
|
113 | 114 |
private static int mNumObjects; |
114 | 115 |
|
115 | 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
387 | 388 |
} |
388 | 389 |
} |
389 | 390 |
|
391 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
392 |
|
|
393 |
private void sendSuspicious() |
|
394 |
{ |
|
395 |
String url = constructSuspiciousURL(); |
|
396 |
|
|
397 |
try |
|
398 |
{ |
|
399 |
java.net.URL connectURL = new URL(url); |
|
400 |
HttpURLConnection conn = (HttpURLConnection)connectURL.openConnection(); |
|
401 |
|
|
402 |
conn.setDoInput(true); |
|
403 |
conn.setDoOutput(true); |
|
404 |
conn.setUseCaches(false); |
|
405 |
conn.setRequestMethod("GET"); |
|
406 |
conn.connect(); |
|
407 |
conn.getOutputStream().flush(); |
|
408 |
conn.getInputStream(); |
|
409 |
} |
|
410 |
catch( final Exception e ) |
|
411 |
{ |
|
412 |
// ignore |
|
413 |
} |
|
414 |
} |
|
415 |
|
|
390 | 416 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
391 | 417 |
|
392 | 418 |
private boolean network(String url) |
... | ... | |
439 | 465 |
return true; |
440 | 466 |
} |
441 | 467 |
|
468 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
469 |
|
|
470 |
private String constructSuspiciousURL() |
|
471 |
{ |
|
472 |
RubikScores scores = RubikScores.getInstance(); |
|
473 |
int deviceID= scores.getDeviceID(); |
|
474 |
String debug = URLencode(mDebug); |
|
475 |
|
|
476 |
String url="https://distorted.org/magic/cgi-bin/suspicious.cgi"; |
|
477 |
url += "?i="+deviceID+"&d="+debug; |
|
478 |
|
|
479 |
return url; |
|
480 |
} |
|
481 |
|
|
442 | 482 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
443 | 483 |
|
444 | 484 |
private String constructDebugURL() |
... | ... | |
460 | 500 |
return url; |
461 | 501 |
} |
462 | 502 |
|
463 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
464 |
|
|
465 |
private static String getObjectList() |
|
466 |
{ |
|
467 |
StringBuilder list = new StringBuilder(); |
|
468 |
|
|
469 |
for(int i=0; i<mNumObjects; i++) |
|
470 |
{ |
|
471 |
RubikObject object = RubikObjectList.getObject(i); |
|
472 |
|
|
473 |
if( object!=null ) |
|
474 |
{ |
|
475 |
if( i>0 ) list.append(','); |
|
476 |
list.append(object.getName()); |
|
477 |
} |
|
478 |
} |
|
479 |
|
|
480 |
return list.toString(); |
|
481 |
} |
|
482 |
|
|
483 | 503 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
484 | 504 |
|
485 | 505 |
private String constructDownloadURL() |
... | ... | |
552 | 572 |
if( mMode==SUBMIT ) |
553 | 573 |
{ |
554 | 574 |
mRunning = true; |
575 |
RubikScores scores = RubikScores.getInstance(); |
|
555 | 576 |
|
556 |
if( RubikScores.getInstance().thereAreUnsubmittedRecords() )
|
|
577 |
if( scores.thereAreUnsubmittedRecords() )
|
|
557 | 578 |
{ |
558 | 579 |
receiveValues = network(constructSubmitURL()); |
559 | 580 |
} |
... | ... | |
564 | 585 |
receiveValues = false; |
565 | 586 |
mRunning = false; |
566 | 587 |
} |
588 |
if( mMode==SUSPICIOUS ) |
|
589 |
{ |
|
590 |
sendSuspicious(); |
|
591 |
receiveValues = false; |
|
592 |
mRunning = false; |
|
593 |
} |
|
567 | 594 |
} |
568 | 595 |
catch( Exception e ) |
569 | 596 |
{ |
... | ... | |
656 | 683 |
{ |
657 | 684 |
start(null, act, DEBUG); |
658 | 685 |
} |
686 |
|
|
687 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
688 |
|
|
689 |
public void suspicious(AppCompatActivity act, String debug) |
|
690 |
{ |
|
691 |
mDebug = debug; |
|
692 |
start(null, act, SUSPICIOUS); |
|
693 |
} |
|
659 | 694 |
} |
src/main/java/org/distorted/tutorials/TutorialObjectLibInterface.java | ||
---|---|---|
41 | 41 |
mAct = new WeakReference<>(act); |
42 | 42 |
} |
43 | 43 |
|
44 |
public void onWinEffectFinished(String debug, int scrambleNum) { } |
|
44 |
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
|
|
45 | 45 |
public void onScrambleEffectFinished() { } |
46 | 46 |
public void onBeginRotation() { } |
47 | 47 |
public void onSolved() { } |
Also available in: Unified diff
Add debugging for the case when people submit suspicious records.