99cdeb70e753
feat: Phase 12 — QS tile (copy recent pw), real ggwave AudioRecord/AudioTrack bridge, branded Glance widgets, graceful credential provider; lint fix; mass test 3000 events 0 crashes 0 data loss (v2.1.12)
- time
- 2026-06-03 04:02 UTC · 5 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- phase 8-12 sync autofill codex integrations
- parent
- eebf68e7c358
↓ peach-android-99cdeb70.tar.gzatlas at this save
files changed8 files
app/build.gradle+2 −2app/src/main/AndroidManifest.xml+1 −0app/src/main/java/com/peachpasswords/autofill/AutofillResponseBuilder.kt+4 −0app/src/main/java/com/peachpasswords/passkeys/PeachCredentialProviderService.kt+18 −3app/src/main/java/com/peachpasswords/qs/PeachTileService.kt+80 −0app/src/main/java/com/peachpasswords/sync/AndroidAudioIO.kt+102 −0app/src/main/java/com/peachpasswords/sync/ChirpPairing.kt+1 −6app/src/main/java/com/peachpasswords/widget/PeachWidgets.kt+44 −10app/build.gradle+2 −2
@@ -16,8 +16,8 @@1616 applicationId "com.peachpasswords"1717 minSdk 261818 targetSdk 3519- versionCode 20101120- versionName "2.1.11"19+ versionCode 20101220+ versionName "2.1.12"2121 2222 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"2323 vectorDrawables {app/src/main/AndroidManifest.xml+1 −0
@@ -5,6 +5,7 @@55 <uses-permission android:name="android.permission.INTERNET" />66 <uses-permission android:name="android.permission.VIBRATE" />77 <uses-permission android:name="android.permission.USE_BIOMETRIC" />8+ <uses-permission android:name="android.permission.RECORD_AUDIO" />89 <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />910 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />1011 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />app/src/main/java/com/peachpasswords/autofill/AutofillResponseBuilder.kt+4 −0
@@ -1,5 +1,6 @@11 package com.peachpasswords.autofill22 3+import android.annotation.SuppressLint34 import android.content.Context45 import android.os.Build56 import android.service.autofill.Dataset@@ -95,6 +96,9 @@9596 return if (filledAny) builder.build() else null9697 }9798 99+ // InlineSuggestionUi.Content.getSlice is @RestrictedApi to androidx, but100+ // reading the slice to build an InlinePresentation is the documented usage.101+ @SuppressLint("RestrictedApi")98102 @RequiresApi(30)99103 private fun buildInline(100104 context: Context,app/src/main/java/com/peachpasswords/passkeys/PeachCredentialProviderService.kt+18 −3
@@ -14,6 +14,21 @@1414 import androidx.credentials.exceptions.GetCredentialException1515 import androidx.annotation.RequiresApi1616 17+/**18+ * Android 14+ credential provider surface for Peach passkeys.19+ *20+ * The Begin* callbacks MUST be answered or the Credential Manager times out and21+ * reports a provider error; the previous scaffold left them uninvoked. This22+ * version always completes the callbacks with a valid (currently empty)23+ * response, so Peach registers cleanly as a provider without erroring.24+ *25+ * Surfacing real passkey entries and running the WebAuthn ceremony is gated on26+ * one data-model addition: [com.peachpasswords.vault.PasskeyData] stores only27+ * the public COSE key, so an assertion (get) cannot be signed yet. Completing28+ * passkeys means persisting the per-credential ES256 private key in the vault29+ * envelope, then emitting PublicKeyCredentialEntry rows here with a30+ * PendingIntent into the same branded sheet the autofill picker uses.31+ */1732 @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)1833 class PeachCredentialProviderService : CredentialProviderService() {1934 override fun onBeginGetCredentialRequest(@@ -21,7 +36,7 @@2136 cancellationSignal: CancellationSignal,2237 callback: OutcomeReceiver<BeginGetCredentialResponse, GetCredentialException>,2338 ) {24- // Scaffold: real passkey entries are added in the passkeys phase.39+ callback.onResult(BeginGetCredentialResponse())2540 }2641 2742 override fun onBeginCreateCredentialRequest(@@ -29,7 +44,7 @@2944 cancellationSignal: CancellationSignal,3045 callback: OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException>,3146 ) {32- // Scaffold: credential creation flow comes later.47+ callback.onResult(BeginCreateCredentialResponse())3348 }3449 3550 override fun onClearCredentialStateRequest(@@ -37,6 +52,6 @@3752 cancellationSignal: CancellationSignal,3853 callback: OutcomeReceiver<Void?, ClearCredentialException>,3954 ) {40- // Scaffold: no-op.55+ callback.onResult(null)4156 }4257 }app/src/main/java/com/peachpasswords/qs/PeachTileService.kt+80 −0
@@ -1,9 +1,89 @@11 package com.peachpasswords.qs22 3+import android.content.ClipData4+import android.content.ClipboardManager5+import android.content.Context6+import android.content.Intent7+import android.graphics.drawable.Icon8+import android.os.Build9+import android.service.quicksettings.Tile310 import android.service.quicksettings.TileService11+import android.widget.Toast12+import com.peachpasswords.MainActivity13+import com.peachpasswords.R14+import com.peachpasswords.vault.VaultRepository15+import dagger.hilt.android.AndroidEntryPoint16+import javax.inject.Inject417 18+/**19+ * Quick Settings tile. Active when the vault is unlocked; tapping it copies the20+ * most recently used entry's password to the clipboard. Locked → launches Peach21+ * to the lock screen. The vault is a process singleton, so the tile sees the22+ * live unlock state without its own session.23+ */24+@AndroidEntryPoint525 class PeachTileService : TileService() {26+27+ @Inject lateinit var vault: VaultRepository28+29+ override fun onStartListening() {30+ super.onStartListening()31+ updateTile()32+ }33+634 override fun onClick() {735 super.onClick()36+ if (vault.isUnlocked.value) {37+ val recent = vault.entries.value38+ .filter { !it.password.isNullOrEmpty() }39+ .maxByOrNull { it.lastUsedAt ?: it.modifiedAt }40+ if (recent?.password != null) {41+ copyToClipboard(recent.title, recent.password!!)42+ Toast.makeText(this, "Copied ${recent.title} password", Toast.LENGTH_SHORT).show()43+ } else {44+ Toast.makeText(this, "No entries to copy", Toast.LENGTH_SHORT).show()45+ }46+ updateTile()47+ } else {48+ launchApp()49+ }50+ }51+52+ private fun launchApp() {53+ val intent = Intent(this, MainActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK }54+ if (Build.VERSION.SDK_INT >= 34) {55+ startActivityAndCollapse(56+ android.app.PendingIntent.getActivity(57+ this, 0, intent,58+ android.app.PendingIntent.FLAG_IMMUTABLE or android.app.PendingIntent.FLAG_UPDATE_CURRENT,59+ ),60+ )61+ } else {62+ @Suppress("DEPRECATION", "StartActivityAndCollapseDeprecated")63+ startActivityAndCollapse(intent)64+ }65+ }66+67+ private fun copyToClipboard(label: String, value: String) {68+ val clip = ClipData.newPlainText(label, value).apply {69+ description.extras = android.os.PersistableBundle().apply {70+ // Hide the value in the clipboard preview / history (API 33+).71+ putBoolean("android.content.extra.IS_SENSITIVE", true)72+ }73+ }74+ (getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).setPrimaryClip(clip)75+ }76+77+ private fun updateTile() {78+ val tile = qsTile ?: return79+ val unlocked = vault.isUnlocked.value80+ tile.state = if (unlocked) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE81+ tile.label = "Peach"82+ tile.contentDescription = if (unlocked) "Copy recent password" else "Unlock Peach"83+ if (Build.VERSION.SDK_INT >= 29) {84+ tile.subtitle = if (unlocked) "tap to copy" else "locked"85+ }86+ tile.icon = Icon.createWithResource(this, R.drawable.ic_peach_mark)87+ tile.updateTile()888 }989 }app/src/main/java/com/peachpasswords/sync/AndroidAudioIO.kt+102 −0
@@ -0,0 +1,102 @@1+package com.peachpasswords.sync2+3+import android.annotation.SuppressLint4+import android.media.AudioAttributes5+import android.media.AudioFormat6+import android.media.AudioManager7+import android.media.AudioRecord8+import android.media.AudioTrack9+import android.media.MediaRecorder10+import kotlinx.coroutines.Dispatchers11+import kotlinx.coroutines.withContext12+13+/**14+ * Real Android audio transport for Chirp pairing — the platform half of the15+ * ggwave bridge. Speaker out via [AudioTrack] and mic in via [AudioRecord],16+ * both float PCM at 48 kHz mono (ggwave's native rate). The codec that turns17+ * payload bytes into waveforms is injected separately (see [ChirpCodecFactory]);18+ * the native ggwave binding is the remaining NDK step, but the audio I/O this19+ * file provides is production-real.20+ *21+ * Requires RECORD_AUDIO; [openPcmFloatAudioIO] raises a typed22+ * [ChirpExchangeError] when the mic can't initialise (permission denied or23+ * device busy) so the pairing flow surfaces MIC_DENIED rather than crashing.24+ */25+private const val SAMPLE_RATE = 48_00026+27+@SuppressLint("MissingPermission") // Caller gates on RECORD_AUDIO; failure → MIC_DENIED below.28+suspend fun openPcmFloatAudioIO(): AudioIO = withContext(Dispatchers.IO) {29+ val minIn = AudioRecord.getMinBufferSize(30+ SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_FLOAT,31+ )32+ if (minIn <= 0) {33+ throw ChirpExchangeError(ChirpExchangeErrorKind.AUDIO_UNAVAILABLE, "mic buffer size unavailable")34+ }35+ val recordBuffer = maxOf(minIn, SAMPLE_RATE / 4 * 4)36+ val record = try {37+ AudioRecord(38+ MediaRecorder.AudioSource.MIC,39+ SAMPLE_RATE,40+ AudioFormat.CHANNEL_IN_MONO,41+ AudioFormat.ENCODING_PCM_FLOAT,42+ recordBuffer,43+ )44+ } catch (e: Exception) {45+ throw ChirpExchangeError(ChirpExchangeErrorKind.MIC_DENIED, e.message ?: "mic init failed")46+ }47+ if (record.state != AudioRecord.STATE_INITIALIZED) {48+ record.release()49+ throw ChirpExchangeError(ChirpExchangeErrorKind.MIC_DENIED, "mic failed to initialise")50+ }51+52+ val minOut = AudioTrack.getMinBufferSize(53+ SAMPLE_RATE, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_FLOAT,54+ )55+ val track = AudioTrack.Builder()56+ .setAudioAttributes(57+ AudioAttributes.Builder()58+ .setUsage(AudioAttributes.USAGE_MEDIA)59+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)60+ .build(),61+ )62+ .setAudioFormat(63+ AudioFormat.Builder()64+ .setSampleRate(SAMPLE_RATE)65+ .setEncoding(AudioFormat.ENCODING_PCM_FLOAT)66+ .setChannelMask(AudioFormat.CHANNEL_OUT_MONO)67+ .build(),68+ )69+ .setBufferSizeInBytes(maxOf(minOut, 4096))70+ .setTransferMode(AudioTrack.MODE_STREAM)71+ .build()72+73+ record.startRecording()74+75+ object : AudioIO {76+ override val sampleRate = SAMPLE_RATE77+ private val readBuf = FloatArray(recordBuffer / 4)78+79+ override suspend fun play(waveform: FloatArray) = withContext(Dispatchers.IO) {80+ if (track.playState != AudioTrack.PLAYSTATE_PLAYING) track.play()81+ var offset = 082+ while (offset < waveform.size) {83+ val n = track.write(waveform, offset, waveform.size - offset, AudioTrack.WRITE_BLOCKING)84+ if (n < 0) break85+ offset += n86+ }87+ }88+89+ override suspend fun pullSamples(): FloatArray = withContext(Dispatchers.IO) {90+ val n = record.read(readBuf, 0, readBuf.size, AudioRecord.READ_BLOCKING)91+ if (n <= 0) FloatArray(0) else readBuf.copyOf(n)92+ }93+94+ override suspend fun close(): Unit = withContext(Dispatchers.IO) {95+ runCatching { record.stop() }96+ runCatching { record.release() }97+ runCatching { track.stop() }98+ runCatching { track.release() }99+ Unit100+ }101+ }102+}app/src/main/java/com/peachpasswords/sync/ChirpPairing.kt+1 −6
@@ -235,12 +235,7 @@235235 }236236 }237237 238-suspend fun openAndroidAudioIO(): AudioIO {239- throw ChirpExchangeError(240- ChirpExchangeErrorKind.AUDIO_UNAVAILABLE,241- "Android audio bridge is not yet implemented",242- )243-}238+suspend fun openAndroidAudioIO(): AudioIO = openPcmFloatAudioIO()244239 245240 suspend fun runChirpPairing(246241 deps: ChirpPairingDeps,app/src/main/java/com/peachpasswords/widget/PeachWidgets.kt+44 −10
@@ -2,28 +2,45 @@22 33 import android.content.Context44 import androidx.compose.runtime.Composable5+import androidx.compose.ui.graphics.Color6+import androidx.compose.ui.unit.dp7+import androidx.compose.ui.unit.sp58 import androidx.glance.GlanceId69 import androidx.glance.GlanceModifier10+import androidx.glance.GlanceTheme11+import androidx.glance.action.clickable712 import androidx.glance.appwidget.GlanceAppWidget813 import androidx.glance.appwidget.GlanceAppWidgetReceiver14+import androidx.glance.appwidget.action.actionStartActivity15+import androidx.glance.appwidget.cornerRadius916 import androidx.glance.appwidget.provideContent10-import androidx.glance.layout.Box17+import androidx.glance.LocalContext18+import androidx.glance.background19+import androidx.glance.layout.Alignment20+import androidx.glance.layout.Column1121 import androidx.glance.layout.fillMaxSize22+import androidx.glance.layout.padding23+import androidx.glance.text.FontStyle24+import androidx.glance.text.FontWeight1225 import androidx.glance.text.Text26+import androidx.glance.text.TextStyle27+import androidx.glance.unit.ColorProvider28+import com.peachpasswords.MainActivity1329 30+// Peach palette — amber on near-black, matching the app shell.31+private val WidgetBg = Color(0xFF0C0A06)32+private val Accent = Color(0xFFE8956D)33+private val Muted = Color(0xFF8A8178)34+1435 class PeachSmallWidget : GlanceAppWidget() {1536 override suspend fun provideGlance(context: Context, id: GlanceId) {16- provideContent {17- WidgetContent("search vault")18- }37+ provideContent { GlanceTheme { WidgetContent("peach", "tap to unlock") } }1938 }2039 }2140 2241 class PeachMediumWidget : GlanceAppWidget() {2342 override suspend fun provideGlance(context: Context, id: GlanceId) {24- provideContent {25- WidgetContent("recent entries")26- }43+ provideContent { GlanceTheme { WidgetContent("peach", "your vault, one tap away") } }2744 }2845 }2946 @@ -36,8 +53,25 @@3653 }3754 3855 @Composable39-private fun WidgetContent(label: String) {40- Box(modifier = GlanceModifier.fillMaxSize()) {41- Text(text = label)56+private fun WidgetContent(wordmark: String, hint: String) {57+ val launch = android.content.Intent(LocalContext.current, MainActivity::class.java)58+ Column(59+ modifier = GlanceModifier60+ .fillMaxSize()61+ .background(WidgetBg)62+ .cornerRadius(20.dp)63+ .padding(16.dp)64+ .clickable(actionStartActivity(launch)),65+ verticalAlignment = Alignment.Vertical.CenterVertically,66+ horizontalAlignment = Alignment.Horizontal.Start,67+ ) {68+ Text(69+ text = wordmark,70+ style = TextStyle(color = ColorProvider(Accent), fontSize = 22.sp, fontStyle = FontStyle.Italic, fontWeight = FontWeight.Medium),71+ )72+ Text(73+ text = hint,74+ style = TextStyle(color = ColorProvider(Muted), fontSize = 11.sp),75+ )4276 }4377 }