[core] Don't trust SystemProperties (#970)
This commit is contained in:
parent
c278d5f35b
commit
dbc6df3cf3
|
|
@ -1,15 +1,15 @@
|
||||||
package org.lsposed.lspd.service;
|
package org.lsposed.lspd.service;
|
||||||
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.lsposed.lspd.util.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public class LogcatService implements Runnable {
|
public class LogcatService implements Runnable {
|
||||||
|
|
@ -22,8 +22,7 @@ public class LogcatService implements Runnable {
|
||||||
public LogcatService(File logPath) {
|
public LogcatService(File logPath) {
|
||||||
System.loadLibrary("daemon");
|
System.loadLibrary("daemon");
|
||||||
this.logPath = logPath;
|
this.logPath = logPath;
|
||||||
var zone = ZoneId.of(SystemProperties.get("persist.sys.timezone", "GMT"));
|
logTimeFormat = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(Utils.getZoneId());
|
||||||
logTimeFormat = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(zone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,10 @@ package org.lsposed.lspd.util;
|
||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.SystemProperties;
|
|
||||||
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
@ -39,7 +37,7 @@ public class ModuleLogger {
|
||||||
public static void initLogger(ParcelFileDescriptor fileDescriptor) {
|
public static void initLogger(ParcelFileDescriptor fileDescriptor) {
|
||||||
if (fd == null && fileDescriptor != null) {
|
if (fd == null && fileDescriptor != null) {
|
||||||
fd = fileDescriptor;
|
fd = fileDescriptor;
|
||||||
var zone = ZoneId.of(SystemProperties.get("persist.sys.timezone", "GMT"));
|
var zone = Utils.getZoneId();
|
||||||
var pattern = "uuuu-MM-dd'T'HH:mm:ss.SSS"; // DateTimeFormatter.ISO_LOCAL_DATE_TIME
|
var pattern = "uuuu-MM-dd'T'HH:mm:ss.SSS"; // DateTimeFormatter.ISO_LOCAL_DATE_TIME
|
||||||
logDateFormat = DateTimeFormatter.ofPattern(pattern, Locale.ROOT).withZone(zone);
|
logDateFormat = DateTimeFormatter.ofPattern(pattern, Locale.ROOT).withZone(zone);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ import android.util.Log;
|
||||||
|
|
||||||
import org.lsposed.lspd.BuildConfig;
|
import org.lsposed.lspd.BuildConfig;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.zone.ZoneRulesException;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final String LOG_TAG = "LSPosed";
|
public static final String LOG_TAG = "LSPosed";
|
||||||
|
|
@ -64,4 +68,13 @@ public class Utils {
|
||||||
public static void logE(String msg, Throwable throwable) {
|
public static void logE(String msg, Throwable throwable) {
|
||||||
Log.e(LOG_TAG, msg, throwable);
|
Log.e(LOG_TAG, msg, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ZoneId getZoneId() {
|
||||||
|
var timezone = SystemProperties.get("persist.sys.timezone", "GMT");
|
||||||
|
try {
|
||||||
|
return ZoneId.of(timezone);
|
||||||
|
} catch (ZoneRulesException e) {
|
||||||
|
return ZoneOffset.UTC;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue