An approval's Allow once / Deny from its notification need the phone unlocked
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
NotificationCompat.Action.setAuthenticationRequired: Android 12+ asks for the unlock before the answer is sent. Run on every approval push, so the approvals a scheduled run on a linked computer sends are covered by the same path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+12
-3
No files matched your search
@@ -17,6 +17,9 @@ is in alpha and releases come off `main`.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Allow once and Deny on an approval's notification ask for the phone to be unlocked first**
|
||||
(Android 12 and newer), so a locked phone cannot answer for you. This holds for the
|
||||
approvals a scheduled run on a computer will send too.
|
||||
- **The microphone in a chat follows Settings › Voice input**, as the assistant does: with
|
||||
*LLeMbas* it records and your instance writes the words down when you stop; with *Phone* the
|
||||
phone's own recogniser writes them into the box as you speak and stops at the end of what you
|
||||
|
||||
@@ -122,10 +122,12 @@ object Notifications {
|
||||
// The body can name a command or a file; on a locked screen only the title shows.
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||
// An approval can be answered from here: once, or no. "Always" and a corrected command
|
||||
// need the card itself, so they stay in the app.
|
||||
// need the card itself, so they stay in the app. Either answer asks for the phone to be
|
||||
// unlocked first (Android 12+): a locked phone in somebody else's hand must not say yes
|
||||
// to a command -- nor no to a run that waits on it, a scheduled one included.
|
||||
if (payload.kind == "ask" && payload.ask == "approval" && chatId != null && payload.interactionId != null) {
|
||||
builder.addAction(0, context.getString(R.string.card_allow_once), answer(context, instance, chatId, payload.interactionId, "allow", id))
|
||||
builder.addAction(0, context.getString(R.string.card_deny), answer(context, instance, chatId, payload.interactionId, "deny", id))
|
||||
builder.addAction(unlocked(context.getString(R.string.card_allow_once), answer(context, instance, chatId, payload.interactionId, "allow", id)))
|
||||
builder.addAction(unlocked(context.getString(R.string.card_deny), answer(context, instance, chatId, payload.interactionId, "deny", id)))
|
||||
}
|
||||
NotificationManagerCompat.from(context).notify(id, builder.build())
|
||||
}
|
||||
@@ -163,6 +165,10 @@ object Notifications {
|
||||
NotificationManagerCompat.from(context).notify(notice.id, builder.build())
|
||||
}
|
||||
|
||||
/** A notification action Android runs only once the phone is unlocked. */
|
||||
private fun unlocked(title: String, intent: PendingIntent): NotificationCompat.Action =
|
||||
NotificationCompat.Action.Builder(0, title, intent).setAuthenticationRequired(true).build()
|
||||
|
||||
private fun opener(context: Context, instance: String, id: Int, chatId: String?, scheduleId: String? = null, runId: String? = null): PendingIntent =
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
|
||||
Reference in new issue
Block a user