From e88de6a915d5c06ba0d491140c3c84eeac640a5c Mon Sep 17 00:00:00 2001 From: RikkaW Date: Sun, 9 Oct 2022 16:28:20 +0800 Subject: [PATCH] Fix first time of pairing always fail since recent versions --- .../shizuku/manager/adb/AdbPairingService.kt | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/manager/src/main/java/moe/shizuku/manager/adb/AdbPairingService.kt b/manager/src/main/java/moe/shizuku/manager/adb/AdbPairingService.kt index 6dd019d06..a9419951f 100644 --- a/manager/src/main/java/moe/shizuku/manager/adb/AdbPairingService.kt +++ b/manager/src/main/java/moe/shizuku/manager/adb/AdbPairingService.kt @@ -293,16 +293,10 @@ class AdbPairingService : Service() { .build() } - private val searchingNotification by unsafeLazy { - Notification.Builder(this, notificationChannel) - .setColor(getColor(R.color.notification)) - .setSmallIcon(R.drawable.ic_system_icon) - .setContentTitle(getString(R.string.notification_adb_pairing_searching_for_service_title)) - .addAction(stopNotificationAction) - .build() - } + private fun replyNotificationAction(port: Int): Notification.Action { + // Ensure pending intent is created + val action = replyNotificationAction - private fun createInputNotification(port: Int): Notification { PendingIntent.getForegroundService( this, replyRequestId, @@ -313,11 +307,24 @@ class AdbPairingService : Service() { PendingIntent.FLAG_UPDATE_CURRENT ) + return action + } + + private val searchingNotification by unsafeLazy { + Notification.Builder(this, notificationChannel) + .setColor(getColor(R.color.notification)) + .setSmallIcon(R.drawable.ic_system_icon) + .setContentTitle(getString(R.string.notification_adb_pairing_searching_for_service_title)) + .addAction(stopNotificationAction) + .build() + } + + private fun createInputNotification(port: Int): Notification { return Notification.Builder(this, notificationChannel) .setColor(getColor(R.color.notification)) .setContentTitle(getString(R.string.notification_adb_pairing_service_found_title)) .setSmallIcon(R.drawable.ic_system_icon) - .addAction(replyNotificationAction) + .addAction(replyNotificationAction(port)) .build() }