Skip to content

Commit

Permalink
see 04/18 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Apr 18, 2018
1 parent 9bafcbf commit 1de559c
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

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

[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.13-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.14-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.13.13-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.14-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
// LeakCanary
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
// implementation 'com.blankj:utilcode:1.13.13'
// implementation 'com.blankj:utilcode:1.13.14'
}


4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ ext {
min_sdk_version = 14
target_sdk_version = 27

version_code = 1_013_013
version_name = '1.13.13'// E.g 1.9.72 => 1,009,072
version_code = 1_013_014
version_name = '1.13.14'// E.g 1.9.72 => 1,009,072

// App dependencies
support_version = '27.1.0'
Expand Down
1 change: 1 addition & 0 deletions update_log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* 18/04/19 新增 Process#isMainProcess 和 Process#getCurrentProcessName,发布 1.13.14 版本
* 18/04/18 修复 LogUtils 头部空指针异常,SPUtils、CacheUtils 存储空值异常,发布 1.13.13 版本
* 18/04/17 修复 ToastUtils 内存泄漏问题,感谢 [LambertCoding](https://github.com/LambertCoding),发布 1.13.12 版本
* 18/04/16 完善 AppUtils#installAppSilent 路径包含空格问题,发布 1.13.11 版本
Expand Down
4 changes: 3 additions & 1 deletion utilcode/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gradle:
```groovy
implementation 'com.blankj:utilcode:1.13.13'
implementation 'com.blankj:utilcode:1.13.14'
```


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

* ### 反射相关 -> [ReflectUtils.java][reflect.java] -> [Test][reflect.test]
Expand Down
4 changes: 3 additions & 1 deletion utilcode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gradle:
```groovy
implementation 'com.blankj:utilcode:1.13.13'
implementation 'com.blankj:utilcode:1.13.14'
```


Expand Down Expand Up @@ -430,6 +430,8 @@ sendSmsSilent
getForegroundProcessName
killAllBackgroundProcesses
killBackgroundProcesses
isMainProcess
getCurrentProcessName
```

* ### About Reflect -> [ReflectUtils.java][reflect.java] -> [Test][reflect.test]
Expand Down
4 changes: 2 additions & 2 deletions utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static boolean installAppSilent(final File file) {
* {@code <uses-permission android:name="android.permission.INSTALL_PACKAGES" />}</p>
*
* @param filePath The path of file.
* @param params The params of installation.
* @param params The params of installation(e.g.,<code>-r</code>, <code>-s</code>).
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean installAppSilent(final String filePath, final String params) {
Expand All @@ -143,7 +143,7 @@ public static boolean installAppSilent(final String filePath, final String param
* {@code <uses-permission android:name="android.permission.INSTALL_PACKAGES" />}</p>
*
* @param file The file.
* @param params The params of installation.
* @param params The params of installation(e.g.,<code>-r</code>, <code>-s</code>).
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean installAppSilent(final File file, final String params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import java.lang.reflect.Method;

import static android.Manifest.permission.EXPAND_STATUS_BAR;

/**
* <pre>
* author: Blankj
Expand Down Expand Up @@ -515,7 +517,7 @@ public static int getActionBarHeight() {
*
* @param isVisible True to set notification bar visible, false otherwise.
*/
@RequiresPermission(android.Manifest.permission.EXPAND_STATUS_BAR)
@RequiresPermission(EXPAND_STATUS_BAR)
public static void setNotificationBarVisibility(final boolean isVisible) {
String methodName;
if (isVisible) {
Expand Down
31 changes: 31 additions & 0 deletions utilcode/src/main/java/com/blankj/utilcode/util/ProcessUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Process;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresPermission;
Expand Down Expand Up @@ -193,4 +194,34 @@ public static boolean killBackgroundProcesses(@NonNull final String packageName)
}
return true;
}

/**
* Return whether app running in the main process.
*
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isMainProcess() {
return Utils.getApp().getPackageName().equals(getCurrentProcessName());
}

/**
* Return the name of current process.
*
* @return the name of current process
*/
public static String getCurrentProcessName() {
ActivityManager am = (ActivityManager) Utils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
if (am == null) return null;
List<ActivityManager.RunningAppProcessInfo> info = am.getRunningAppProcesses();
if (info == null || info.size() == 0) return null;
int pid = Process.myPid();
for (ActivityManager.RunningAppProcessInfo aInfo : info) {
if (aInfo.pid == pid) {
if (aInfo.processName != null) {
return aInfo.processName;
}
}
}
return null;
}
}

0 comments on commit 1de559c

Please sign in to comment.