Files
mg4/app/src/main/java/com/evsuite/abrp/AbrpConfig.java
T
nilsandClaude Opus 5.5 9f184362f0 Server 2.4.0, app 2.11.1: ABRP forwarding removed from the server
The car sends live data to ABRP itself, and the car and the server go
over the same mobile connection: when the car cannot reach ABRP, it
cannot reach the server either, so the server's fallback bought
nothing. The forwarder, its ABRP_* settings and abrpSentUtc are gone;
the server only stores. The app stops sending abrpSentUtc (the server
ignores unknown fields, so 2.11.0 keeps working) and its texts no longer
promise a server fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
2026-10-18 12:49:46 +02:00

63 lines
2.2 KiB
Java

package com.evsuite.abrp;
import android.content.Context;
import android.content.SharedPreferences;
/**
* The ABRP credentials for sending live data straight from the car: the API key (which app is
* sending) and the user token (which car in which ABRP account). Kept in {@link SecurePrefs}
* next to the server settings, entered on the Live data tab or imported from a config file.
*
* The car is the only one that sends to ABRP: the server stores live data but does not forward
* it. Without these, ABRP gets no live data.
*/
final class AbrpConfig {
static final String KEY_API_KEY = "abrp_api_key";
static final String KEY_USER_TOKEN = "abrp_user_token";
final String apiKey;
final String userToken;
private static volatile AbrpConfig current;
AbrpConfig(String apiKey, String userToken) {
this.apiKey = apiKey;
this.userToken = userToken;
}
boolean isConfigured() {
return !apiKey.isEmpty() && !userToken.isEmpty();
}
static AbrpConfig get(Context context) {
AbrpConfig config = current;
if (config != null) return config;
synchronized (AbrpConfig.class) {
if (current == null) {
SharedPreferences prefs = SecurePrefs.get(context);
current = new AbrpConfig(prefs.getString(KEY_API_KEY, ""), prefs.getString(KEY_USER_TOKEN, ""));
}
return current;
}
}
/** Stores trimmed values; empty strings switch direct sending off. */
static synchronized void save(Context context, String apiKey, String userToken) {
String key = apiKey == null ? "" : apiKey.trim();
String token = userToken == null ? "" : userToken.trim();
SecurePrefs.get(context).edit()
.putString(KEY_API_KEY, key)
.putString(KEY_USER_TOKEN, token)
.apply();
current = new AbrpConfig(key, token);
}
/** Plausible as an ABRP credential: no spaces, not absurdly short or long. */
static boolean isPlausible(String value) {
if (value == null) return false;
String v = value.trim();
return v.length() >= 8 && v.length() <= 200 && !v.contains(" ");
}
}