Skip to content

Commit

Permalink
[bug] Fix FD info error in java crash tombstone.
Browse files Browse the repository at this point in the history
When API level is greater than or equal to 21, use android.system.Os.readlink() instead of java.io.File#getCanonicalPath().
  • Loading branch information
caikelun committed Dec 19, 2019
1 parent 9c94c54 commit 9ce3a1b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/java/xcrash/xcrash_lib/src/main/java/xcrash/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.content.Context;
import android.os.Build;
import android.os.Debug;
import android.system.Os;
import android.text.TextUtils;

import java.io.BufferedReader;
Expand Down Expand Up @@ -363,11 +364,15 @@ public boolean accept(File dir, String name) {
for (File fd : fds) {
String path = null;
try {
path = fd.getCanonicalPath();
if (Build.VERSION.SDK_INT >= 21) {
path = Os.readlink(fd.getAbsolutePath());
} else {
path = fd.getCanonicalPath();
}
} catch (Exception ignored) {
}
sb.append(" fd ").append(fd.getName()).append(": ")
.append(TextUtils.isEmpty(path) ? "???" : path).append('\n');
.append(TextUtils.isEmpty(path) ? "???" : path.trim()).append('\n');

count++;
if (count > 1024) {
Expand Down

0 comments on commit 9ce3a1b

Please sign in to comment.