Don't use shell context to getprop (#1362)
* [core] Getprop * [app] Remove getprop
This commit is contained in:
parent
8c593f725a
commit
971bcc6946
|
|
@ -222,17 +222,9 @@ public class LogsFragment extends BaseFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try (var is = Runtime.getRuntime().exec("getprop").getInputStream()) {
|
|
||||||
os.putNextEntry(new ZipEntry("system_props.log"));
|
|
||||||
FileUtils.copy(is, os);
|
|
||||||
os.closeEntry();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w(TAG, "system_props.log", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
var now = LocalDateTime.now();
|
var now = LocalDateTime.now();
|
||||||
var name = "app_" + now.toString() + ".log";
|
var name = "app_" + now.toString() + ".log";
|
||||||
try (var is = Runtime.getRuntime().exec("logcat -d").getInputStream()) {
|
try (var is = new ProcessBuilder("logcat", "-d").start().getInputStream()) {
|
||||||
os.putNextEntry(new ZipEntry(name));
|
os.putNextEntry(new ZipEntry(name));
|
||||||
FileUtils.copy(is, os);
|
FileUtils.copy(is, os);
|
||||||
os.closeEntry();
|
os.closeEntry();
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,11 @@ public class ConfigFileManager {
|
||||||
return logDirPath.resolve(getNewLogFileName("modules")).toFile();
|
return logDirPath.resolve(getNewLogFileName("modules")).toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static File getpropsLogPath() throws IOException {
|
||||||
|
createLogDirPath();
|
||||||
|
return logDirPath.resolve("props.log").toFile();
|
||||||
|
}
|
||||||
|
|
||||||
static Map<String, ParcelFileDescriptor> getLogs() {
|
static Map<String, ParcelFileDescriptor> getLogs() {
|
||||||
var map = new LinkedHashMap<String, ParcelFileDescriptor>();
|
var map = new LinkedHashMap<String, ParcelFileDescriptor>();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -796,6 +796,7 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAddShortcut() {
|
public boolean isAddShortcut() {
|
||||||
|
Log.d(TAG, "Auto add shortcut=" + autoAddShortcut);
|
||||||
return autoAddShortcut;
|
return autoAddShortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,20 @@ package org.lsposed.lspd.service;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.system.ErrnoException;
|
||||||
|
import android.system.Os;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.lsposed.lspd.BuildConfig;
|
import org.lsposed.lspd.BuildConfig;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.LinkOption;
|
import java.nio.file.LinkOption;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
public class LogcatService implements Runnable {
|
public class LogcatService implements Runnable {
|
||||||
private static final String TAG = "LSPosedLogcat";
|
private static final String TAG = "LSPosedLogcat";
|
||||||
|
|
@ -102,6 +106,39 @@ public class LogcatService implements Runnable {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
getprop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GetProp implements Runnable {
|
||||||
|
private volatile InputStream is;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Os.setuid(9999); // AID_NOBODY
|
||||||
|
is = new ProcessBuilder("getprop").start().getInputStream();
|
||||||
|
} catch (ErrnoException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getValue() {
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getprop() {
|
||||||
|
try {
|
||||||
|
var get = new GetProp();
|
||||||
|
var thread = new Thread(get);
|
||||||
|
thread.start();
|
||||||
|
thread.join();
|
||||||
|
var is = get.getValue();
|
||||||
|
var propsLogPath = ConfigFileManager.getpropsLogPath();
|
||||||
|
Files.copy(is, propsLogPath.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
Log.e(TAG, "getprop: " + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startVerbose() {
|
public void startVerbose() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue