Skip to content

Commit 1de559c

Browse files
committed
see 04/18 log
1 parent 9bafcbf commit 1de559c

File tree

10 files changed

+48
-10
lines changed

10 files changed

+48
-10
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.13.13-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.14-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.13.13-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.14-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

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

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dependencies {
5757
// LeakCanary
5858
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
5959
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
60-
// implementation 'com.blankj:utilcode:1.13.13'
60+
// implementation 'com.blankj:utilcode:1.13.14'
6161
}
6262

6363

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ ext {
3333
min_sdk_version = 14
3434
target_sdk_version = 27
3535

36-
version_code = 1_013_013
37-
version_name = '1.13.13'// E.g 1.9.72 => 1,009,072
36+
version_code = 1_013_014
37+
version_name = '1.13.14'// E.g 1.9.72 => 1,009,072
3838

3939
// App dependencies
4040
support_version = '27.1.0'

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 18/04/19 新增 Process#isMainProcess 和 Process#getCurrentProcessName,发布 1.13.14 版本
12
* 18/04/18 修复 LogUtils 头部空指针异常,SPUtils、CacheUtils 存储空值异常,发布 1.13.13 版本
23
* 18/04/17 修复 ToastUtils 内存泄漏问题,感谢 [LambertCoding](https://github.com/LambertCoding),发布 1.13.12 版本
34
* 18/04/16 完善 AppUtils#installAppSilent 路径包含空格问题,发布 1.13.11 版本

utilcode/README-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

88

@@ -430,6 +430,8 @@ sendSmsSilent : 发送短信
430430
getForegroundProcessName : 获取前台线程包名
431431
killAllBackgroundProcesses: 杀死所有的后台服务进程
432432
killBackgroundProcesses : 杀死后台服务进程
433+
isMainProcess : 判断是否运行在主进程
434+
getCurrentProcessName : 获取当前进程名称
433435
```
434436

435437
* ### 反射相关 -> [ReflectUtils.java][reflect.java] -> [Test][reflect.test]

utilcode/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

88

@@ -430,6 +430,8 @@ sendSmsSilent
430430
getForegroundProcessName
431431
killAllBackgroundProcesses
432432
killBackgroundProcesses
433+
isMainProcess
434+
getCurrentProcessName
433435
```
434436

435437
* ### About Reflect -> [ReflectUtils.java][reflect.java] -> [Test][reflect.test]

utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static boolean installAppSilent(final File file) {
130130
* {@code <uses-permission android:name="android.permission.INSTALL_PACKAGES" />}</p>
131131
*
132132
* @param filePath The path of file.
133-
* @param params The params of installation.
133+
* @param params The params of installation(e.g.,<code>-r</code>, <code>-s</code>).
134134
* @return {@code true}: success<br>{@code false}: fail
135135
*/
136136
public static boolean installAppSilent(final String filePath, final String params) {
@@ -143,7 +143,7 @@ public static boolean installAppSilent(final String filePath, final String param
143143
* {@code <uses-permission android:name="android.permission.INSTALL_PACKAGES" />}</p>
144144
*
145145
* @param file The file.
146-
* @param params The params of installation.
146+
* @param params The params of installation(e.g.,<code>-r</code>, <code>-s</code>).
147147
* @return {@code true}: success<br>{@code false}: fail
148148
*/
149149
public static boolean installAppSilent(final File file, final String params) {

utilcode/src/main/java/com/blankj/utilcode/util/BarUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import java.lang.reflect.Method;
2424

25+
import static android.Manifest.permission.EXPAND_STATUS_BAR;
26+
2527
/**
2628
* <pre>
2729
* author: Blankj
@@ -515,7 +517,7 @@ public static int getActionBarHeight() {
515517
*
516518
* @param isVisible True to set notification bar visible, false otherwise.
517519
*/
518-
@RequiresPermission(android.Manifest.permission.EXPAND_STATUS_BAR)
520+
@RequiresPermission(EXPAND_STATUS_BAR)
519521
public static void setNotificationBarVisibility(final boolean isVisible) {
520522
String methodName;
521523
if (isVisible) {

utilcode/src/main/java/com/blankj/utilcode/util/ProcessUtils.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.content.pm.ApplicationInfo;
1010
import android.content.pm.PackageManager;
1111
import android.content.pm.ResolveInfo;
12+
import android.os.Process;
1213
import android.provider.Settings;
1314
import android.support.annotation.NonNull;
1415
import android.support.annotation.RequiresPermission;
@@ -193,4 +194,34 @@ public static boolean killBackgroundProcesses(@NonNull final String packageName)
193194
}
194195
return true;
195196
}
197+
198+
/**
199+
* Return whether app running in the main process.
200+
*
201+
* @return {@code true}: yes<br>{@code false}: no
202+
*/
203+
public static boolean isMainProcess() {
204+
return Utils.getApp().getPackageName().equals(getCurrentProcessName());
205+
}
206+
207+
/**
208+
* Return the name of current process.
209+
*
210+
* @return the name of current process
211+
*/
212+
public static String getCurrentProcessName() {
213+
ActivityManager am = (ActivityManager) Utils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
214+
if (am == null) return null;
215+
List<ActivityManager.RunningAppProcessInfo> info = am.getRunningAppProcesses();
216+
if (info == null || info.size() == 0) return null;
217+
int pid = Process.myPid();
218+
for (ActivityManager.RunningAppProcessInfo aInfo : info) {
219+
if (aInfo.pid == pid) {
220+
if (aInfo.processName != null) {
221+
return aInfo.processName;
222+
}
223+
}
224+
}
225+
return null;
226+
}
196227
}

0 commit comments

Comments
 (0)