feat:设备日志模块

feat:定时任务
feat:设置页面用路由重构
This commit is contained in:
dzc committed 2026-07-30 13:16:14 +08:00
1 parent 1033f403b1
commit 2efa7a3c19
60 files changed
+6560 -643

No files matched your search

@@ -15,7 +15,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_PATH = "pj_cashier/database";
private static final String DATABASE_NAME = "cash_register.db";
private static final int DATABASE_VERSION = 7;
/** 与 Flutter Floor 的 @Database 版本保持一致,避免原生层提前推进 user_version。 */
private static final int DATABASE_VERSION = 8;
public DatabaseHelper(Context context) {
super(context, getCustomDatabasePath(context), null, DATABASE_VERSION);
@@ -1,11 +1,15 @@
package com.example.pj_supermarket_cloud
import android.content.Context
import android.app.ActivityManager
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.net.TrafficStats
import android.hardware.display.DisplayManager
import android.os.Build
import android.os.Debug
import android.os.Process
import android.os.StatFs
import android.telephony.TelephonyManager
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
@@ -49,6 +53,7 @@ class MainActivity : FlutterActivity() {
)
}
"getNetworkSnapshot" -> result.success(getNetworkSnapshot())
"getPerformanceSnapshot" -> result.success(getPerformanceSnapshot())
"isSubScreenShowing" -> result.success(
FlutterSubScreenProvider.instance.presentation?.isShowing == true
)
@@ -174,6 +179,26 @@ class MainActivity : FlutterActivity() {
)
}
/**
* 返回轻量的进程与设备资源快照。CPU 使用率由 Flutter 比较两次累计进程时间计算,
* 原生层不创建额外线程或定时器,避免运行状态展示反过来增加终端负载。
*/
private fun getPerformanceSnapshot(): Map<String, Any> {
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val memoryInfo = ActivityManager.MemoryInfo()
activityManager.getMemoryInfo(memoryInfo)
val storage = StatFs(filesDir.absolutePath)
return mapOf(
"processCpuTimeMs" to Process.getElapsedCpuTime(),
"logicalProcessorCount" to Runtime.getRuntime().availableProcessors().coerceAtLeast(1),
"memoryTotalBytes" to memoryInfo.totalMem,
"memoryAvailableBytes" to memoryInfo.availMem,
"appMemoryBytes" to Debug.getPss().toLong() * 1024L,
"storageTotalBytes" to storage.totalBytes,
"storageAvailableBytes" to storage.availableBytes
)
}
@Suppress("DEPRECATION")
private fun mobileNetworkType(): String {
return try {