47
47
import java .util .ArrayList ;
48
48
import java .util .List ;
49
49
import java .util .Locale ;
50
- import java .util .UUID ;
51
50
52
51
/**
53
52
* Created by [email protected] on 2016/4/6.
@@ -61,18 +60,8 @@ public class AppUtils {
61
60
private static String mVersionName = "" ;
62
61
private static int mVersionCode = -1 ;
63
62
64
- // Hardware version
65
- private static String mHwVersionName = "" ;
66
- private static int mHwVersionCode = -1 ;
67
-
68
63
// Firmware version
69
- private static String mSwVersionName = "" ;
70
- private static int mSwVersionCode = -1 ;
71
-
72
- // Product
73
- private static String mProduceName = "" ;
74
- private static String mProduceId = "" ;
75
- private static String mPlatform = "" ;
64
+ private static String mFwVersion = "" ;
76
65
77
66
// MAC
78
67
private static String mEth0Mac = "" ;
@@ -93,8 +82,8 @@ public class AppUtils {
93
82
/**
94
83
* Is first run
95
84
*
96
- * @param context
97
- * @return
85
+ * @param context Context
86
+ * @return true: First run, false: Not the first time
98
87
*/
99
88
public static boolean isFirstRun (Context context ) {
100
89
boolean isFirst = SPUtils .getInstance (context ).getData (KEY_IS_FIRST , true );
@@ -145,105 +134,16 @@ public static int getVersionCode(Context context) {
145
134
}
146
135
147
136
/**
148
- * Get product name
149
- *
150
- * @return product name
151
- */
152
- public static String getProductName () {
153
- if (TextUtils .isEmpty (mProduceName )) {
154
- mProduceName = AppUtils .getProperty ("ro.product.model" , "" );
155
- }
156
- return mProduceName ;
157
- }
158
-
159
- /**
160
- * Get chip platform
161
- *
162
- * @return platform
163
- */
164
- public static String getPlatform () {
165
- if (TextUtils .isEmpty (mPlatform )) {
166
- mPlatform = AppUtils .getProperty ("ro.product.board" , "" );
167
- }
168
- return mPlatform ;
169
- }
170
-
171
- /**
172
- * Get product id
173
- *
174
- * @return product id
175
- */
176
- public static String getProductId () {
177
- if (TextUtils .isEmpty (mProduceId )) {
178
- mProduceId = AppUtils .getProperty ("ro.topband.product.id" , "" );
179
- }
180
- return mProduceId ;
181
- }
182
-
183
- /**
184
- * Get hardware version code
185
- *
186
- * @return version code
187
- */
188
- public static int getHwVersionCode () {
189
- if (-1 == mHwVersionCode ) {
190
- int versionCode = 0 ;
191
- String value = getHwVersionName ();
192
- if (!TextUtils .isEmpty (value )) {
193
- String [] arr = value .split ("-" );
194
- if (arr .length > 0 ) {
195
- String str = arr [0 ].replace ("." , "" );
196
- mHwVersionCode = Integer .parseInt (str );
197
- }
198
- }
199
- }
200
- return mHwVersionCode ;
201
- }
202
-
203
- /**
204
- * Get hardware version name
205
- *
206
- * @return version name
207
- */
208
- public static String getHwVersionName () {
209
- if (TextUtils .isEmpty (mHwVersionName )) {
210
- mHwVersionName = AppUtils .getProperty ("ro.topband.hw.version" , "" );
211
- }
212
- return mHwVersionName ;
213
- }
214
-
215
- /**
216
- * Get firmware version code
217
- *
218
- * @return version code
219
- */
220
- public static int getSwVersionCode () {
221
- if (-1 == mSwVersionCode ) {
222
- String value = AppUtils .getProperty ("ro.topband.sw.versioncode" , "0" );
223
- mSwVersionCode = Integer .parseInt (value );
224
- }
225
- return mSwVersionCode ;
226
- }
227
-
228
- /**
229
- * Get firmware version name
230
- *
231
- * @return version name
232
- */
233
- public static String getSwVersionName () {
234
- if (TextUtils .isEmpty (mSwVersionName )) {
235
- mSwVersionName = AppUtils .getProperty ("ro.topband.sw.version" , "1.0.0" );
236
- }
237
- return mSwVersionName ;
238
- }
239
-
240
- /**
241
- * Get Android version
137
+ * Get firmware version
242
138
*
243
139
* @return version
244
140
*/
245
- public static String getAndroidVersion () {
246
- return AppUtils .getProperty ("ro.build.version.release" , "" );
141
+ public static String getFwVersion () {
142
+ if (TextUtils .isEmpty (mFwVersion )) {
143
+ mFwVersion = getProperty ("ro.fw.version" ,
144
+ getProperty ("ro.topband.sw.version" , "1.0.0" ));
145
+ }
146
+ return mFwVersion ;
247
147
}
248
148
249
149
/**
@@ -255,7 +155,7 @@ public static String getAndroidVersion() {
255
155
public static String getSerialNo () {
256
156
String sn = android .os .Build .SERIAL ;
257
157
if (TextUtils .isEmpty (sn )) {
258
- sn = AppUtils . getProperty ("ro.serialno" , "" );
158
+ sn = getProperty ("ro.serialno" , "" );
259
159
if (TextUtils .isEmpty (sn )) {
260
160
sn = "unknown" ;
261
161
}
@@ -329,7 +229,7 @@ public static String getLanguage() {
329
229
* Whether the network is connected
330
230
*
331
231
* @param context Context
332
- * @return true/ false
232
+ * @return true: connected, false: disconnected
333
233
*/
334
234
public static boolean isConnNetWork (Context context ) {
335
235
ConnectivityManager conManager = (ConnectivityManager ) context .
@@ -342,7 +242,7 @@ public static boolean isConnNetWork(Context context) {
342
242
* Whether WiFi is connected
343
243
*
344
244
* @param context Context
345
- * @return true/ false
245
+ * @return true: connected, false: disconnected
346
246
*/
347
247
public static boolean isWifiConnected (Context context ) {
348
248
ConnectivityManager conManager = (ConnectivityManager ) context .
@@ -354,8 +254,8 @@ public static boolean isWifiConnected(Context context) {
354
254
/**
355
255
* Get Ethernet MAC
356
256
*
357
- * @param context
358
- * @return
257
+ * @param context Context
258
+ * @return Mac
359
259
*/
360
260
public static String getEth0Mac (Context context ) {
361
261
if (TextUtils .isEmpty (mEth0Mac )) {
@@ -381,8 +281,8 @@ public static String getEth0Mac(Context context) {
381
281
/**
382
282
* Get WiFi MAC
383
283
*
384
- * @param context
385
- * @return
284
+ * @param context Context
285
+ * @return Mac
386
286
*/
387
287
@ SuppressLint ("HardwareIds" )
388
288
public static String getWifiMac (Context context ) {
@@ -398,8 +298,8 @@ public static String getWifiMac(Context context) {
398
298
/**
399
299
* Get MAC, get the Ethernet MAC first, then get the WiFi MAC if it is empty.
400
300
*
401
- * @param context
402
- * @return
301
+ * @param context Context
302
+ * @return Mac
403
303
*/
404
304
public static String getMac (Context context ) {
405
305
if (TextUtils .isEmpty (mMac )) {
@@ -414,8 +314,8 @@ public static String getMac(Context context) {
414
314
/**
415
315
* Get the MAC with the colon removed
416
316
*
417
- * @param context
418
- * @return
317
+ * @param context Context
318
+ * @return Mac
419
319
*/
420
320
public static String getMacNoColon (Context context ) {
421
321
if (TextUtils .isEmpty (mMacNoColon )) {
@@ -491,15 +391,6 @@ public static void setProperty(String key, String value) {
491
391
}
492
392
}
493
393
494
- /**
495
- * Get UUID
496
- *
497
- * @return UUID
498
- */
499
- public static String getUUID () {
500
- return UUID .randomUUID ().toString ().replace ("-" , "" );
501
- }
502
-
503
394
private static boolean isExternalStorageMounted () {
504
395
return Environment .MEDIA_MOUNTED .equals (Environment .getExternalStorageState ());
505
396
}
@@ -688,7 +579,7 @@ private static List<String> getStorageVolumeList(Context context) {
688
579
/**
689
580
* reboot
690
581
*
691
- * @param context
582
+ * @param context Context
692
583
*/
693
584
public static void reboot (Context context ) {
694
585
Intent intent = new Intent (Intent .ACTION_REBOOT );
@@ -701,7 +592,7 @@ public static void reboot(Context context) {
701
592
/**
702
593
* shutdown
703
594
*
704
- * @param context
595
+ * @param context Context
705
596
*/
706
597
public static void shutdown (Context context ) {
707
598
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
@@ -720,8 +611,8 @@ public static void shutdown(Context context) {
720
611
/**
721
612
* start app
722
613
*
723
- * @param context
724
- * @param packageName
614
+ * @param context Context
615
+ * @param packageName PackageName
725
616
*/
726
617
public static void startApp (@ NonNull Context context , @ NonNull String packageName ) {
727
618
Intent intent = context .getPackageManager ()
0 commit comments