App 2.19.6: remove the CarPlay full-screen switch and the export button

CarPlay's 1920x640 is fixed in Allgo's system app. On start the car
build removes the CarPlay entry from policy_control if the switch was
left on.

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:02:15 +02:00
co-authored by Claude Opus 5.5
parent 4c224dcb3b
commit e6f8258203
13 changed files with 37 additions and 382 deletions
@@ -242,46 +242,9 @@ public class MainActivity extends AppCompatActivity {
if (r.statusBarPx != null) {
sb.append('\n').append(getString(R.string.foreground_status_bar, r.statusBarPx));
}
if (lastCarPlayExport != null) {
sb.append('\n').append(getString(R.string.carplay_export_last, lastCarPlayExport));
}
return sb.toString();
}
/** The last CarPlay export's outcome, for the Foreground apps card; null before the first. */
private static volatile String lastCarPlayExport;
/**
* Waits 20 seconds, so the driver can bring CarPlay to the front, then exports what decides
* its size to the USB stick (CarPlayExport). Runs in the app's process, which the upload
* service keeps alive while this activity is in the background.
*/
private void startCarPlayExport() {
android.content.Context app = getApplicationContext();
android.os.Handler main = new android.os.Handler(android.os.Looper.getMainLooper());
Toast.makeText(app, R.string.carplay_export_started, Toast.LENGTH_LONG).show();
new Thread(() -> {
try {
Thread.sleep(20_000);
} catch (InterruptedException e) {
return;
}
main.post(() -> Toast.makeText(app, R.string.carplay_export_running, Toast.LENGTH_SHORT).show());
String result;
try {
result = CarPlayExport.run(app);
} catch (Throwable t) {
result = "Export failed: " + t;
}
lastCarPlayExport = result;
final String shown = result;
main.post(() -> {
Toast.makeText(app, shown, Toast.LENGTH_LONG).show();
refreshForeground();
});
}, "carplay-export").start();
}
/** Refreshes state + call log while the screen is visible. */
private final android.os.Handler uiHandler = new android.os.Handler(android.os.Looper.getMainLooper());
private final Runnable uiRefresh = new Runnable() {
@@ -335,7 +298,6 @@ public class MainActivity extends AppCompatActivity {
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());
logPane.findViewById(R.id.carplay_export_button).setOnClickListener(v -> startCarPlayExport());
setUpPager();
// Back on the page that was open when the activity was recreated (accent colour change).
@@ -1105,54 +1067,27 @@ public class MainActivity extends AppCompatActivity {
// ---------- Upload page ----------
/** The car's CarPlay app, as the Logs tab's foreground list showed it on SWI68. */
private static final String CARPLAY_PACKAGE = "com.allgo.carplay.service";
/**
* Experiment: forces CarPlay into immersive mode through Android 9's policy_control setting.
* The switch shows what the setting holds, not a preference, and switching off removes only
* our entry. Writing it needs WRITE_SECURE_SETTINGS, which only the car build (system user)
* has; elsewhere the switch is disabled.
* App 2.19.2–2.19.5 had a "Full screen for CarPlay" experiment that added CarPlay to Android 9's
* policy_control setting; CarPlay's 1920×640 picture turned out to be fixed in its own app, so
* the switch is gone. This takes our entry out again where the switch was left on, and leaves
* anything else in the setting alone. Only the car build (system user) may write it.
*/
private void bindCarPlayFullScreen() {
com.google.android.material.switchmaterial.SwitchMaterial sw =
settingsPane.findViewById(R.id.carplay_full_screen_switch);
boolean mayWrite = checkSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
== android.content.pm.PackageManager.PERMISSION_GRANTED;
String current = android.provider.Settings.Global.getString(getContentResolver(), PolicyControl.KEY);
sw.setOnCheckedChangeListener(null);
sw.setChecked(PolicyControl.hasFull(current, CARPLAY_PACKAGE));
sw.setEnabled(mayWrite);
if (!mayWrite) {
((TextView) settingsPane.findViewById(R.id.carplay_full_screen_hint))
.setText(R.string.hint_carplay_full_screen_unavailable);
return;
}
sw.setOnCheckedChangeListener((btn, checked) -> diagReader.execute(() -> {
boolean ok;
private void clearCarPlayFullScreen() {
if (checkSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
!= android.content.pm.PackageManager.PERMISSION_GRANTED) return;
diagReader.execute(() -> {
try {
android.content.ContentResolver cr = getContentResolver();
String before = android.provider.Settings.Global.getString(cr, PolicyControl.KEY);
String after = checked ? PolicyControl.withFull(before, CARPLAY_PACKAGE)
: PolicyControl.withoutFull(before, CARPLAY_PACKAGE);
android.provider.Settings.Global.putString(cr, PolicyControl.KEY, after);
String now = android.provider.Settings.Global.getString(cr, PolicyControl.KEY);
ok = PolicyControl.hasFull(now, CARPLAY_PACKAGE) == checked;
android.util.Log.i("EVABRP.Settings", "policy_control " + (checked ? "on" : "off") + ": " + now);
if (!PolicyControl.hasFull(before, PolicyControl.CARPLAY_PACKAGE)) return;
android.provider.Settings.Global.putString(cr, PolicyControl.KEY,
PolicyControl.withoutFull(before, PolicyControl.CARPLAY_PACKAGE));
android.util.Log.i("EVABRP.Settings", "CarPlay entry removed from policy_control");
} catch (RuntimeException e) {
android.util.Log.w("EVABRP.Settings", "policy_control not written", e);
ok = false;
android.util.Log.w("EVABRP.Settings", "policy_control not cleared", e);
}
final boolean written = ok;
runOnUiThread(() -> {
if (isDestroyed()) return;
if (!written) {
Toast.makeText(this, R.string.carplay_full_screen_failed, Toast.LENGTH_LONG).show();
bindCarPlayFullScreen();
}
refreshForeground();
});
}));
});
}
private void bindServicePane() {
@@ -1168,7 +1103,7 @@ public class MainActivity extends AppCompatActivity {
prefs.edit().putBoolean(UploadSettings.KEY_FULL_SCREEN, checked).apply();
applyFullScreen();
});
bindCarPlayFullScreen();
clearCarPlayFullScreen();
liveTelemetrySwitch = servicePane.findViewById(R.id.abrp_upload_switch);
intervalChoices = servicePane.findViewById(R.id.interval_choices);
boostSwitch = servicePane.findViewById(R.id.boost_switch);