Skip to content

Commit f8991e4

Browse files
committed
see 04/08 log
2 parents 23c1689 + 72af9eb commit f8991e4

File tree

13 files changed

+36
-40
lines changed

13 files changed

+36
-40
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Bug report
33
about: Make AndroidUtilCode more perfect!
4-
title: "[BUG]"
54
labels: bug
65
assignees: Blankj
76

.github/ISSUE_TEMPLATE/bug_report_cn.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: 提交 Bug
33
about: 让工具类更完美!
4-
title: "[BUG]"
54
labels: bug
65
assignees: Blankj
76

.github/ISSUE_TEMPLATE/feature-request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Feature request
33
about: Make AndroidUtilCode more perfect!
4-
title: "[FEATURE]"
54
labels: help wanted
65
assignees: Blankj
76

.github/ISSUE_TEMPLATE/feature-request_cn.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: 提交需求
33
about: 让工具类更健全!
4-
title: "[FEATURE]"
54
labels: help wanted
65
assignees: Blankj
76

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
* `20/04/08` [fix] CrashUtils DefaultUncaughtExceptionHandler is wrong; LogUtils write file failed. Publish v1.27.3.
1+
* `20/04/08` [fix] CleanUtils clean dir not work. Publish v1.27.4.
2+
* `20/04/08` [fix] CrashUtils DefaultUncaughtExceptionHandler is wrong; LogUtils write file failed; Utils#getApp failed run on remote process. Publish v1.27.3.
23
* `20/04/07` [mdf] GsonUtils#getGson() method public.
34
* `20/04/04` [fix] ShadowUtils bug running on lower version devices. Publish v1.27.2.
45
* `20/04/03` [fix] UtilsActivityLifecycleImpl#HashMap#remove IllegalStateException bug.

buildSrc/src/main/groovy/Config.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Config {
1515
static minSdkVersion = 14
1616
static targetSdkVersion = 29
1717
static versionCode = 1_026_001
18-
static versionName = '1.27.3'// E.g. 1.9.72 => 1,009,072
18+
static versionName = '1.27.4'// E.g. 1.9.72 => 1,009,072
1919

2020
// lib version
2121
static gradlePluginVersion = '3.5.2'

feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/messenger/MessengerActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.blankj.utilcode.pkg.R
1212
import com.blankj.utilcode.util.CollectionUtils
1313
import com.blankj.utilcode.util.MessengerUtils
1414
import com.blankj.utilcode.util.SnackbarUtils
15+
import com.blankj.utilcode.util.ToastUtils
1516

1617
/**
1718
* ```

lib/utilcode/README-CN.md

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

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.27.3'
5+
implementation 'com.blankj:utilcode:1.27.4'
66
77
// if u use AndroidX, use the following
8-
implementation 'com.blankj:utilcodex:1.27.3'
8+
implementation 'com.blankj:utilcodex:1.27.4'
99
```
1010

1111

lib/utilcode/README.md

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

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.27.3'
5+
implementation 'com.blankj:utilcode:1.27.4'
66
77
// if u use AndroidX, use the following
8-
implementation 'com.blankj:utilcodex:1.27.3'
8+
implementation 'com.blankj:utilcodex:1.27.4'
99
```
1010

1111

lib/utilcode/src/main/java/com/blankj/utilcode/util/CleanUtils.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private CleanUtils() {
2525
* @return {@code true}: success<br>{@code false}: fail
2626
*/
2727
public static boolean cleanInternalCache() {
28-
return cleanCustomDir(Utils.getApp().getCacheDir());
28+
return UtilsBridge.deleteAllInDir(Utils.getApp().getCacheDir());
2929
}
3030

3131
/**
@@ -35,7 +35,7 @@ public static boolean cleanInternalCache() {
3535
* @return {@code true}: success<br>{@code false}: fail
3636
*/
3737
public static boolean cleanInternalFiles() {
38-
return cleanCustomDir(Utils.getApp().getFilesDir());
38+
return UtilsBridge.deleteAllInDir(Utils.getApp().getFilesDir());
3939
}
4040

4141
/**
@@ -45,7 +45,7 @@ public static boolean cleanInternalFiles() {
4545
* @return {@code true}: success<br>{@code false}: fail
4646
*/
4747
public static boolean cleanInternalDbs() {
48-
return cleanCustomDir(new File(Utils.getApp().getFilesDir().getParent(), "databases"));
48+
return UtilsBridge.deleteAllInDir(new File(Utils.getApp().getFilesDir().getParent(), "databases"));
4949
}
5050

5151
/**
@@ -66,7 +66,7 @@ public static boolean cleanInternalDbByName(final String dbName) {
6666
* @return {@code true}: success<br>{@code false}: fail
6767
*/
6868
public static boolean cleanInternalSp() {
69-
return cleanCustomDir(new File(Utils.getApp().getFilesDir().getParent(), "shared_prefs"));
69+
return UtilsBridge.deleteAllInDir(new File(Utils.getApp().getFilesDir().getParent(), "shared_prefs"));
7070
}
7171

7272
/**
@@ -77,7 +77,7 @@ public static boolean cleanInternalSp() {
7777
*/
7878
public static boolean cleanExternalCache() {
7979
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
80-
&& cleanCustomDir(Utils.getApp().getExternalCacheDir());
80+
&& UtilsBridge.deleteAllInDir(Utils.getApp().getExternalCacheDir());
8181
}
8282

8383
/**
@@ -87,16 +87,6 @@ public static boolean cleanExternalCache() {
8787
* @return {@code true}: success<br>{@code false}: fail
8888
*/
8989
public static boolean cleanCustomDir(final String dirPath) {
90-
return cleanCustomDir(UtilsBridge.getFileByPath(dirPath));
91-
}
92-
93-
/**
94-
* Clean the custom directory.
95-
*
96-
* @param dir The directory.
97-
* @return {@code true}: success<br>{@code false}: fail
98-
*/
99-
public static boolean cleanCustomDir(final File dir) {
100-
return UtilsBridge.deleteFilesInDir(dir);
90+
return UtilsBridge.deleteAllInDir(UtilsBridge.getFileByPath(dirPath));
10191
}
10292
}

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,21 @@ private static String getCurrentProcessNameByFile() {
232232
}
233233

