Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mmm-rain
AndroidUtilCode
提交
c1ed4cd2
A
AndroidUtilCode
项目概览
mmm-rain
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c1ed4cd2
编写于
1月 30, 2019
作者:
布
布兰柯基
提交者:
GitHub
1月 30, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #825 from gnaixx/1.23.4
1.23.4
上级
b3bed76f
871d0150
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
505 addition
and
228 deletion
+505
-228
README-CN.md
README-CN.md
+1
-1
README.md
README.md
+1
-1
config.gradle
config.gradle
+2
-2
lib/base/build.gradle
lib/base/build.gradle
+1
-1
subutil/lib/src/main/java/com/blankj/subutil/util/RomUtils.java
...l/lib/src/main/java/com/blankj/subutil/util/RomUtils.java
+0
-202
utilcode/README-CN.md
utilcode/README-CN.md
+9
-9
utilcode/README-STATIC-BUS.md
utilcode/README-STATIC-BUS.md
+1
-1
utilcode/README.md
utilcode/README.md
+9
-9
utilcode/lib/src/main/java/com/blankj/utilcode/util/DeviceUtils.java
...b/src/main/java/com/blankj/utilcode/util/DeviceUtils.java
+47
-1
utilcode/lib/src/main/java/com/blankj/utilcode/util/LogUtils.java
.../lib/src/main/java/com/blankj/utilcode/util/LogUtils.java
+0
-1
utilcode/lib/src/main/java/com/blankj/utilcode/util/RomUtils.java
.../lib/src/main/java/com/blankj/utilcode/util/RomUtils.java
+347
-0
utilcode/pkg/src/main/AndroidManifest.xml
utilcode/pkg/src/main/AndroidManifest.xml
+3
-0
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt
.../java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt
+5
-0
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/device/DeviceActivity.kt
.../com/blankj/utilcode/pkg/feature/device/DeviceActivity.kt
+2
-0
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/rom/RomActivity.kt
...n/java/com/blankj/utilcode/pkg/feature/rom/RomActivity.kt
+53
-0
utilcode/pkg/src/main/res/layout/activity_rom.xml
utilcode/pkg/src/main/res/layout/activity_rom.xml
+16
-0
utilcode/pkg/src/main/res/layout/activity_util_core.xml
utilcode/pkg/src/main/res/layout/activity_util_core.xml
+7
-0
utilcode/pkg/src/main/res/values/strings.xml
utilcode/pkg/src/main/res/values/strings.xml
+1
-0
未找到文件。
README-CN.md
浏览文件 @
c1ed4cd2
...
...
@@ -41,7 +41,7 @@
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.23.
3
-brightgreen.svg
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.23.
4
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apiSvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
README.md
浏览文件 @
c1ed4cd2
...
...
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.23.
3
-brightgreen.svg
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.23.
4
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apiSvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
config.gradle
浏览文件 @
c1ed4cd2
...
...
@@ -5,8 +5,8 @@ ext {
compileSdkVersion
=
27
minSdkVersion
=
14
targetSdkVersion
=
27
versionCode
=
1
_023_00
3
versionName
=
'1.23.
3
'
// E.g. 1.9.72 => 1,009,072
versionCode
=
1
_023_00
4
versionName
=
'1.23.
4
'
// E.g. 1.9.72 => 1,009,072
bus
=
[
isDebug:
false
,
...
...
lib/base/build.gradle
浏览文件 @
c1ed4cd2
...
...
@@ -15,5 +15,5 @@ dependencies {
api
dep
.
free_proguard
api
'com.r0adkll:slidableactivity:2.0.5'
compileOnly
dep
.
leakcanary
.
android_no_op
// api 'com.blankj:utilcode:1.23.
3
'
// api 'com.blankj:utilcode:1.23.
4
'
}
\ No newline at end of file
subutil/lib/src/main/java/com/blankj/subutil/util/RomUtils.java
已删除
100644 → 0
浏览文件 @
b3bed76f
package
com.blankj.subutil.util
;
import
android.annotation.SuppressLint
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.text.TextUtils
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.Method
;
import
java.util.Properties
;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2018/07/04
* desc : utils about rom
* </pre>
*/
public
final
class
RomUtils
{
public
static
final
String
SYS_EMUI
=
"emui"
;
public
static
final
String
SYS_MIUI
=
"miui"
;
public
static
final
String
SYS_FLYME
=
"flyme"
;
public
static
final
String
SYS_COLOROS
=
"colorOs"
;
public
static
final
String
SYS_FUNTOUCH
=
"Funtouch"
;
public
static
final
String
SYS_SAMSUNG
=
"samsung"
;
///////////////////////////////////////////////////////////////////////////
// MIUI
///////////////////////////////////////////////////////////////////////////
private
static
final
String
KEY_MIUI_VERSION_CODE
=
"ro.miui.ui.version.code"
;
private
static
final
String
KEY_MIUI_VERSION_NAME
=
"ro.miui.ui.version.name"
;
private
static
final
String
KEY_MIUI_INTERNAL_STORAGE
=
"ro.miui.internal.storage"
;
private
static
final
String
KEY_MIUI_VERSION_INCREMENTAL
=
"ro.build.version.incremental"
;
///////////////////////////////////////////////////////////////////////////
// EMUI
///////////////////////////////////////////////////////////////////////////
private
static
final
String
KEY_EMUI_API_LEVEL
=
"ro.build.hw_emui_api_level"
;
private
static
final
String
KEY_EMUI_VERSION
=
"ro.build.version.emui"
;
private
static
final
String
KEY_EMUI_CONFIG_HW_SYS_VERSION
=
"ro.confg.hw_systemversion"
;
///////////////////////////////////////////////////////////////////////////
// OPPO
///////////////////////////////////////////////////////////////////////////
private
static
final
String
KEY_OPPO_NAME
=
"ro.rom.different.version"
;
private
static
final
String
KEY_OPPO_VERSION
=
"ro.build.version.opporom"
;
///////////////////////////////////////////////////////////////////////////
// VIVO
///////////////////////////////////////////////////////////////////////////
private
static
final
String
KEY_VIVO_NAME
=
"ro.vivo.os.name"
;
private
static
final
String
KEY_VIVO_VERSION
=
"ro.vivo.os.version"
;
private
static
RomBean
bean
=
null
;
/**
* Return the name of rom.
*
* @return the name of rom
*/
public
static
RomBean
getRom
()
{
if
(
bean
!=
null
)
return
bean
;
bean
=
new
RomBean
();
// 小米
if
(!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_MIUI_VERSION_CODE
))
||
!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_MIUI_VERSION_NAME
))
||
!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_MIUI_INTERNAL_STORAGE
)))
{
bean
.
setRomName
(
SYS_MIUI
);
bean
.
setRomVersion
(
getSystemProperty
(
KEY_MIUI_VERSION_INCREMENTAL
));
}
// 华为
else
if
(!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_EMUI_API_LEVEL
))
||
!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_EMUI_VERSION
))
||
!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_EMUI_CONFIG_HW_SYS_VERSION
)))
{
bean
.
setRomName
(
SYS_EMUI
);
String
version
=
getSystemProperty
(
KEY_EMUI_VERSION
);
// EmotionUI_2.0
String
[]
temp
=
version
.
split
(
"_"
);
if
(
temp
.
length
>
1
)
{
bean
.
setRomVersion
(
temp
[
1
]);
}
else
{
bean
.
setRomVersion
(
version
);
}
}
// 魅族
else
if
(
Build
.
DISPLAY
.
toLowerCase
().
contains
(
"flyme"
))
{
bean
.
setRomName
(
SYS_FLYME
);
bean
.
setRomVersion
(
Build
.
DISPLAY
);
return
bean
;
}
// OPPO
else
if
(!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_OPPO_NAME
))
&&
getSystemProperty
(
KEY_OPPO_NAME
).
toLowerCase
().
contains
(
"coloros"
))
{
bean
.
setRomName
(
SYS_COLOROS
);
bean
.
setRomVersion
(
getSystemProperty
(
KEY_OPPO_VERSION
));
}
// VIVO
else
if
(!
TextUtils
.
isEmpty
(
getSystemProperty
(
KEY_VIVO_NAME
)))
{
bean
.
setRomName
(
SYS_FUNTOUCH
);
bean
.
setRomVersion
(
getSystemProperty
(
KEY_VIVO_VERSION
));
}
// 其他手机
else
{
String
brand
=
Build
.
BRAND
;
bean
.
setRomName
(
Build
.
BRAND
);
if
(
SYS_SAMSUNG
.
equalsIgnoreCase
(
brand
))
{
bean
.
setRomVersion
(
getSystemProperty
(
"ro.build.changelist"
));
}
}
return
bean
;
}
private
static
String
getSystemProperty
(
final
String
name
)
{
String
prop
=
getSystemPropertyByShell
(
name
);
if
(!
TextUtils
.
isEmpty
(
prop
))
return
prop
;
prop
=
getSystemPropertyByStream
(
name
);
if
(!
TextUtils
.
isEmpty
(
prop
))
return
prop
;
if
(
Build
.
VERSION
.
SDK_INT
<
28
)
{
return
getSystemPropertyByReflect
(
name
);
}
return
prop
;
}
private
static
String
getSystemPropertyByShell
(
final
String
propName
)
{
String
line
;
BufferedReader
input
=
null
;
try
{
Process
p
=
Runtime
.
getRuntime
().
exec
(
"getprop "
+
propName
);
input
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()),
1024
);
return
input
.
readLine
();
}
catch
(
IOException
e
)
{
return
""
;
}
finally
{
if
(
input
!=
null
)
{
try
{
input
.
close
();
}
catch
(
IOException
ignore
)
{
}
}
}
}
private
static
String
getSystemPropertyByStream
(
final
String
key
)
{
try
{
Properties
prop
=
new
Properties
();
FileInputStream
is
=
new
FileInputStream
(
new
File
(
Environment
.
getRootDirectory
(),
"build.prop"
)
);
prop
.
load
(
is
);
return
prop
.
getProperty
(
key
,
""
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
""
;
}
}
private
static
String
getSystemPropertyByReflect
(
String
key
)
{
try
{
@SuppressLint
(
"PrivateApi"
)
Class
<?>
clz
=
Class
.
forName
(
"android.os.SystemProperties"
);
Method
get
=
clz
.
getMethod
(
"get"
,
String
.
class
,
String
.
class
);
return
(
String
)
get
.
invoke
(
clz
,
key
,
""
);
}
catch
(
Exception
e
)
{
return
""
;
}
}
public
static
class
RomBean
{
private
String
romName
;
private
String
romVersion
;
public
String
getRomName
()
{
if
(
romName
==
null
)
return
""
;
return
romName
;
}
private
void
setRomName
(
String
romName
)
{
this
.
romName
=
romName
;
}
public
String
getRomVersion
()
{
if
(
romVersion
==
null
)
return
""
;
return
romVersion
;
}
private
void
setRomVersion
(
String
romVersion
)
{
this
.
romVersion
=
romVersion
;
}
@Override
public
String
toString
()
{
return
"romName: "
+
romName
+
"\nromVersion: "
+
romVersion
;
}
}
}
utilcode/README-CN.md
浏览文件 @
c1ed4cd2
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.23.
3
'
implementation
'com.blankj:utilcode:1.23.
4
'
```
...
...
@@ -281,14 +281,6 @@ reboot2Recovery : 重启到 recovery
reboot2Bootloader: 重启到 bootloader
```
*
### 闪光灯相关 ->
[
FlashlightUtils.java
][
flashlight.java
]
->
[
Demo
][
flashlight.demo
]
```
isFlashlightEnable : 判断设备是否支持闪光灯
isFlashlightOn : 判断闪光灯是否打开
setFlashlightStatus: 设置闪光灯状态
destroy : 销毁
```
*
### 编码解码相关 ->
[
EncodeUtils.java
][
encode.java
]
->
[
Test
][
encode.test
]
```
urlEncode : URL 编码
...
...
@@ -378,6 +370,14 @@ getFileNameNoExtension : 根据全路径获取文件名不带拓展名
getFileExtension : 根据全路径获取文件拓展名
```
*
### 闪光灯相关 ->
[
FlashlightUtils.java
][
flashlight.java
]
->
[
Demo
][
flashlight.demo
]
```
isFlashlightEnable : 判断设备是否支持闪光灯
isFlashlightOn : 判断闪光灯是否打开
setFlashlightStatus: 设置闪光灯状态
destroy : 销毁
```
*
### Fragment 相关 ->
[
FragmentUtils.java
][
fragment.java
]
->
[
Demo
][
fragment.demo
]
```
add : 新增 fragment
...
...
utilcode/README-STATIC-BUS.md
浏览文件 @
c1ed4cd2
...
...
@@ -27,7 +27,7 @@ apply plugin: "com.blankj.bus"
给 base 模块添加
[
AndroidUtilCode
](
https://github.com/Blankj/AndroidUtilCode
)
依赖:
```
groovy
api
"com.blankj:utilcode:1.23.
3
"
api
"com.blankj:utilcode:1.23.
4
"
```
比如 module0 中存在的
`Module0Activity.java`
,我们通常都是在它内部写一个
`start`
函数来启动它,现在我们给它添加
`@BusUtils.Subscribe`
注解,并给注解的
`name`
赋唯一值,要注意,函数务必要
`public static`
哦:
...
...
utilcode/README.md
浏览文件 @
c1ed4cd2
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.23.
3
'
implementation
'com.blankj:utilcode:1.23.
4
'
```
...
...
@@ -281,14 +281,6 @@ reboot2Recovery
reboot2Bootloader
```
*
### About Flashlight ->
[
FlashlightUtils.java
][
flashlight.java
]
->
[
Demo
][
flashlight.demo
]
```
isFlashlightEnable
isFlashlightOn
setFlashlightStatus
destroy
```
*
### About Encode ->
[
EncodeUtils.java
][
encode.java
]
->
[
Test
][
encode.test
]
```
urlEncode
...
...
@@ -378,6 +370,14 @@ getFileNameNoExtension
getFileExtension
```
*
### About Flashlight ->
[
FlashlightUtils.java
][
flashlight.java
]
->
[
Demo
][
flashlight.demo
]
```
isFlashlightEnable
isFlashlightOn
setFlashlightStatus
destroy
```
*
### About Fragment ->
[
FragmentUtils.java
][
fragment.java
]
->
[
Demo
][
fragment.demo
]
```
add
...
...
utilcode/lib/src/main/java/com/blankj/utilcode/util/DeviceUtils.java
浏览文件 @
c1ed4cd2
...
...
@@ -10,6 +10,8 @@ import android.os.PowerManager;
import
android.provider.Settings
;
import
android.support.annotation.RequiresApi
;
import
android.support.annotation.RequiresPermission
;
import
android.telecom.TelecomManager
;
import
android.telephony.TelephonyManager
;
import
android.text.TextUtils
;
import
java.io.File
;
...
...
@@ -20,6 +22,7 @@ import java.util.Enumeration;
import
static
android
.
Manifest
.
permission
.
ACCESS_WIFI_STATE
;
import
static
android
.
Manifest
.
permission
.
INTERNET
;
import
static
android
.
Manifest
.
permission
.
READ_PHONE_STATE
;
/**
* <pre>
...
...
@@ -43,7 +46,8 @@ public final class DeviceUtils {
public
static
boolean
isDeviceRooted
()
{
String
su
=
"su"
;
String
[]
locations
=
{
"/system/bin/"
,
"/system/xbin/"
,
"/sbin/"
,
"/system/sd/xbin/"
,
"/system/bin/failsafe/"
,
"/data/local/xbin/"
,
"/data/local/bin/"
,
"/data/local/"
};
"/system/bin/failsafe/"
,
"/data/local/xbin/"
,
"/data/local/bin/"
,
"/data/local/"
,
"/system/sbin/"
,
"/usr/bin/"
,
"/vendor/bin/"
};
for
(
String
location
:
locations
)
{
if
(
new
File
(
location
+
su
).
exists
())
{
return
true
;
...
...
@@ -65,6 +69,48 @@ public final class DeviceUtils {
)
>
0
;
}
/**
* Return the imei of device.
*
* @return the imei of device
*/
@SuppressLint
(
"HardwareIds"
)
@RequiresPermission
(
value
=
READ_PHONE_STATE
)
public
static
String
getImei
()
{
String
imei
=
""
;
try
{
TelephonyManager
telephonyMgr
=
(
TelephonyManager
)
Utils
.
getApp
()
.
getApplicationContext
().
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
if
(
telephonyMgr
!=
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
imei
=
telephonyMgr
.
getImei
();
}
else
{
imei
=
telephonyMgr
.
getDeviceId
();
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
imei
;
}
/**
* Return the serial of device.
*
* @return the serial of device
*/
@SuppressLint
(
"HardwareIds"
)
@RequiresPermission
(
value
=
READ_PHONE_STATE
)
public
static
String
getSerial
()
{
String
serial
=
""
;
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
O
)
{
serial
=
Build
.
getSerial
();
}
else
{
serial
=
Build
.
SERIAL
;
}
return
serial
;
}
/**
* Return the version name of device's system.
*
...
...
utilcode/lib/src/main/java/com/blankj/utilcode/util/LogUtils.java
浏览文件 @
c1ed4cd2
...
...
@@ -110,7 +110,6 @@ public final class LogUtils {
private
static
final
SimpleArrayMap
<
Class
,
IFormatter
>
I_FORMATTER_MAP
=
new
SimpleArrayMap
<>();
private
LogUtils
()
{
throw
new
UnsupportedOperationException
(
"u can't instantiate me..."
);
}
...
...
utilcode/lib/src/main/java/com/blankj/utilcode/util/RomUtils.java
0 → 100644
浏览文件 @
c1ed4cd2
package
com.blankj.utilcode.util
;
import
android.annotation.SuppressLint
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.text.TextUtils
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.Method
;
import
java.util.Properties
;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2018/07/04
* desc : utils about rom
* </pre>
*/
public
final
class
RomUtils
{
public
static
final
String
ROM_HUAWEI
=
"huawei"
;
public
static
final
String
ROM_VIVO
=
"vivo"
;
public
static
final
String
ROM_XIAOMI
=
"xiaomi"
;
public
static
final
String
ROM_OPPO
=
"oppo"
;
public
static
final
String
ROM_LEECO
=
"leeco"
;
public
static
final
String
ROM_QIKU
=
"qiku"
;
public
static
final
String
ROM_ZTE
=
"zte"
;
public
static
final
String
ROM_ONEPLUS
=
"oneplus"
;
public
static
final
String
ROM_NUBIA
=
"nubia"
;
public
static
final
String
ROM_SAMSUNG
=
"samsung"
;
public
static
final
String
ROM_MEIZU
=
"meizu"
;
public
static
final
String
ROM_COOLPAD
=
"coolpad"
;
public
static
final
String
ROM_LENOVO
=
"lenovo"
;
public
static
final
String
VERSION_PROPERTY_HUAWEI
=
"ro.build.version.emui"
;
public
static
final
String
VERSION_PROPERTY_VIVO
=
"ro.vivo.os.build.display.id"
;
public
static
final
String
VERSION_PROPERTY_XIAOMI
=
"ro.build.version.incremental"
;
public
static
final
String
VERSION_PROPERTY_OPPO
=
"ro.build.version.opporom"
;
public
static
final
String
VERSION_PROPERTY_LEECO
=
"ro.letv.release.version"
;
public
static
final
String
VERSION_PROPERTY_QIKU
=
"ro.build.uiversion"
;
public
static
final
String
VERSION_PROPERTY_ZTE
=
"ro.build.MiFavor_version"
;
public
static
final
String
VERSION_PROPERTY_ONEPLUS
=
"ro.rom.version"
;
public
static
final
String
VERSION_PROPERTY_NUBIA
=
"ro.build.rom.id"
;
private
final
static
String
UNKNOWN
=
"unknown"
;
private
static
RomInfo
bean
=
null
;
private
RomUtils
()
{
throw
new
UnsupportedOperationException
(
"u can't instantiate me..."
);
}
/**
* Return whether the rom is made by huawei.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isHuawei
()
{
return
ROM_HUAWEI
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by vivo.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isVivo
()
{
return
ROM_VIVO
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by xiaomi.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isXiaomi
()
{
return
ROM_XIAOMI
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by oppo.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isOppo
()
{
return
ROM_OPPO
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by leeco.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isLeeco
()
{
return
ROM_LEECO
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by qiku.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isQiku
()
{
return
ROM_QIKU
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by zte.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isZte
()
{
return
ROM_ZTE
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by oneplus.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isOneplus
()
{
return
ROM_ONEPLUS
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by nubia.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isNubia
()
{
return
ROM_NUBIA
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by samsung.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isSamsung
()
{
return
ROM_SAMSUNG
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by meizu.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isMeizu
()
{
return
ROM_MEIZU
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by coolpad.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isCoolpad
()
{
return
ROM_COOLPAD
.
equals
(
getRomInfo
().
name
);
}
/**
* Return whether the rom is made by lenovo.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public
static
boolean
isLenovo
()
{
return
ROM_LENOVO
.
equals
(
getRomInfo
().
name
);
}
/**
* Return the rom's information.
*
* @return the rom's information
*/
public
static
RomInfo
getRomInfo
()
{
if
(
bean
!=
null
)
return
bean
;
bean
=
new
RomInfo
();
final
String
brandName
=
getBrand
();
final
String
manufacturer
=
getManufacturer
();
if
(
ROM_HUAWEI
.
equals
(
brandName
)
||
ROM_HUAWEI
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_HUAWEI
;
String
version
=
getRomVersion
(
VERSION_PROPERTY_HUAWEI
);
String
[]
temp
=
version
.
split
(
"_"
);
if
(
temp
.
length
>
1
)
{
bean
.
version
=
temp
[
1
];
}
else
{
bean
.
version
=
version
;
}
}
else
if
(
ROM_VIVO
.
equals
(
brandName
)
||
ROM_VIVO
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_VIVO
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_VIVO
);
}
else
if
(
ROM_XIAOMI
.
equals
(
brandName
)
||
ROM_XIAOMI
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_XIAOMI
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_XIAOMI
);
}
else
if
(
ROM_OPPO
.
equals
(
brandName
)
||
ROM_OPPO
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_OPPO
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_OPPO
);
}
else
if
(
ROM_LEECO
.
equals
(
brandName
)
||
ROM_LEECO
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_LEECO
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_LEECO
);
}
else
if
(
ROM_QIKU
.
equals
(
brandName
)
||
ROM_QIKU
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_QIKU
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_QIKU
);
}
else
if
(
ROM_ZTE
.
equals
(
brandName
)
||
ROM_ZTE
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_ZTE
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_ZTE
);
}
else
if
(
ROM_ONEPLUS
.
equals
(
brandName
)
||
ROM_ONEPLUS
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_ONEPLUS
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_ONEPLUS
);
}
else
if
(
ROM_NUBIA
.
equals
(
brandName
)
||
ROM_NUBIA
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_NUBIA
;
bean
.
version
=
getRomVersion
(
VERSION_PROPERTY_NUBIA
);
}
else
if
(
ROM_SAMSUNG
.
equals
(
brandName
)
||
ROM_SAMSUNG
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_SAMSUNG
;
bean
.
version
=
getRomVersion
(
""
);
}
else
if
(
ROM_MEIZU
.
equals
(
brandName
)
||
ROM_MEIZU
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_MEIZU
;
bean
.
version
=
getRomVersion
(
""
);
}
else
if
(
ROM_COOLPAD
.
equals
(
brandName
)
||
ROM_COOLPAD
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_COOLPAD
;
bean
.
version
=
getRomVersion
(
""
);
}
else
if
(
ROM_LENOVO
.
equals
(
brandName
)
||
ROM_LENOVO
.
equals
(
manufacturer
))
{
bean
.
name
=
ROM_LENOVO
;
bean
.
version
=
getRomVersion
(
""
);
}
else
{
bean
.
name
=
manufacturer
;
bean
.
version
=
getRomVersion
(
""
);
}
return
bean
;
}
private
static
String
getManufacturer
()
{
try
{
String
manufacturer
=
Build
.
MANUFACTURER
;
if
(!
TextUtils
.
isEmpty
(
manufacturer
))
{
return
manufacturer
.
toLowerCase
();
}
}
catch
(
Throwable
ignore
)
{
/**/
}
return
UNKNOWN
;
}
private
static
String
getBrand
()
{
try
{
String
brand
=
Build
.
BRAND
;
if
(!
TextUtils
.
isEmpty
(
brand
))
{
return
brand
.
toLowerCase
();
}
}
catch
(
Throwable
ignore
)
{
/**/
}
return
UNKNOWN
;
}
private
static
String
getRomVersion
(
final
String
propertyName
)
{
String
ret
=
""
;
if
(!
TextUtils
.
isEmpty
(
propertyName
))
{
ret
=
getSystemProperty
(
propertyName
);
}
if
(
TextUtils
.
isEmpty
(
ret
)
||
ret
.
equals
(
UNKNOWN
))
{
try
{
String
display
=
Build
.
DISPLAY
;
if
(!
TextUtils
.
isEmpty
(
display
))
{
ret
=
display
.
toLowerCase
();
}
}
catch
(
Throwable
ignore
)
{
/**/
}
}
if
(
TextUtils
.
isEmpty
(
ret
))
{
return
UNKNOWN
;
}
return
ret
;
}
private
static
String
getSystemProperty
(
final
String
name
)
{
String
prop
=
getSystemPropertyByShell
(
name
);
if
(!
TextUtils
.
isEmpty
(
prop
))
return
prop
;
prop
=
getSystemPropertyByStream
(
name
);
if
(!
TextUtils
.
isEmpty
(
prop
))
return
prop
;
if
(
Build
.
VERSION
.
SDK_INT
<
28
)
{
return
getSystemPropertyByReflect
(
name
);
}
return
prop
;
}
private
static
String
getSystemPropertyByShell
(
final
String
propName
)
{
String
line
;
BufferedReader
input
=
null
;
try
{
Process
p
=
Runtime
.
getRuntime
().
exec
(
"getprop "
+
propName
);
input
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()),
1024
);
String
ret
=
input
.
readLine
();
if
(
ret
!=
null
)
{
return
ret
;
}
}
catch
(
IOException
ignore
)
{
}
finally
{
if
(
input
!=
null
)
{
try
{
input
.
close
();
}
catch
(
IOException
ignore
)
{
/**/
}
}
}
return
""
;
}
private
static
String
getSystemPropertyByStream
(
final
String
key
)
{
try
{
Properties
prop
=
new
Properties
();
FileInputStream
is
=
new
FileInputStream
(
new
File
(
Environment
.
getRootDirectory
(),
"build.prop"
)
);
prop
.
load
(
is
);
return
prop
.
getProperty
(
key
,
""
);
}
catch
(
Exception
ignore
)
{
/**/
}
return
""
;
}
private
static
String
getSystemPropertyByReflect
(
String
key
)
{
try
{
@SuppressLint
(
"PrivateApi"
)
Class
<?>
clz
=
Class
.
forName
(
"android.os.SystemProperties"
);
Method
get
=
clz
.
getMethod
(
"get"
,
String
.
class
,
String
.
class
);
return
(
String
)
get
.
invoke
(
clz
,
key
,
""
);
}
catch
(
Exception
e
)
{
/**/
}
return
""
;
}
public
static
class
RomInfo
{
private
String
name
;
private
String
version
;
public
String
getName
()
{
return
name
;
}
public
String
getVersion
()
{
return
version
;
}
@Override
public
String
toString
()
{
return
"RomInfo{name: "
+
name
+
"\nversion: "
+
version
+
"}"
;
}
}
}
utilcode/pkg/src/main/AndroidManifest.xml
浏览文件 @
c1ed4cd2
...
...
@@ -149,6 +149,9 @@
<activity
android:name=
".feature.resource.ResourceActivity"
android:launchMode=
"singleTop"
/>
<activity
android:name=
".feature.rom.RomActivity"
android:launchMode=
"singleTop"
/>
<activity
android:name=
".feature.sdcard.SDCardActivity"
android:launchMode=
"singleTop"
/>
...
...
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt
浏览文件 @
c1ed4cd2
...
...
@@ -26,6 +26,7 @@ import com.blankj.utilcode.pkg.feature.phone.PhoneActivity
import
com.blankj.utilcode.pkg.feature.process.ProcessActivity
import
com.blankj.utilcode.pkg.feature.reflect.ReflectActivity
import
com.blankj.utilcode.pkg.feature.resource.ResourceActivity
import
com.blankj.utilcode.pkg.feature.rom.RomActivity
import
com.blankj.utilcode.pkg.feature.sdcard.SDCardActivity
import
com.blankj.utilcode.pkg.feature.snackbar.SnackbarActivity
import
com.blankj.utilcode.pkg.feature.spStatic.SPStaticActivity
...
...
@@ -156,6 +157,10 @@ class CoreUtilActivity : BaseBackActivity() {
ResourceActivity
.
start
(
this
)
}
fun
romClick
(
view
:
View
)
{
RomActivity
.
start
(
this
)
}
fun
sdcardClick
(
view
:
View
)
{
SDCardActivity
.
start
(
this
)
}
...
...
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/device/DeviceActivity.kt
浏览文件 @
c1ed4cd2
...
...
@@ -52,6 +52,8 @@ class DeviceActivity : BaseBackActivity() {
appendLine
(
"isAdbEnabled: "
+
DeviceUtils
.
isAdbEnabled
())
}
}
.
appendLine
(
"getImei: "
+
DeviceUtils
.
getImei
())
.
appendLine
(
"getSerial: "
+
DeviceUtils
.
getSerial
())
.
appendLine
(
"getSDKVersionName: "
+
DeviceUtils
.
getSDKVersionName
())
.
appendLine
(
"getSDKVersionCode: "
+
DeviceUtils
.
getSDKVersionCode
())
.
appendLine
(
"getAndroidID: "
+
DeviceUtils
.
getAndroidID
())
...
...
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/rom/RomActivity.kt
0 → 100644
浏览文件 @
c1ed4cd2
package
com.blankj.utilcode.pkg.feature.rom
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.view.View
import
com.blankj.lib.base.BaseBackActivity
import
com.blankj.utilcode.pkg.R
import
com.blankj.utilcode.util.RomUtils
import
com.blankj.utilcode.util.SpanUtils
import
kotlinx.android.synthetic.main.activity_rom.*
/**
* ```
* author: Blankj
* blog : http://blankj.com
* time : 2019/01/29
* desc : demo about RomUtils
* ```
*/
class
RomActivity
:
BaseBackActivity
()
{
companion
object
{
fun
start
(
context
:
Context
)
{
val
starter
=
Intent
(
context
,
RomActivity
::
class
.
java
)
context
.
startActivity
(
starter
)
}
}
override
fun
initData
(
bundle
:
Bundle
?)
{
}
override
fun
bindLayout
():
Int
{
return
R
.
layout
.
activity_rom
}
override
fun
initView
(
savedInstanceState
:
Bundle
?,
contentView
:
View
)
{
setTitle
(
R
.
string
.
demo_rom
)
SpanUtils
.
with
(
romAboutTv
)
.
append
(
"getRomInfo: "
+
RomUtils
.
getRomInfo
())
.
create
()
}
override
fun
doBusiness
()
{
}
override
fun
onWidgetClick
(
view
:
View
)
{
}
}
utilcode/pkg/src/main/res/layout/activity_rom.xml
0 → 100644
浏览文件 @
c1ed4cd2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:padding=
"@dimen/spacing_16"
>
<TextView
android:id=
"@+id/romAboutTv"
style=
"@style/TextStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
utilcode/pkg/src/main/res/layout/activity_util_core.xml
浏览文件 @
c1ed4cd2
...
...
@@ -154,6 +154,13 @@
android:onClick=
"resourceClick"
android:text=
"@string/demo_resource"
/>
<Button
style=
"@style/WideBtnStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"romClick"
android:text=
"@string/demo_rom"
/>
<Button
style=
"@style/WideBtnStyle"
android:layout_width=
"match_parent"
...
...
utilcode/pkg/src/main/res/values/strings.xml
浏览文件 @
c1ed4cd2
...
...
@@ -23,6 +23,7 @@
<string
name=
"demo_reflect"
>
ReflectUtils Demo
</string>
<string
name=
"demo_resource"
>
ResourceUtils Demo
</string>
<string
name=
"demo_screen"
>
ScreenUtils Demo
</string>
<string
name=
"demo_rom"
>
RomUtils Demo
</string>
<string
name=
"demo_sdcard"
>
SDCardUtils Demo
</string>
<string
name=
"demo_snackbar"
>
SnackbarUtils Demo
</string>
<string
name=
"demo_spStatic"
>
SPStaticUtils Demo
</string>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录