Skip to content

Commit 64f4fbe

Browse files
committed
logging: add lifecycle, config, and connectivity diagnostics
- Log onCreate with pid + key settings (allow_sleep, super_sleep, auto_disable_wifi, allow_http) so config issues are immediately visible in logcat - Log onResume/onPause/onDestroy with pid so app restarts vs. normal lifecycle transitions are distinguishable in a logcat dump - Log when onPause cancels the refresh timer so it's clear why the next fetch reason is onResume instead of timer - Expand connectivity timeout log to include wifi enabled state, IP address, and rssi at the moment of timeout instead of just a generic message - Include path and dir-exists check in screensaver write failure log
1 parent da854a8 commit 64f4fbe

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/com/bpmct/trmnl_nook_simple_touch/DisplayActivity.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ protected void onCreate(Bundle savedInstanceState) {
106106

107107
// Initialize file logging from saved preference
108108
FileLogger.setEnabled(ApiPrefs.isFileLoggingEnabled(this));
109+
logD("onCreate pid=" + android.os.Process.myPid()
110+
+ " allow_sleep=" + ApiPrefs.isAllowSleep(this)
111+
+ " super_sleep=" + ApiPrefs.isSuperSleep(this)
112+
+ " auto_disable_wifi=" + ApiPrefs.isAutoDisableWifi(this)
113+
+ " allow_http=" + ApiPrefs.isAllowHttp(this));
109114

110115
// Write the generic screensaver on first-ever launch so NOOK shows something
111116
// branded if it sleeps before any API image has been displayed.
@@ -372,6 +377,7 @@ public void onReceive(Context context, Intent intent) {
372377
@Override
373378
protected void onResume() {
374379
super.onResume();
380+
logD("onResume pid=" + android.os.Process.myPid() + " fetchInProgress=" + fetchInProgress);
375381
getWindow().setFlags(
376382
WindowManager.LayoutParams.FLAG_FULLSCREEN,
377383
WindowManager.LayoutParams.FLAG_FULLSCREEN);
@@ -460,7 +466,14 @@ public void run() {
460466
@Override
461467
public void run() {
462468
pendingConnectivityTimeoutRunnable = null;
463-
logD("connectivity wait timed out");
469+
WifiManager wm = (WifiManager) a.getSystemService(Context.WIFI_SERVICE);
470+
String wifiDetail = "unknown";
471+
if (wm != null) {
472+
wifiDetail = "enabled=" + wm.isWifiEnabled();
473+
WifiInfo wi = wm.getConnectionInfo();
474+
if (wi != null) wifiDetail += " ip=" + wi.getIpAddress() + " rssi=" + wi.getRssi();
475+
}
476+
logD("connectivity wait timed out after " + (CONNECTIVITY_MAX_WAIT_MS / 1000L) + "s wifi=" + wifiDetail);
464477
logD("Ensure you are connected to WiFi. Press the home button and go into settings to configure.");
465478
cancelConnectivityWait();
466479
if (showErrorInMenu) {
@@ -551,6 +564,7 @@ private void applyIntentState(Intent intent) {
551564
@Override
552565
protected void onPause() {
553566
super.onPause();
567+
logD("onPause pid=" + android.os.Process.myPid() + " fetchInProgress=" + fetchInProgress);
554568
// Restore screen timeout whenever we leave — user is navigating around the device.
555569
try {
556570
android.provider.Settings.System.putInt(
@@ -560,6 +574,7 @@ protected void onPause() {
560574
} catch (Throwable t) { /* ignore */ }
561575
if (refreshRunnable != null) {
562576
refreshHandler.removeCallbacks(refreshRunnable);
577+
logD("onPause: refresh timer cancelled (fetchInProgress=" + fetchInProgress + ")");
563578
}
564579
if (pendingSleepRunnable != null) {
565580
refreshHandler.removeCallbacks(pendingSleepRunnable);
@@ -582,6 +597,7 @@ protected void onPause() {
582597

583598
@Override
584599
protected void onDestroy() {
600+
logD("onDestroy pid=" + android.os.Process.myPid());
585601
cancelConnectivityWait();
586602
// Safety net: always restore screen timeout in case the app dies before onResume
587603
try {
@@ -766,7 +782,8 @@ private void writeScreenshotToScreensaver(Bitmap bitmap) {
766782
out.close();
767783
logD("screensaver written: " + path);
768784
} catch (Throwable t) {
769-
logW("screensaver write failed: " + t);
785+
logW("screensaver write failed: " + path + " — " + t
786+
+ " (dir exists=" + new File(dirPath).exists() + ")");
770787
}
771788
}
772789

0 commit comments

Comments
 (0)