App 2.19.9: remove the Foreground apps card from the Logs tab

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-23 22:20:18 +02:00
co-authored by Claude Opus 5.5
parent e2922e4842
commit 71aceaa626
11 changed files with 14 additions and 333 deletions
@@ -203,47 +203,11 @@ public class MainActivity extends AppCompatActivity {
}
((TextView) findViewById(R.id.header_title)).setText(PAGE_TITLES[position]);
((TextView) findViewById(R.id.header_subtitle)).setText(PAGE_SUBTITLES[position]);
if (panes != null && panes[position] == logPane) refreshForeground();
}
private TextView foregroundText;
private final java.util.concurrent.ExecutorService diagReader =
java.util.concurrent.Executors.newSingleThreadExecutor(r -> new Thread(r, "foreground-read"));
/** Logs tab diagnostic: reads which apps were in front, off the main thread. Changes nothing. */
private void refreshForeground() {
if (foregroundText == null) return;
try {
diagReader.execute(() -> {
ForegroundProbe.Result r = ForegroundProbe.read(getApplicationContext());
runOnUiThread(() -> { if (!isDestroyed()) foregroundText.setText(foregroundReport(r)); });
});
} catch (java.util.concurrent.RejectedExecutionException ignored) {
// Activity going away.
}
}
private String foregroundReport(ForegroundProbe.Result r) {
StringBuilder sb = new StringBuilder();
if (r.recent == null) {
sb.append(getString(R.string.foreground_unavailable)).append('\n');
} else if (r.recent.isEmpty()) {
sb.append(getString(R.string.foreground_none)).append('\n');
} else {
sb.append(getString(R.string.foreground_recent)).append('\n');
for (String line : r.recent) sb.append(line).append('\n');
}
if (!r.tasks.isEmpty()) {
sb.append('\n').append(getString(R.string.foreground_tasks)).append('\n');
for (String t : r.tasks) sb.append(t).append('\n');
}
sb.append('\n').append(getString(R.string.foreground_policy,
r.policyControl == null ? getString(R.string.foreground_policy_unset) : r.policyControl));
if (r.statusBarPx != null) {
sb.append('\n').append(getString(R.string.foreground_status_bar, r.statusBarPx));
}
return sb.toString();
}
/** Background thread for the one system-setting write (clearCarPlayFullScreen). */
private final java.util.concurrent.ExecutorService settingsWriter =
java.util.concurrent.Executors.newSingleThreadExecutor(r -> new Thread(r, "settings-write"));
/** Refreshes state + call log while the screen is visible. */
private final android.os.Handler uiHandler = new android.os.Handler(android.os.Looper.getMainLooper());
@@ -296,8 +260,6 @@ public class MainActivity extends AppCompatActivity {
statusText = servicePane.findViewById(R.id.status_text);
callLogText = logPane.findViewById(R.id.call_log_text);
logPane.findViewById(R.id.flush_now_button).setOnClickListener(v -> manualFlush());
foregroundText = logPane.findViewById(R.id.foreground_text);
logPane.findViewById(R.id.foreground_refresh_button).setOnClickListener(v -> refreshForeground());
setUpPager();
// Back on the page that was open when the activity was recreated (accent colour change).
@@ -386,11 +348,6 @@ public class MainActivity extends AppCompatActivity {
// Poll state and log only while the screen is up; onPause cancels it.
uiHandler.post(uiRefresh);
uiHandler.post(overviewRefresh);
// Back from another app (CarPlay) on the Logs tab: show where we were.
if (panes != null) {
ViewPager2 pager = findViewById(R.id.content);
if (panes[pager.getCurrentItem()] == logPane) refreshForeground();
}
}
@Override
@@ -443,7 +400,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
carReader.shutdownNow();
diagReader.shutdownNow();
settingsWriter.shutdownNow();
super.onDestroy();
}
@@ -1076,7 +1033,7 @@ public class MainActivity extends AppCompatActivity {
private void clearCarPlayFullScreen() {
if (checkSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
!= android.content.pm.PackageManager.PERMISSION_GRANTED) return;
diagReader.execute(() -> {
settingsWriter.execute(() -> {
try {
android.content.ContentResolver cr = getContentResolver();
String before = android.provider.Settings.Global.getString(cr, PolicyControl.KEY);