[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")
|
||||
private int refreshFd(boolean isVerboseLog) {
|
||||
try {
|
||||
File log = isVerboseLog ? (verboseLog = ConfigFileManager.getNewVerboseLogPath()) :
|
||||
(modulesLog = ConfigFileManager.getNewModulesLogPath());
|
||||
File log = isVerboseLog ? ConfigFileManager.getNewVerboseLogPath() : ConfigFileManager.getNewModulesLogPath();
|
||||
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) {
|
||||
if (isVerboseLog) verboseLog = null;
|
||||
else modulesLog = null;
|
||||
Log.w(TAG, "someone chattr +i ?", e);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue