Skip to content

Commit

Permalink
fix /data/local/tmp/stethox_suspend file not exist return
Browse files Browse the repository at this point in the history
  • Loading branch information
GangJust authored and 5ec1cff committed Feb 19, 2025
1 parent 92e8ca6 commit e2a431e
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private synchronized void initializeStetho(Context context) throws InterruptedEx
initialized = true;
return;
}

var processName = Utils.getProcessName();
Logger.d("Install Stetho: " + packageName + " proc=" + processName);
var suspendRequested = false;
Expand All @@ -79,18 +80,18 @@ private synchronized void initializeStetho(Context context) throws InterruptedEx
}

if (!suspendRequested) {

try {
var file = new File("/data/local/tmp/stethox_suspend");
if (!file.canRead()) return;
var bytes = new byte[(int) file.length()];
try (var is = new FileInputStream(file)) {
is.read(bytes);
}
var str = new String(bytes, StandardCharsets.UTF_8);
if (Arrays.asList(str.split("\n")).contains(processName)) {
suspendRequested = true;
Logger.d("suspend requested by file");
if (file.canRead()) {
var bytes = new byte[(int) file.length()];
try (var is = new FileInputStream(file)) {
is.read(bytes);
}
var str = new String(bytes, StandardCharsets.UTF_8);
if (Arrays.asList(str.split("\n")).contains(processName)) {
suspendRequested = true;
Logger.d("suspend requested by file");
}
}
} catch (Throwable t) {
Logger.e("get suspend file", t);
Expand Down

0 comments on commit e2a431e

Please sign in to comment.