Use java8 time API (#952)
This commit is contained in:
parent
c77d122254
commit
70344ff9fd
|
|
@ -182,7 +182,7 @@ public class App extends Application {
|
|||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||
Log.e(App.TAG, e.getMessage(), e);
|
||||
Log.e(App.TAG, "loadRemoteVersion: " + e.getMessage());
|
||||
if (pref.getBoolean("checked", false)) return;
|
||||
pref.edit().putBoolean("checked", true).apply();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,8 @@ import org.lsposed.manager.BuildConfig;
|
|||
import org.lsposed.manager.R;
|
||||
import org.lsposed.manager.databinding.ActivityCrashReportBinding;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class CrashReportActivity extends AppCompatActivity {
|
||||
ActivityCrashReportBinding binding;
|
||||
|
|
@ -62,21 +60,16 @@ public class CrashReportActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
public String getAllErrorDetailsFromIntent(@NonNull Intent intent) {
|
||||
Date currentDate = new Date();
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
|
||||
|
||||
var dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
String versionName = String.format("%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
|
||||
|
||||
String errorDetails = "";
|
||||
|
||||
errorDetails += "Build version: " + versionName + " \n";
|
||||
errorDetails += "Current date: " + dateFormat.format(currentDate) + " \n";
|
||||
errorDetails += "Device: " + getDeviceModelName() + " \n";
|
||||
errorDetails += "Fingerprint: " + getFingerprint() + " \n \n";
|
||||
errorDetails += "SDK: " + Build.VERSION.SDK_INT + " \n \n";
|
||||
errorDetails += "Stack trace: \n";
|
||||
errorDetails += getStackTraceFromIntent(intent);
|
||||
return errorDetails;
|
||||
return "Build version: " + versionName + " \n" +
|
||||
"Current date: " + dateFormat.format(Instant.now()) + " \n" +
|
||||
"Device: " + getDeviceModelName() + " \n" +
|
||||
"Fingerprint: " + getFingerprint() + " \n \n" +
|
||||
"SDK: " + Build.VERSION.SDK_INT + " \n \n" +
|
||||
"Stack trace: \n" +
|
||||
getStackTraceFromIntent(intent);
|
||||
}
|
||||
|
||||
private String getFingerprint() {
|
||||
|
|
|
|||
|
|
@ -23,22 +23,25 @@ package org.lsposed.lspd.util;
|
|||
import android.app.ActivityThread;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.Process;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class ModuleLogger {
|
||||
static SimpleDateFormat logDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.sss", Locale.getDefault());
|
||||
static ParcelFileDescriptor fd = null;
|
||||
private static DateTimeFormatter logDateFormat;
|
||||
private static ParcelFileDescriptor fd = null;
|
||||
|
||||
public static void initLogger(ParcelFileDescriptor fileDescriptor) {
|
||||
if (fd == null && fileDescriptor != null) {
|
||||
fd = fileDescriptor;
|
||||
logDateFormat.setTimeZone(TimeZone.getDefault());
|
||||
var zone = ZoneId.of(SystemProperties.get("persist.sys.timezone"));
|
||||
var pattern = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
logDateFormat = DateTimeFormatter.ofPattern(pattern, Locale.ROOT).withZone(zone);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ public class ModuleLogger {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
String processName = ActivityThread.currentProcessName();
|
||||
|
||||
sb.append(logDateFormat.format(new Date()));
|
||||
sb.append(logDateFormat.format(Instant.now()));
|
||||
sb.append(' ');
|
||||
sb.append(isThrowable ? "E" : "I");
|
||||
sb.append('/');
|
||||
|
|
|
|||
Loading…
Reference in New Issue