The four Kotlin files that were the link rather than this product now come from the submodule: the pinned TrustManager, the enrollment store and its Keystore sealing, the QR capture activity, and the local-network permission check. `:link` is a subproject resolved by path, so the app half is version-locked to the same commit the Rust half already was. What stays here is the two facts that are actually about this app, and both are load-bearing in a way that would fail quietly if got wrong: the `aiapp` URI scheme, and the Keystore alias `aiapp-token-key` that every enrolled phone's token is already sealed under. A wrong alias would leave those phones reading as not enrolled with nothing on screen to explain it, so the value is carried over exactly and the reason is written beside it. Call sites are unchanged. `ServerSettings` stays available unqualified as a typealias and `applyPinnedTls()` stays an extension, so the diff is the three files that bind the product-specific values plus two imports -- rather than every screen that happens to use a setting. Also clears a warning the build had been printing: `setup?.id.orEmpty()` where the compiler already knows `setup` is non-null, because `chosen` came from that setup's own provider list. Verified by running the build, not only by reading it: ktfmt, Kotlin compile and Android Lint are all clean with no warnings, and the APK still builds -- which exercises the pinned-CA generator, since that is the step that reads the CA off this machine. Still unpushed, per the hold until the rebuild bug is proven fixed. Note the submodule: a checkout of this commit needs `git submodule update --init` before `app/` or `server/` will build.
29 lines
1.2 KiB
Kotlin
29 lines
1.2 KiB
Kotlin
package com.example.aiapp
|
|
|
|
import android.content.Context
|
|
import android.net.Uri
|
|
import com.example.wgapplink.ServerStore
|
|
|
|
/**
|
|
* Where the backend is and how to authenticate to it. Absent until the phone is enrolled -- by
|
|
* scanning the server's terminal QR (an `aiapp://enroll` URI the camera app hands to MainActivity)
|
|
* or by typing the fields into the settings screen.
|
|
*/
|
|
typealias ServerSettings = com.example.wgapplink.ServerSettings
|
|
|
|
/**
|
|
* This app's enrollment, which is the whole of what is product-specific about it.
|
|
*
|
|
* Both values are load-bearing and neither may be changed casually. The scheme is what routes a
|
|
* scanned QR here rather than to Dev Updater, and the key alias names the Android Keystore key the
|
|
* token is already sealed under on every enrolled phone -- changing it would leave those phones
|
|
* reading as not enrolled, with no error to explain why.
|
|
*/
|
|
private val store = ServerStore(scheme = "aiapp", keyAlias = "aiapp-token-key")
|
|
|
|
fun loadServerSettings(context: Context): ServerSettings? = store.load(context)
|
|
|
|
fun saveServerSettings(context: Context, settings: ServerSettings) = store.save(context, settings)
|
|
|
|
fun parseEnrollmentUri(uri: Uri): ServerSettings? = store.parseEnrollmentUri(uri)
|