Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download android/app/src/main/java/com/httpsms/Receiver.kt from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 2.68 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/83a59cae175e3c9a43b6f5d3f8749ca61b6b5072/android/app/src/main/java/com/httpsms/Receiver.kt
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@83a59cae175e3c9a43b6f5d3f8749ca61b6b5072/android/app/src/main/java/com/httpsms/Receiver.kt
-
curl -L -o Receiver.kt https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/83a59cae175e3c9a43b6f5d3f8749ca61b6b5072/android/app/src/main/java/com/httpsms/Receiver.kt
2.68 kB
| package com.httpsms | |
| import android.content.Context | |
| import android.content.Context.RECEIVER_EXPORTED | |
| import android.content.IntentFilter | |
| import android.os.Build | |
| import androidx.annotation.RequiresApi | |
| import timber.log.Timber | |
| object Receiver { | |
| private var sentReceiver: SentReceiver? = null; | |
| private var deliveredReceiver: DeliveredReceiver? = null; | |
| fun register(context: Context) { | |
| if(sentReceiver == null) { | |
| Timber.d("registering [sent] receiver for intent [${SmsManagerService.sentAction()}]") | |
| sentReceiver = SentReceiver() | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | |
| context.registerReceiver( | |
| sentReceiver, | |
| IntentFilter(SmsManagerService.sentAction()), | |
| RECEIVER_EXPORTED | |
| ) | |
| } else { | |
| context.registerReceiver( | |
| sentReceiver, | |
| IntentFilter(SmsManagerService.sentAction()) | |
| ) | |
| } | |
| } | |
| if(deliveredReceiver == null) { | |
| Timber.d("registering [delivered] receiver for intent [${SmsManagerService.deliveredAction()}]") | |
| deliveredReceiver = DeliveredReceiver() | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | |
| context.registerReceiver( | |
| deliveredReceiver, | |
| IntentFilter(SmsManagerService.deliveredAction()), | |
| RECEIVER_EXPORTED | |
| ) | |
| } else { | |
| context.registerReceiver( | |
| deliveredReceiver, | |
| IntentFilter(SmsManagerService.deliveredAction()) | |
| ) | |
| } | |
| } | |
| } | |
| fun isValid(context: Context, messageId: String?): Boolean { | |
| if (messageId == null) { | |
| Timber.e("cannot handle event because the message ID is null") | |
| return false | |
| } | |
| if (!Settings.isLoggedIn(context)) { | |
| Timber.w("cannot handle message with id [$messageId] because the user is not logged in") | |
| return false | |
| } | |
| if (!Settings.getActiveStatus(context, Constants.SIM1) && !Settings.getActiveStatus(context, Constants.SIM2)) { | |
| Timber.w("cannot handle message with id [$messageId] because the user is not active") | |
| return false | |
| } | |
| if(messageId.contains(".")) { | |
| Timber.d("message id [${messageId}] is for multipart segment [${messageId.split(".")[1]}]") | |
| return false | |
| } | |
| return true | |
| } | |
| } | |