23
23
*/
24
24
public final class RomUtils {
25
25
26
- public static final String ROM_HUAWEI = "huawei" ;
27
- public static final String ROM_VIVO = "vivo" ;
28
- public static final String ROM_XIAOMI = "xiaomi" ;
29
- public static final String ROM_OPPO = "oppo" ;
26
+ public static final String [] ROM_HUAWEI = { "huawei" } ;
27
+ public static final String [] ROM_VIVO = { "vivo" } ;
28
+ public static final String [] ROM_XIAOMI = { "xiaomi" } ;
29
+ public static final String [] ROM_OPPO = { "oppo" } ;
30
30
public static final String [] ROM_LEECO = {"leeco" , "letv" };
31
31
public static final String [] ROM_360 = {"360" , "qiku" };
32
- public static final String ROM_ZTE = "zte" ;
33
- public static final String ROM_ONEPLUS = "oneplus" ;
34
- public static final String ROM_NUBIA = "nubia" ;
32
+ public static final String [] ROM_ZTE = { "zte" } ;
33
+ public static final String [] ROM_ONEPLUS = { "oneplus" } ;
34
+ public static final String [] ROM_NUBIA = { "nubia" } ;
35
35
36
36
public static final String [] ROM_COOLPAD = {"coolpad" , "yulong" };
37
37
public static final String [] ROM_LG = {"lg" , "lge" };
38
- public static final String ROM_GOOGLE = "google" ;
39
- public static final String ROM_SAMSUNG = "samsung" ;
40
- public static final String ROM_MEIZU = "meizu" ;
41
- public static final String ROM_LENOVO = "lenovo" ;
42
- public static final String ROM_SMARTISAN = "smartisan" ;
43
- public static final String ROM_HTC = "htc" ;
44
- public static final String ROM_SONY = "sony" ;
45
- public static final String ROM_AMIGO = "amigo" ;
38
+ public static final String [] ROM_GOOGLE = { "google" } ;
39
+ public static final String [] ROM_SAMSUNG = { "samsung" } ;
40
+ public static final String [] ROM_MEIZU = { "meizu" } ;
41
+ public static final String [] ROM_LENOVO = { "lenovo" } ;
42
+ public static final String [] ROM_SMARTISAN = { "smartisan" } ;
43
+ public static final String [] ROM_HTC = { "htc" } ;
44
+ public static final String [] ROM_SONY = { "sony" } ;
45
+ public static final String [] ROM_AMIGO = { "amigo" } ;
46
46
47
47
public static final String VERSION_PROPERTY_HUAWEI = "ro.build.version.emui" ;
48
48
public static final String VERSION_PROPERTY_VIVO = "ro.vivo.os.build.display.id" ;
@@ -142,6 +142,33 @@ public static boolean isNubia() {
142
142
return ROM_NUBIA .equals (getRomInfo ().name );
143
143
}
144
144
145
+ /**
146
+ * Return whether the rom is made by coolpad.
147
+ *
148
+ * @return {@code true}: yes<br>{@code false}: no
149
+ */
150
+ public static boolean isCoolpad () {
151
+ return ROM_COOLPAD [0 ].equals (getRomInfo ().name );
152
+ }
153
+
154
+ /**
155
+ * Return whether the rom is made by lg.
156
+ *
157
+ * @return {@code true}: yes<br>{@code false}: no
158
+ */
159
+ public static boolean isLg () {
160
+ return ROM_LG [0 ].equals (getRomInfo ().name );
161
+ }
162
+
163
+ /**
164
+ * Return whether the rom is made by google.
165
+ *
166
+ * @return {@code true}: yes<br>{@code false}: no
167
+ */
168
+ public static boolean isGoogle () {
169
+ return ROM_GOOGLE .equals (getRomInfo ().name );
170
+ }
171
+
145
172
/**
146
173
* Return whether the rom is made by samsung.
147
174
*
@@ -161,21 +188,48 @@ public static boolean isMeizu() {
161
188
}
162
189
163
190
/**
164
- * Return whether the rom is made by coolpad .
191
+ * Return whether the rom is made by lenovo .
165
192
*
166
193
* @return {@code true}: yes<br>{@code false}: no
167
194
*/
168
- public static boolean isCoolpad () {
169
- return ROM_COOLPAD [ 0 ] .equals (getRomInfo ().name );
195
+ public static boolean isLenovo () {
196
+ return ROM_LENOVO .equals (getRomInfo ().name );
170
197
}
171
198
172
199
/**
173
- * Return whether the rom is made by lenovo .
200
+ * Return whether the rom is made by smartisan .
174
201
*
175
202
* @return {@code true}: yes<br>{@code false}: no
176
203
*/
177
- public static boolean isLenovo () {
178
- return ROM_LENOVO .equals (getRomInfo ().name );
204
+ public static boolean isSmartisan () {
205
+ return ROM_SMARTISAN .equals (getRomInfo ().name );
206
+ }
207
+
208
+ /**
209
+ * Return whether the rom is made by htc.
210
+ *
211
+ * @return {@code true}: yes<br>{@code false}: no
212
+ */
213
+ public static boolean isHtc () {
214
+ return ROM_HTC .equals (getRomInfo ().name );
215
+ }
216
+
217
+ /**
218
+ * Return whether the rom is made by sony.
219
+ *
220
+ * @return {@code true}: yes<br>{@code false}: no
221
+ */
222
+ public static boolean isSony () {
223
+ return ROM_SONY .equals (getRomInfo ().name );
224
+ }
225
+
226
+ /**
227
+ * Return whether the rom is made by amigo.
228
+ *
229
+ * @return {@code true}: yes<br>{@code false}: no
230
+ */
231
+ public static boolean isAmigo () {
232
+ return ROM_AMIGO .equals (getRomInfo ().name );
179
233
}
180
234
181
235
/**
@@ -186,9 +240,9 @@ public static boolean isLenovo() {
186
240
public static RomInfo getRomInfo () {
187
241
if (bean != null ) return bean ;
188
242
bean = new RomInfo ();
189
- final String brandName = getBrand ();
243
+ final String brand = getBrand ();
190
244
final String manufacturer = getManufacturer ();
191
- if (isRightRom (brandName , manufacturer , ROM_HUAWEI )) {
245
+ if (isRightRom (brand , manufacturer , ROM_HUAWEI )) {
192
246
bean .name = ROM_HUAWEI ;
193
247
String version = getRomVersion (VERSION_PROPERTY_HUAWEI );
194
248
String [] temp = version .split ("_" );
@@ -199,67 +253,67 @@ public static RomInfo getRomInfo() {
199
253
}
200
254
return bean ;
201
255
}
202
- if (isRightRom (brandName , manufacturer , ROM_VIVO )) {
256
+ if (isRightRom (brand , manufacturer , ROM_VIVO )) {
203
257
bean .name = ROM_VIVO ;
204
258
bean .version = getRomVersion (VERSION_PROPERTY_VIVO );
205
259
return bean ;
206
260
}
207
- if (isRightRom (brandName , manufacturer , ROM_XIAOMI )) {
261
+ if (isRightRom (brand , manufacturer , ROM_XIAOMI )) {
208
262
bean .name = ROM_XIAOMI ;
209
263
bean .version = getRomVersion (VERSION_PROPERTY_XIAOMI );
210
264
return bean ;
211
265
}
212
- if (isRightRom (brandName , manufacturer , ROM_OPPO )) {
266
+ if (isRightRom (brand , manufacturer , ROM_OPPO )) {
213
267
bean .name = ROM_OPPO ;
214
268
bean .version = getRomVersion (VERSION_PROPERTY_OPPO );
215
269
return bean ;
216
270
}
217
- if (isRightRom (brandName , manufacturer , ROM_LEECO )) {
271
+ if (isRightRom (brand , manufacturer , ROM_LEECO )) {
218
272
bean .name = ROM_LEECO [0 ];
219
273
bean .version = getRomVersion (VERSION_PROPERTY_LEECO );
220
274
return bean ;
221
275
}
222
276
223
- if (isRightRom (brandName , manufacturer , ROM_360 )) {
277
+ if (isRightRom (brand , manufacturer , ROM_360 )) {
224
278
bean .name = ROM_360 [0 ];
225
279
bean .version = getRomVersion (VERSION_PROPERTY_360 );
226
280
return bean ;
227
281
}
228
- if (isRightRom (brandName , manufacturer , ROM_ZTE )) {
282
+ if (isRightRom (brand , manufacturer , ROM_ZTE )) {
229
283
bean .name = ROM_ZTE ;
230
284
bean .version = getRomVersion (VERSION_PROPERTY_ZTE );
231
285
return bean ;
232
286
}
233
- if (isRightRom (brandName , manufacturer , ROM_ONEPLUS )) {
287
+ if (isRightRom (brand , manufacturer , ROM_ONEPLUS )) {
234
288
bean .name = ROM_ONEPLUS ;
235
289
bean .version = getRomVersion (VERSION_PROPERTY_ONEPLUS );
236
290
return bean ;
237
291
}
238
- if (isRightRom (brandName , manufacturer , ROM_NUBIA )) {
292
+ if (isRightRom (brand , manufacturer , ROM_NUBIA )) {
239
293
bean .name = ROM_NUBIA ;
240
294
bean .version = getRomVersion (VERSION_PROPERTY_NUBIA );
241
295
return bean ;
242
296
}
243
297
244
- if (isRightRom (brandName , manufacturer , ROM_COOLPAD )) {
298
+ if (isRightRom (brand , manufacturer , ROM_COOLPAD )) {
245
299
bean .name = ROM_COOLPAD [0 ];
246
- } else if (isRightRom (brandName , manufacturer , ROM_LG )) {
300
+ } else if (isRightRom (brand , manufacturer , ROM_LG )) {
247
301
bean .name = ROM_LG [0 ];
248
- } else if (isRightRom (brandName , manufacturer , ROM_GOOGLE )) {
302
+ } else if (isRightRom (brand , manufacturer , ROM_GOOGLE )) {
249
303
bean .name = ROM_GOOGLE ;
250
- } else if (isRightRom (brandName , manufacturer , ROM_SAMSUNG )) {
304
+ } else if (isRightRom (brand , manufacturer , ROM_SAMSUNG )) {
251
305
bean .name = ROM_SAMSUNG ;
252
- } else if (isRightRom (brandName , manufacturer , ROM_MEIZU )) {
306
+ } else if (isRightRom (brand , manufacturer , ROM_MEIZU )) {
253
307
bean .name = ROM_MEIZU ;
254
- } else if (isRightRom (brandName , manufacturer , ROM_LENOVO )) {
308
+ } else if (isRightRom (brand , manufacturer , ROM_LENOVO )) {
255
309
bean .name = ROM_LENOVO ;
256
- } else if (isRightRom (brandName , manufacturer , ROM_SMARTISAN )) {
310
+ } else if (isRightRom (brand , manufacturer , ROM_SMARTISAN )) {
257
311
bean .name = ROM_SMARTISAN ;
258
- } else if (isRightRom (brandName , manufacturer , ROM_HTC )) {
312
+ } else if (isRightRom (brand , manufacturer , ROM_HTC )) {
259
313
bean .name = ROM_HTC ;
260
- } else if (isRightRom (brandName , manufacturer , ROM_SONY )) {
314
+ } else if (isRightRom (brand , manufacturer , ROM_SONY )) {
261
315
bean .name = ROM_SONY ;
262
- } else if (isRightRom (brandName , manufacturer , ROM_AMIGO )) {
316
+ } else if (isRightRom (brand , manufacturer , ROM_AMIGO )) {
263
317
bean .name = ROM_AMIGO ;
264
318
} else {
265
319
bean .name = manufacturer ;
0 commit comments