Revision 9d4c38eb
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/network/RubikNetwork.java | ||
---|---|---|
56 | 56 |
private static final int DEBUG = 2; |
57 | 57 |
private static final int IDLE = 3; |
58 | 58 |
|
59 |
private static final int REND_ADRENO = 0; |
|
60 |
private static final int REND_MALI = 1; |
|
61 |
private static final int REND_POWER = 2; |
|
62 |
private static final int REND_OTHER = 3; |
|
63 |
|
|
59 | 64 |
private final String[] hex = { |
60 | 65 |
"%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", |
61 | 66 |
"%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f", |
... | ... | |
249 | 254 |
} |
250 | 255 |
} |
251 | 256 |
|
257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
258 |
|
|
259 |
private int getRendererType(String renderer) |
|
260 |
{ |
|
261 |
if( renderer.contains("Adreno") ) return REND_ADRENO; |
|
262 |
if( renderer.contains("Mali") ) return REND_MALI; |
|
263 |
if( renderer.contains("PowerVR") ) return REND_POWER; |
|
264 |
|
|
265 |
return REND_OTHER; |
|
266 |
} |
|
267 |
|
|
268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 |
|
|
270 |
private String parseRenderer(final int type, String renderer) |
|
271 |
{ |
|
272 |
if( type==REND_ADRENO || type==REND_POWER ) |
|
273 |
{ |
|
274 |
int lastSpace = renderer.lastIndexOf(' '); |
|
275 |
String ret = renderer.substring(lastSpace+1); |
|
276 |
return URLencode(ret); |
|
277 |
} |
|
278 |
|
|
279 |
if( type==REND_MALI ) |
|
280 |
{ |
|
281 |
int firstHyphen = renderer.indexOf('-'); |
|
282 |
String ret = renderer.substring(firstHyphen+1); |
|
283 |
return URLencode(ret); |
|
284 |
} |
|
285 |
|
|
286 |
return "other"; |
|
287 |
} |
|
288 |
|
|
289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
290 |
|
|
291 |
private String parseVersion(final int type, String version) |
|
292 |
{ |
|
293 |
switch(type) |
|
294 |
{ |
|
295 |
case REND_ADRENO: int aMonkey = version.indexOf('@'); |
|
296 |
int aDot = version.indexOf('.', aMonkey); |
|
297 |
String ret1 = aDot>=3 ? version.substring(aDot-3,aDot) : ""; |
|
298 |
return URLencode(ret1); |
|
299 |
case REND_MALI : int mV1 = version.indexOf("v1"); |
|
300 |
int mHyphen = version.indexOf('-', mV1); |
|
301 |
String ret2 = mHyphen>mV1+3 && mV1>=0 ? version.substring(mV1+3,mHyphen) : ""; |
|
302 |
return URLencode(ret2); |
|
303 |
case REND_POWER : int pMonkey = version.indexOf('@'); |
|
304 |
int pSpace = version.lastIndexOf(' '); |
|
305 |
String ret3 = pSpace>=0 && pMonkey>pSpace+1 ? version.substring(pSpace+1,pMonkey) : ""; |
|
306 |
return URLencode(ret3); |
|
307 |
default : return ""; |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
252 | 311 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
253 | 312 |
|
254 | 313 |
private String URLencode(String s) |
... | ... | |
422 | 481 |
long epoch = System.currentTimeMillis(); |
423 | 482 |
String salt = "cuboid"; |
424 | 483 |
|
484 |
String renderer = DistortedLibrary.getDriverRenderer(); |
|
485 |
String version = DistortedLibrary.getDriverVersion(); |
|
486 |
|
|
487 |
int type = getRendererType(renderer); |
|
488 |
renderer = parseRenderer(type,renderer); |
|
489 |
version = parseVersion(type,version); |
|
490 |
|
|
425 | 491 |
String url1="https://distorted.org/magic/cgi-bin/submit.cgi"; |
426 | 492 |
String url2 = "n="+name+"&v="+veri+"&r="+numRuns+"&p="+numPlay+"&i="+deviceID+"&e="+mVersion+"d"; |
493 |
url2 += "&d="+renderer+"&s="+version; |
|
427 | 494 |
url2 += reclist+"&c="+country+"&f="+epoch+"&oo="+ ObjectList.getObjectList(); |
428 | 495 |
url2 += "&min=0&max="+MAX_LEVEL+"&lo="+MAX_PLACES; |
429 | 496 |
String hash = computeHash( url2, salt.getBytes() ); |
Also available in: Unified diff
Include info about renderer and version in the submit packet.