[FIX] 修復閒置逾時觸發與資源釋放問題,並修正介面字串

1. 於 AppCompatActivityAbstract 覆寫 onUserInteraction(),在使用者互動時主動更新最後互動時間。
2. 於 HomeActivity.onDestroy() 增加 reportOnScheduler 的生命週期管理,於銷毀時執行 shutdown() 以防止執行緒洩漏。
3. 於 FontendActivity 的閒置逾時機制中,增加開發者/主控台模式判定,若處於該模式則重設計時器、不返回待機頁。
4. 修改 strings.xml 中的 slave_machine_software 字串,由「結構設定APP」修正為「下位機設定」。
This commit is contained in:
sky121113 2026-05-20 11:30:39 +08:00
parent d13546b379
commit 422459a0c3
4 changed files with 16 additions and 1 deletions

View File

@ -78,4 +78,10 @@ public abstract class AppCompatActivityAbstract extends AppCompatActivity {
finish();
}
}
@Override
public void onUserInteraction() {
super.onUserInteraction();
com.unibuy.smartdevice.MyApp.getInstance().updateLastInteraction();
}
}

View File

@ -614,6 +614,9 @@ public class HomeActivity extends AppCompatActivityAbstract {
protected void onDestroy() {
super.onDestroy();
stopOnSwitchFragment();
if (reportOnScheduler != null) {
reportOnScheduler.shutdown();
}
// 取消註冊廣告更新監聽
try {
unregisterReceiver(adUpdateReceiver);

View File

@ -483,6 +483,12 @@ public class FontendActivity extends AppCompatActivityAbstract {
}
idleRunnable = () -> {
// 🚩 若目前處於主控台/管理員模式則忽略閒置返回待機頁的觸發並重新計時
if (!MyApp.getInstance().getSuAccess().isEmpty()) {
getLogs().info(" 偵測到當前處於開發者/主控台模式,忽略閒置返回待機頁的觸發。");
resetIdleTimer();
return;
}
getLogs().info("⚠️ 無操作 3 分鐘,自動返回首頁(清空購物車)");
MyApp.getInstance().getBuyList().clear(); // 🚩 逾時返回首頁時務必清空購物車避免機台進入永久忙碌狀態
Intent intent = new Intent(FontendActivity.this, HomeActivity.class);

View File

@ -142,7 +142,7 @@
<string name="card_machine_checkout">刷卡機結帳</string>
<string name="card_machine_restart">刷卡機重啟</string>
<string name="scan_dock_test">掃碼頭測試</string>
<string name="slave_machine_software">結構設定APP</string>
<string name="slave_machine_software">下位機設定</string>
<string name="slave_machine_detection">下位機檢測</string>
<string name="electronic_controller_detection">電控器檢測</string>
<string name="other_test">其他測試</string>