Skip to content

Commit 72af9eb

Browse files
committed
see 04/08 log
1 parent 9d01300 commit 72af9eb

File tree

9 files changed

+36
-36
lines changed

9 files changed

+36
-36
lines changed

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.0'

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
@@ -231,17 +231,21 @@ private static String getCurrentProcessNameByFile() {
231231
}
232232

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

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
@@ -5,6 +5,7 @@
55
import android.app.Application;
66
import android.arch.lifecycle.Lifecycle;
77
import android.support.annotation.NonNull;
8+
import android.util.Log;
89

910
/**
1011
* <pre>
@@ -48,14 +49,17 @@ public static void init(final Application app) {
4849

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

6165
///////////////////////////////////////////////////////////////////////////

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
@@ -260,8 +260,8 @@ static File getFileByPath(final String filePath) {
260260
return FileUtils.getFileByPath(filePath);
261261
}
262262

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

267267
static boolean createOrExistsFile(final File file) {

0 commit comments

Comments
 (0)