@@ -43,6 +43,7 @@ of this software and associated documentation files (the "Software"), to deal
43
43
import android .os .ParcelFileDescriptor ;
44
44
import android .os .Vibrator ;
45
45
import android .preference .PreferenceManager .OnActivityResultListener ;
46
+ import android .provider .Settings ;
46
47
import android .util .DisplayMetrics ;
47
48
import android .util .Log ;
48
49
import android .view .Display ;
@@ -57,6 +58,7 @@ of this software and associated documentation files (the "Software"), to deal
57
58
import java .io .File ;
58
59
import java .io .FilenameFilter ;
59
60
import java .io .UnsupportedEncodingException ;
61
+ import java .lang .reflect .Field ;
60
62
import java .lang .reflect .InvocationTargetException ;
61
63
import java .lang .reflect .Method ;
62
64
import java .util .LinkedHashSet ;
@@ -316,6 +318,7 @@ public static String getVersion() {
316
318
String version = Cocos2dxActivity .getContext ().getPackageManager ().getPackageInfo (Cocos2dxActivity .getContext ().getPackageName (), 0 ).versionName ;
317
319
return version ;
318
320
} catch (Exception e ) {
321
+ Log .e (TAG , "Exception: " + e .getMessage ());
319
322
return "" ;
320
323
}
321
324
}
@@ -325,17 +328,63 @@ public static String getBuildVersion() {
325
328
int version = Cocos2dxActivity .getContext ().getPackageManager ().getPackageInfo (Cocos2dxActivity .getContext ().getPackageName (), 0 ).versionCode ;
326
329
return Integer .toString (version );
327
330
} catch (Exception e ) {
331
+ Log .e (TAG , "Exception: " + e .getMessage ());
328
332
return "" ;
329
333
}
330
334
}
331
335
332
336
public static String getCopyrightString () {
333
337
return "Copyright (c) 2017" ;
334
- // try {
335
- // return "";
336
- // } catch(Exception e) {
337
- // return "";
338
- // }
338
+ }
339
+
340
+ private static String capitalize (String s ) {
341
+ if (s == null || s .length () == 0 ) {
342
+ return "" ;
343
+ }
344
+ char first = s .charAt (0 );
345
+ if (Character .isUpperCase (first )) {
346
+ return s ;
347
+ } else {
348
+ return Character .toUpperCase (first ) + s .substring (1 );
349
+ }
350
+ }
351
+
352
+ public static String getModelString () {
353
+ try {
354
+ String str = Build .MODEL ;
355
+ if (! Build .MODEL .startsWith (Build .MANUFACTURER )) {
356
+ str = Build .MANUFACTURER + " " + Build .MODEL ;
357
+ }
358
+ str = capitalize (str );
359
+ Log .d (TAG , "Device Model: " + str );
360
+ return str ;
361
+ } catch (Exception e ) {
362
+ Log .e (TAG , "Exception: " + e .getMessage ());
363
+ return "" ;
364
+ }
365
+ }
366
+
367
+ public static String getPlatformString () {
368
+ try {
369
+ Field [] fields = Build .VERSION_CODES .class .getFields ();
370
+ String str = fields [Build .VERSION .SDK_INT + 1 ].getName ();
371
+ str += " " + Build .VERSION .RELEASE ;
372
+ Log .d (TAG , "Platform String:" + str );
373
+ return str ;
374
+ } catch (Exception e ) {
375
+ Log .e (TAG , "Exception: " + e .getMessage ());
376
+ return "" ;
377
+ }
378
+ }
379
+
380
+ public static String getDeviceID () {
381
+ try {
382
+ String deviceId = Settings .Secure .getString (Cocos2dxActivity .getContext ().getContentResolver (), Settings .Secure .ANDROID_ID );
383
+ return deviceId ;
384
+ } catch (Exception e ) {
385
+ Log .e (TAG , "Exception: " + e .getMessage ());
386
+ return "" ;
387
+ }
339
388
}
340
389
341
390
public static boolean openURL (String url ) {
0 commit comments