234234
private static String getCurrentProcessNameByAms() {
235-
ActivityManager am = (ActivityManager) Utils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
236-
if (am == null) return "";
237-
List<ActivityManager.RunningAppProcessInfo> info = am.getRunningAppProcesses();
238-
if (info == null || info.size() == 0) return "";
239-
int pid = android.os.Process.myPid();
240-
for (ActivityManager.RunningAppProcessInfo aInfo : info) {
241-
if (aInfo.pid == pid) {
242-
if (aInfo.processName != null) {
243-
return aInfo.processName;
235+
try {
236+
ActivityManager am = (ActivityManager) Utils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
237+
if (am == null) return "";
238+
List<ActivityManager.RunningAppProcessInfo> info = am.getRunningAppProcesses();
239+
if (info == null || info.size() == 0) return "";
240+
int pid = android.os.Process.myPid();
241+
for (ActivityManager.RunningAppProcessInfo aInfo : info) {
242+
if (aInfo.pid == pid) {
243+
if (aInfo.processName != null) {
244+
return aInfo.processName;
245+
}
244246
}
245247
}
248+
} catch (Exception e) {
249+
return "";
246250
}
247251
return "";
248252
}

lib/utilcode/src/main/java/com/blankj/utilcode/util/Utils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.annotation.SuppressLint;
44
import android.app.Activity;
55
import android.app.Application;
6+
import android.util.Log;
67

78
import androidx.annotation.NonNull;
89
import androidx.lifecycle.Lifecycle;
@@ -49,14 +50,17 @@ public static void init(final Application app) {
4950

5051
/**
5152
* Return the Application object.
53+
* <p>Main process get app by UtilsFileProvider,
54+
* and other process get app by reflect.</p>
5255
*
5356
* @return the Application object
5457
*/
5558
public static Application getApp() {
5659
if (sApp != null) return sApp;
57-
sApp = UtilsBridge.getApplicationByReflect();
58-
if (sApp != null) return sApp;
59-
throw new NullPointerException("UtilsFileProvider load failed && reflect failed.");
60+
init(UtilsBridge.getApplicationByReflect());
61+
if (sApp == null) throw new NullPointerException("reflect failed.");
62+
Log.i("Utils", UtilsBridge.getCurrentProcessName() + " reflect app success.");
63+
return sApp;
6064
}
6165

6266
///////////////////////////////////////////////////////////////////////////

lib/utilcode/src/main/java/com/blankj/utilcode/util/UtilsBridge.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ static File getFileByPath(final String filePath) {
261261
return FileUtils.getFileByPath(filePath);
262262
}
263263

264-
static boolean deleteFilesInDir(final File dir) {
265-
return FileUtils.deleteFilesInDir(dir);
264+
static boolean deleteAllInDir(final File dir) {
265+
return FileUtils.deleteAllInDir(dir);
266266
}
267267

268268
static boolean createOrExistsFile(final File file) {

0 commit comments

Comments
 (0)