App 2.33.0: set the drive mode from Settings, only in P at a standstill

The owner lifted the read-only rule for the drive mode alone. Settings
has Eco, Normal, Sport, Snow and Custom; the lit button is what the car
reports. A tap reads gear and speed fresh and writes only in P at 0 km/h
(DriveModeWrite, unit-tested; unreadable is a refusal), through a CPM-only
write behind EVHardware's standstill gate, then reads the mode back and
says what the car reports. The wide layout's charging price joined the
battery card so the page still fits. Not tried on the car.

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-25 20:02:53 +01:00
co-authored by Claude Opus 5.5
parent 703bdfd2a3
commit ce2ebd7f58
15 changed files with 268 additions and 12 deletions
@@ -0,0 +1,42 @@
package com.evsuite.abrp;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/** The drive mode write's rules — pure JVM. */
public class DriveModeWriteTest {
@Test
public void onlyInPAtAStandstill() {
assertEquals(DriveModeWrite.Verdict.ALLOWED, DriveModeWrite.check(0f, 1));
assertEquals(DriveModeWrite.Verdict.NOT_IN_P, DriveModeWrite.check(0f, 4));
assertEquals(DriveModeWrite.Verdict.NOT_IN_P, DriveModeWrite.check(0f, 3));
assertEquals(DriveModeWrite.Verdict.NOT_IN_P, DriveModeWrite.check(30f, 2));
assertEquals(DriveModeWrite.Verdict.MOVING, DriveModeWrite.check(0.5f, 1));
}
@Test
public void unreadableIsRefused() {
assertEquals(DriveModeWrite.Verdict.UNREADABLE, DriveModeWrite.check(null, 1));
assertEquals(DriveModeWrite.Verdict.UNREADABLE, DriveModeWrite.check(0f, null));
assertEquals(DriveModeWrite.Verdict.UNREADABLE, DriveModeWrite.check(Float.NaN, 1));
assertEquals(DriveModeWrite.Verdict.UNREADABLE, DriveModeWrite.check(-1f, 1));
}
@Test
public void resultIsWhatTheCarReports() {
assertEquals(DriveModeWrite.Outcome.APPLIED, DriveModeWrite.outcome(4, 4));
assertEquals(DriveModeWrite.Outcome.NOT_APPLIED, DriveModeWrite.outcome(4, 2));
assertEquals(DriveModeWrite.Outcome.UNREAD, DriveModeWrite.outcome(4, null));
}
@Test
public void buttonsByCode() {
assertEquals(0, DriveModeWrite.indexOf(2));
assertEquals(2, DriveModeWrite.indexOf(4));
assertEquals(4, DriveModeWrite.indexOf(7));
assertEquals(-1, DriveModeWrite.indexOf(5));
assertEquals(-1, DriveModeWrite.indexOf(null));
}
}