diff --git a/app/src/main/java/com/heykay/snapkeymap/ui/DndAccessDialog.kt b/app/src/main/java/com/heykay/snapkeymap/ui/DndAccessDialog.kt index e3b6675..baf42bd 100644 --- a/app/src/main/java/com/heykay/snapkeymap/ui/DndAccessDialog.kt +++ b/app/src/main/java/com/heykay/snapkeymap/ui/DndAccessDialog.kt @@ -63,19 +63,24 @@ internal fun DndAccessDialog(onDone: () -> Unit, forSilent: Boolean = false) { verticalArrangement = Arrangement.spacedBy(12.dp), ) { Text(if (forSilent) { - "Your action is saved. Silent works best with Shizuku running on Android 15 or later. " + - "Otherwise it needs Do Not Disturb access and may turn on Do Not Disturb." + "On Android 15 or later, Silent can work without Do Not Disturb access when Shizuku is running, " + + "SnapKey Map is allowed in it, and the ringer command succeeds. " + + "Otherwise, Silent needs this access and may turn on Do Not Disturb." } else { - "Your action is saved. Do Not Disturb needs Do Not Disturb access. " + - "Allow it in Settings, or use Shizuku if your phone blocks the switch." + "Do Not Disturb needs this access. On Android 15 or later, Silent can work without it when Shizuku is running, " + + "SnapKey Map is allowed in it, and the ringer command succeeds. " + + "Otherwise, Silent needs this access and may turn on Do Not Disturb. " + + "Allow access in Settings, or use Shizuku if your phone blocks the switch." }) + Text("Settings may call this Modes access.") if (granted) { Text("Do Not Disturb access granted.") - } else { - TextButton( - enabled = !busy, - onClick = { context.openSafely(Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS)) }, - ) { Text("Open settings") } + } + TextButton( + enabled = !busy, + onClick = { context.openSafely(Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS)) }, + ) { Text("Open settings") } + if (!granted) { if (shizukuAvailable) { TextButton( enabled = !busy, diff --git a/app/src/main/java/com/heykay/snapkeymap/ui/HomeScreen.kt b/app/src/main/java/com/heykay/snapkeymap/ui/HomeScreen.kt index 7141012..18a6df4 100644 --- a/app/src/main/java/com/heykay/snapkeymap/ui/HomeScreen.kt +++ b/app/src/main/java/com/heykay/snapkeymap/ui/HomeScreen.kt @@ -157,6 +157,7 @@ fun HomeScreen( var showThemeMenu by rememberSaveable { mutableStateOf(false) } var showTiming by rememberSaveable { mutableStateOf(false) } var showPausedApps by rememberSaveable { mutableStateOf(false) } + var showDndDialog by rememberSaveable { mutableStateOf(false) } var showUnlockHint by rememberSaveable { mutableStateOf(false) } var showBackupWarning by rememberSaveable { mutableStateOf(false) } var pendingRestore by remember { mutableStateOf(null) } @@ -399,6 +400,15 @@ fun HomeScreen( supportingContent = { Text(pausedSummary, maxLines = 1, overflow = TextOverflow.Ellipsis) }, trailingContent = { Icon(Icons.AutoMirrored.Rounded.KeyboardArrowRight, contentDescription = null) }, ) + HorizontalDivider() + ListItem( + modifier = Modifier.clickable { showDndDialog = true }, + colors = ListItemDefaults.colors(containerColor = Color.Transparent), + headlineContent = { Text("Do Not Disturb access") }, + leadingContent = { Icon(Icons.Rounded.Notifications, contentDescription = null) }, + supportingContent = { Text("For Do Not Disturb and Silent actions") }, + trailingContent = { Icon(Icons.AutoMirrored.Rounded.KeyboardArrowRight, contentDescription = null) }, + ) } } item { SectionHeader("Backup") } @@ -471,6 +481,7 @@ fun HomeScreen( } if (showTiming) TimingDialog(config = config, onDismiss = { showTiming = false }) if (showPausedApps) PausedAppsSheet(onDismiss = { showPausedApps = false }) + if (showDndDialog) DndAccessDialog(onDone = { showDndDialog = false }) if (showBackupWarning) { AlertDialog( onDismissRequest = { showBackupWarning = false }, diff --git a/docs/help.html b/docs/help.html index 0608158..d6ff42b 100644 --- a/docs/help.html +++ b/docs/help.html @@ -106,7 +106,7 @@

Choosing actions

  • For Tap, then hold, tap once, then hold the second press. When assigned, a quick double press runs on release instead of on the second press down.
  • The known Find X9 log reports press and release edges. Other learned log formats need repeated events while held to detect a hold.
  • The shortcut picker supports apps that offer ACTION_CREATE_SHORTCUT, not every pinned shortcut. Try a deep link instead. Direct-dial shortcuts are not supported because the app has no calling permission.
  • -
  • Silent mode and Do Not Disturb need notification policy access. Without it, the ringer action cycles between ring and vibrate.
  • +
  • Do Not Disturb needs notification policy access. On Android 15 or later, Silent can work without this access when Shizuku is running, SnapKey Map is allowed in it, and the ringer command succeeds. Otherwise, Silent needs notification policy access and may turn on Do Not Disturb. Without that access, the fallback skips Silent. Open Home > Do Not Disturb access > Open settings to allow access. Settings may call this Modes access. If ColorOS hides the access switch, connect SnapKey Map to Shizuku and choose Allow with Shizuku in the dialog.
  • Android permissions, device support, and the lock screen still apply. The app cannot bypass the lock screen. Screen-off detection and background reliability depend on ColorOS / OxygenOS and your settings.
  • @@ -152,7 +152,7 @@

    Is it safe?

    What stays on the phone

    The app declares no INTERNET permission. It does not send logs or settings off the phone. Apps and websites you open through an action handle their own data and have their own privacy policies.

    The reader checks incoming log lines in memory. It does not save a log file. Outside teaching, matching lines drive key detection and other lines are discarded.

    -

    If you allow SnapKey Map in Shizuku, the app also uses Shizuku to run logcat as the shell user. Shizuku must be running for this. Lines are still checked in memory and discarded, with the teaching exception below. Shizuku is not used to run mapped actions.

    +

    While Shizuku is running and SnapKey Map is allowed in it, the app can read logs with logcat and precise key input with getevent as the shell user. Log lines are still checked in memory and discarded, with the teaching exception below. The app also uses Shizuku for the log-access grant, the optional Do Not Disturb access grant, ringer changes on Android 15 or later, and Circle to Search when available.

    During teaching, it temporarily keeps observations in memory: an arrival time, log tag, normalized message, and writer UID. Runs of message digits are replaced with #, and the message is trimmed and limited to 160 characters. This does not remove all sensitive text. Tags and UIDs are retained. Accessibility key-code observations can also be kept during teaching.

    After learning, the app saves one selected log signature, not the collected log: the tag, normalized message, and writer UID, plus hold detection and release timing settings. If Android supplies a usable key event instead, it saves the key and scan codes rather than a log signature. The observation list is not written to storage and is released after learning finishes or is cancelled.

    How key lines are checked

    @@ -168,7 +168,7 @@

    Declared permissions

  • Show notifications (POST_NOTIFICATIONS): tell you when detection pauses.
  • Access notification policy (ACCESS_NOTIFICATION_POLICY): use Do Not Disturb and silent-mode controls.
  • Ask to ignore battery optimisation (REQUEST_IGNORE_BATTERY_OPTIMIZATIONS): request background operation.
  • -
  • Shizuku API access (moe.shizuku.manager.permission.API_V23): lets the app ask Shizuku for the one-time log permission grant and run logcat as the shell user while Shizuku is running. This avoids the device-logs prompt. Without it, Android asks for one-time access after each app or phone restart and may ask again on reconnect. Mapped actions do not use Shizuku.
  • +
  • Shizuku API access (moe.shizuku.manager.permission.API_V23): lets the app request log access, read logs and key input as the shell user, grant Do Not Disturb access, change the ringer on Android 15 or later, and start Circle to Search when available. Shizuku must be running and SnapKey Map allowed in it. Reading logs through Shizuku avoids the device-logs prompt. Without that route, Android asks for one-time access after each app or phone restart and may ask again on reconnect.
  • Internal receiver permission (com.heykay.snapkeymap.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION): added by the AndroidX library. Only this app holds it, and it keeps other apps from sending broadcasts to the app's private receivers.
  • The code is open source. You can inspect the implementation and build it yourself.