Skip to content

Commit 06f335d

Browse files
committed
fix: prefill open-source ABRP API key
1 parent fea38cb commit 06f335d

4 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project are documented here. Format follows
44
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
55
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.0.1] - 2026-08-03
8+
9+
### Changed
10+
11+
- Prefill the ABRP API-key input with the public open-source telemetry key while
12+
preserving any custom key already saved by the user.
13+
714
## [1.0.0] - 2026-08-02
815

916
### Added

‎app/build.gradle‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ android {
3434
applicationId "com.mg4.abrptelemetry"
3535
minSdk 27
3636
targetSdk 36
37-
versionCode 1
38-
versionName "1.0"
37+
versionCode 2
38+
versionName "1.0.1"
3939

4040
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4141
}

‎app/src/main/java/com/mg4/abrptelemetry/MainActivity.java‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected void onCreate(Bundle savedInstanceState) {
121121
// a no-op and does not even contain the updater.
122122
UpdateHook.checkInBackground(this);
123123

124-
apiKeyInput.setText(securePrefs.getString(SecurePrefs.KEY_API_KEY, ""));
124+
apiKeyInput.setText(savedApiKeyOrDefault());
125125
tokenInput.setText(securePrefs.getString(SecurePrefs.KEY_TOKEN, ""));
126126
serviceSwitch.setChecked(prefs.getBoolean("service_enabled", false));
127127

@@ -169,7 +169,7 @@ protected void onCreate(Bundle savedInstanceState) {
169169
@Override
170170
protected void onResume() {
171171
super.onResume();
172-
apiKeyInput.setText(securePrefs.getString(SecurePrefs.KEY_API_KEY, ""));
172+
apiKeyInput.setText(savedApiKeyOrDefault());
173173
tokenInput.setText(securePrefs.getString(SecurePrefs.KEY_TOKEN, ""));
174174
serviceSwitch.setChecked(prefs.getBoolean("service_enabled", false));
175175
// Poll state and log only while the screen is up; onPause cancels it.
@@ -178,6 +178,17 @@ protected void onResume() {
178178

179179
// ---------- Credentials ----------
180180

181+
/**
182+
* The SAIC open-source gateway publishes this shared ABRP key for compatible clients.
183+
* A user-supplied key saved in encrypted preferences always takes precedence.
184+
*/
185+
private String savedApiKeyOrDefault() {
186+
String savedApiKey = securePrefs.getString(SecurePrefs.KEY_API_KEY, "");
187+
return savedApiKey == null || savedApiKey.trim().isEmpty()
188+
? getString(R.string.default_abrp_api_key)
189+
: savedApiKey;
190+
}
191+
181192
private void saveCredentials() {
182193
String apiKey = textOf(apiKeyInput);
183194
String token = textOf(tokenInput);
@@ -331,7 +342,7 @@ private void applyConfig(String text) {
331342
edit.apply();
332343

333344
// Re-read every control from prefs so the screen shows what was imported.
334-
apiKeyInput.setText(securePrefs.getString(SecurePrefs.KEY_API_KEY, ""));
345+
apiKeyInput.setText(savedApiKeyOrDefault());
335346
tokenInput.setText(securePrefs.getString(SecurePrefs.KEY_TOKEN, ""));
336347
apiKeyLayout.setError(null);
337348
tokenLayout.setError(null);

‎app/src/main/res/values/strings.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<string name="tab_log">Log</string>
88
<string name="card_config">Configuration</string>
99
<string name="hint_api_key">ABRP API Key</string>
10-
<string name="helper_api_key">Developer key from api.iternio.com — register your app to get one</string>
10+
<string name="default_abrp_api_key" translatable="false">8cfc314b-03cd-4efe-ab7d-4431cd8f2e2d</string>
11+
<string name="helper_api_key">Default: open-source ABRP telemetry key. You may replace it with your own.</string>
1112
<string name="api_key_required">Enter your ABRP API key first</string>
1213
<string name="hint_token">ABRP User Token</string>
1314
<string name="helper_token">Find your token in the ABRP app: Settings → Connections → Generic (Manual Entry)</string>

0 commit comments

Comments
 (0)