@@ -38,6 +38,7 @@ import kotlinx.coroutines.withContext
3838import okhttp3.Interceptor
3939import okhttp3.OkHttpClient
4040import okio.ByteString
41+ import org.microg.gms.accountsettings.ui.KEY_IS_2_STEP_VERIFICATION
4142import org.microg.gms.accountsettings.ui.MainActivity
4243import org.microg.gms.auth.AuthConstants
4344import org.microg.gms.auth.AuthManager
@@ -112,7 +113,9 @@ class GcmInGmsService : LifecycleService() {
112113 Log .d(TAG , " onStartCommand: $intent " )
113114 lifecycleScope.launchWhenStarted {
114115 if (checkGcmStatus()) {
115- handleIntent(intent)
116+ withContext(Dispatchers .IO ) {
117+ handleIntent(intent)
118+ }
116119 } else {
117120 val intent = Intent (ACTION_GCM_RECONNECT ).apply {
118121 setPackage(Constants .GMS_PACKAGE_NAME )
@@ -169,6 +172,7 @@ class GcmInGmsService : LifecycleService() {
169172 if (GMS_GCM_NOTIFICATIONS != gcmBodyType) return
170173 val payloadData = data.getString(GcmConstants .EXTRA_GMS_GNOTS_PAYLOAD ) ? : return
171174 val notificationData = NotificationData .ADAPTER .decode(Base64 .decode(payloadData, DEFAULT_FLAGS ))
175+ Log .w(TAG , " notifyVerificationInfo: $notificationData " )
172176 if (notificationData.isActive == true ) return
173177 val account = notificationData.userInfo?.userId?.let { id ->
174178 accountManager?.getAccountsByType(AuthConstants .DEFAULT_ACCOUNT_TYPE )?.find {
@@ -209,6 +213,7 @@ class GcmInGmsService : LifecycleService() {
209213 val intent = Intent (this , MainActivity ::class .java).apply {
210214 `package` = Constants .GMS_PACKAGE_NAME
211215 flags = Intent .FLAG_ACTIVITY_NEW_TASK
216+ putExtra(KEY_IS_2_STEP_VERIFICATION , true )
212217 intentExtras.forEach { putExtra(it.key, it.value_) }
213218 }
214219 val requestCode = notificationIdGenerator.incrementAndGet()
@@ -315,16 +320,29 @@ class GcmInGmsService : LifecycleService() {
315320 }
316321 try {
317322 val identifier = notificationData.identifier
318- val actionButtons = notificationData.content?.actionButtons
319- if (actionButtons.isNullOrEmpty()) {
320- return
321- }
322- val readStateList = actionButtons.map { actionButton ->
323- ReadStateItem .Builder ().apply {
324- notification = identifier
325- state = actionButton.icon
326- status = readState
327- }.build()
323+ val readStateList = when {
324+ readState == NOTIFICATION_STATUS_COMPLETE -> {
325+ listOf (
326+ ReadStateItem .Builder ().apply {
327+ this .notification = identifier
328+ this .state = null
329+ this .status = readState
330+ }.build()
331+ )
332+ }
333+ notificationData.content?.actionButtons.isNullOrEmpty() -> {
334+ Log .w(TAG , " No action buttons found, skipping read state update." )
335+ return
336+ }
337+ else -> {
338+ notificationData.content!! .actionButtons.map {
339+ ReadStateItem .Builder ().apply {
340+ this .notification = identifier
341+ this .state = it.icon
342+ this .status = readState
343+ }.build()
344+ }
345+ }
328346 }
329347 sendNotificationReadState(accountName, ReadStateList .Builder ().apply { items = readStateList }.build())
330348 Log .i(TAG , " Notification read state updated successfully for account: $accountName " )
0 commit comments