Skip to content

Commit f77c833

Browse files
authored
Merge pull request #826 from Blankj/revert-825-1.23.4
Revert "1.23.4"
2 parents c1ed4cd + db150a7 commit f77c833

File tree

18 files changed

+228
-505
lines changed

18 files changed

+228
-505
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.4-brightgreen.svg
44+
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.3-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.4-brightgreen.svg
44+
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.3-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

config.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ext {
55
compileSdkVersion = 27
66
minSdkVersion = 14
77
targetSdkVersion = 27
8-
versionCode = 1_023_004
9-
versionName = '1.23.4'// E.g. 1.9.72 => 1,009,072
8+
versionCode = 1_023_003
9+
versionName = '1.23.3'// E.g. 1.9.72 => 1,009,072
1010

1111
bus = [
1212
isDebug: false,

lib/base/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ dependencies {
1515
api dep.free_proguard
1616
api 'com.r0adkll:slidableactivity:2.0.5'
1717
compileOnly dep.leakcanary.android_no_op
18-
// api 'com.blankj:utilcode:1.23.4'
18+
// api 'com.blankj:utilcode:1.23.3'
1919
}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
package com.blankj.subutil.util;
2+
3+
import android.annotation.SuppressLint;
4+
import android.os.Build;
5+
import android.os.Environment;
6+
import android.text.TextUtils;
7+
8+
import java.io.BufferedReader;
9+
import java.io.File;
10+
import java.io.FileInputStream;
11+
import java.io.IOException;
12+
import java.io.InputStreamReader;
13+
import java.lang.reflect.Method;
14+
import java.util.Properties;
15+
16+
/**
17+
* <pre>
18+
* author: Blankj
19+
* blog : http://blankj.com
20+
* time : 2018/07/04
21+
* desc : utils about rom
22+
* </pre>
23+
*/
24+
public final class RomUtils {
25+
26+
public static final String SYS_EMUI = "emui";
27+
public static final String SYS_MIUI = "miui";
28+
public static final String SYS_FLYME = "flyme";
29+
public static final String SYS_COLOROS = "colorOs";
30+
public static final String SYS_FUNTOUCH = "Funtouch";
31+
public static final String SYS_SAMSUNG = "samsung";
32+
33+
///////////////////////////////////////////////////////////////////////////
34+
// MIUI
35+
///////////////////////////////////////////////////////////////////////////
36+
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
37+
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
38+
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
39+
private static final String KEY_MIUI_VERSION_INCREMENTAL = "ro.build.version.incremental";
40+
41+
///////////////////////////////////////////////////////////////////////////
42+
// EMUI
43+
///////////////////////////////////////////////////////////////////////////
44+
private static final String KEY_EMUI_API_LEVEL = "ro.build.hw_emui_api_level";
45+
private static final String KEY_EMUI_VERSION = "ro.build.version.emui";
46+
private static final String KEY_EMUI_CONFIG_HW_SYS_VERSION = "ro.confg.hw_systemversion";
47+
48+
///////////////////////////////////////////////////////////////////////////
49+
// OPPO
50+
///////////////////////////////////////////////////////////////////////////
51+
private static final String KEY_OPPO_NAME = "ro.rom.different.version";
52+
private static final String KEY_OPPO_VERSION = "ro.build.version.opporom";
53+
54+
///////////////////////////////////////////////////////////////////////////
55+
// VIVO
56+
///////////////////////////////////////////////////////////////////////////
57+
private static final String KEY_VIVO_NAME = "ro.vivo.os.name";
58+
private static final String KEY_VIVO_VERSION = "ro.vivo.os.version";
59+
60+
private static RomBean bean = null;
61+
62+
/**
63+
* Return the name of rom.
64+
*
65+
* @return the name of rom
66+
*/
67+
public static RomBean getRom() {
68+
if (bean != null) return bean;
69+
bean = new RomBean();
70+
// 小米
71+
if (!TextUtils.isEmpty(getSystemProperty(KEY_MIUI_VERSION_CODE))
72+
|| !TextUtils.isEmpty(getSystemProperty(KEY_MIUI_VERSION_NAME))
73+
|| !TextUtils.isEmpty(getSystemProperty(KEY_MIUI_INTERNAL_STORAGE))) {
74+
bean.setRomName(SYS_MIUI);
75+
bean.setRomVersion(getSystemProperty(KEY_MIUI_VERSION_INCREMENTAL));
76+
}
77+
// 华为
78+
else if (!TextUtils.isEmpty(getSystemProperty(KEY_EMUI_API_LEVEL))
79+
|| !TextUtils.isEmpty(getSystemProperty(KEY_EMUI_VERSION))
80+
|| !TextUtils.isEmpty(getSystemProperty(KEY_EMUI_CONFIG_HW_SYS_VERSION))) {
81+
bean.setRomName(SYS_EMUI);
82+
String version = getSystemProperty(KEY_EMUI_VERSION);// EmotionUI_2.0
83+
String[] temp = version.split("_");
84+
if (temp.length > 1) {
85+
bean.setRomVersion(temp[1]);
86+
} else {
87+
bean.setRomVersion(version);
88+
}
89+
}
90+
// 魅族
91+
else if (Build.DISPLAY.toLowerCase().contains("flyme")) {
92+
bean.setRomName(SYS_FLYME);
93+
bean.setRomVersion(Build.DISPLAY);
94+
return bean;
95+
}
96+
// OPPO
97+
else if (!TextUtils.isEmpty(getSystemProperty(KEY_OPPO_NAME)) &&
98+
getSystemProperty(KEY_OPPO_NAME).toLowerCase().contains("coloros")) {
99+
bean.setRomName(SYS_COLOROS);
100+
bean.setRomVersion(getSystemProperty(KEY_OPPO_VERSION));
101+
}
102+
// VIVO
103+
else if (!TextUtils.isEmpty(getSystemProperty(KEY_VIVO_NAME))) {
104+
bean.setRomName(SYS_FUNTOUCH);
105+
bean.setRomVersion(getSystemProperty(KEY_VIVO_VERSION));
106+
}
107+
// 其他手机
108+
else {
109+
String brand = Build.BRAND;
110+
bean.setRomName(Build.BRAND);
111+
if (SYS_SAMSUNG.equalsIgnoreCase(brand)) {
112+
bean.setRomVersion(getSystemProperty("ro.build.changelist"));
113+
}
114+
}
115+
return bean;
116+
}
117+
118+
private static String getSystemProperty(final String name) {
119+
String prop = getSystemPropertyByShell(name);
120+
if (!TextUtils.isEmpty(prop)) return prop;
121+
prop = getSystemPropertyByStream(name);
122+
if (!TextUtils.isEmpty(prop)) return prop;
123+
if (Build.VERSION.SDK_INT < 28) {
124+
return getSystemPropertyByReflect(name);
125+
}
126+
return prop;
127+
}
128+
129+
private static String getSystemPropertyByShell(final String propName) {
130+
String line;
131+
BufferedReader input = null;
132+
try {
133+
Process p = Runtime.getRuntime().exec("getprop " + propName);
134+
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
135+
return input.readLine();
136+
} catch (IOException e) {
137+
return "";
138+
} finally {
139+
if (input != null) {
140+
try {
141+
input.close();
142+
} catch (IOException ignore) {
143+
144+
}
145+
}
146+
}
147+
}
148+
149+
private static String getSystemPropertyByStream(final String key) {
150+
try {
151+
Properties prop = new Properties();
152+
FileInputStream is = new FileInputStream(
153+
new File(Environment.getRootDirectory(), "build.prop")
154+
);
155+
prop.load(is);
156+
return prop.getProperty(key, "");
157+
} catch (Exception e) {
158+
e.printStackTrace();
159+
return "";
160+
}
161+
}
162+
163+
private static String getSystemPropertyByReflect(String key) {
164+
try {
165+
@SuppressLint("PrivateApi")
166+
Class<?> clz = Class.forName("android.os.SystemProperties");
167+
Method get = clz.getMethod("get", String.class, String.class);
168+
return (String) get.invoke(clz, key, "");
169+
} catch (Exception e) {
170+
return "";
171+
}
172+
}
173+
174+
public static class RomBean {
175+
private String romName;
176+
private String romVersion;
177+
178+
public String getRomName() {
179+
if (romName == null) return "";
180+
return romName;
181+
}
182+
183+
private void setRomName(String romName) {
184+
this.romName = romName;
185+
}
186+
187+
public String getRomVersion() {
188+
if (romVersion == null) return "";
189+
return romVersion;
190+
}
191+
192+
private void setRomVersion(String romVersion) {
193+
this.romVersion = romVersion;
194+
}
195+
196+
@Override
197+
public String toString() {
198+
return "romName: " + romName +
199+
"\nromVersion: " + romVersion;
200+
}
201+
}
202+
}

utilcode/README-CN.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.23.4'
5+
implementation 'com.blankj:utilcode:1.23.3'
66
```
77

88

@@ -281,6 +281,14 @@ reboot2Recovery : 重启到 recovery
281281
reboot2Bootloader: 重启到 bootloader
282282
```
283283

284+
* ### 闪光灯相关 -> [FlashlightUtils.java][flashlight.java] -> [Demo][flashlight.demo]
285+
```
286+
isFlashlightEnable : 判断设备是否支持闪光灯
287+
isFlashlightOn : 判断闪光灯是否打开
288+
setFlashlightStatus: 设置闪光灯状态
289+
destroy : 销毁
290+
```
291+
284292
* ### 编码解码相关 -> [EncodeUtils.java][encode.java] -> [Test][encode.test]
285293
```
286294
urlEncode : URL 编码
@@ -370,14 +378,6 @@ getFileNameNoExtension : 根据全路径获取文件名不带拓展名
370378
getFileExtension : 根据全路径获取文件拓展名
371379
```
372380

373-
* ### 闪光灯相关 -> [FlashlightUtils.java][flashlight.java] -> [Demo][flashlight.demo]
374-
```
375-
isFlashlightEnable : 判断设备是否支持闪光灯
376-
isFlashlightOn : 判断闪光灯是否打开
377-
setFlashlightStatus: 设置闪光灯状态
378-
destroy : 销毁
379-
```
380-
381381
* ### Fragment 相关 -> [FragmentUtils.java][fragment.java] -> [Demo][fragment.demo]
382382
```
383383
add : 新增 fragment

utilcode/README-STATIC-BUS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apply plugin: "com.blankj.bus"
2727
给 base 模块添加 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode) 依赖:
2828

2929
```groovy
30-
api "com.blankj:utilcode:1.23.4"
30+
api "com.blankj:utilcode:1.23.3"
3131
```
3232

3333
比如 module0 中存在的 `Module0Activity.java`,我们通常都是在它内部写一个 `start` 函数来启动它,现在我们给它添加 `@BusUtils.Subscribe` 注解,并给注解的 `name` 赋唯一值,要注意,函数务必要 `public static` 哦:

utilcode/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.23.4'
5+
implementation 'com.blankj:utilcode:1.23.3'
66
```
77

88

@@ -281,6 +281,14 @@ reboot2Recovery
281281
reboot2Bootloader
282282
```
283283

284+
* ### About Flashlight -> [FlashlightUtils.java][flashlight.java] -> [Demo][flashlight.demo]
285+
```
286+
isFlashlightEnable
287+
isFlashlightOn
288+
setFlashlightStatus
289+
destroy
290+
```
291+
284292
* ### About Encode -> [EncodeUtils.java][encode.java] -> [Test][encode.test]
285293
```
286294
urlEncode
@@ -370,14 +378,6 @@ getFileNameNoExtension
370378
getFileExtension
371379
```
372380

373-
* ### About Flashlight -> [FlashlightUtils.java][flashlight.java] -> [Demo][flashlight.demo]
374-
```
375-
isFlashlightEnable
376-
isFlashlightOn
377-
setFlashlightStatus
378-
destroy
379-
```
380-
381381
* ### About Fragment -> [FragmentUtils.java][fragment.java] -> [Demo][fragment.demo]
382382
```
383383
add

0 commit comments

Comments
 (0)