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. 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. */ 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)