[core] Use fd instead of realpath (#1170)
Co-authored-by: LoveSy <shana@zju.edu.cn>
This commit is contained in:
parent
361e05ea2e
commit
957896fd63
|
|
@ -36,11 +36,16 @@ public class LogcatService implements Runnable {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private int refreshFd(boolean isVerboseLog) {
|
private int refreshFd(boolean isVerboseLog) {
|
||||||
try {
|
try {
|
||||||
File log = isVerboseLog ? (verboseLog = ConfigFileManager.getNewVerboseLogPath()) :
|
File log = isVerboseLog ? ConfigFileManager.getNewVerboseLogPath() : ConfigFileManager.getNewModulesLogPath();
|
||||||
(modulesLog = ConfigFileManager.getNewModulesLogPath());
|
|
||||||
Log.i(TAG, "New " + (isVerboseLog ? "verbose" : "modules") + " log file: " + log);
|
Log.i(TAG, "New " + (isVerboseLog ? "verbose" : "modules") + " log file: " + log);
|
||||||
return ParcelFileDescriptor.open(log, mode).detachFd();
|
int fd = ParcelFileDescriptor.open(log, mode).detachFd();
|
||||||
|
var fdFile = new File("/proc/self/fd/" + fd);
|
||||||
|
if (isVerboseLog) verboseLog = fdFile;
|
||||||
|
else modulesLog = fdFile;
|
||||||
|
return fd;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
if (isVerboseLog) verboseLog = null;
|
||||||
|
else modulesLog = null;
|
||||||
Log.w(TAG, "someone chattr +i ?", e);
|
Log.w(TAG, "someone chattr +i ?", e);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue