Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrivoruchko committed Dec 6, 2023
1 parent 2698fa9 commit 350aca4
Show file tree
Hide file tree
Showing 32 changed files with 42 additions and 60 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ android {
applicationId = "info.dvkr.screenstream"
minSdk = 23
targetSdk = 34
versionCode = 40027
versionName = "4.0.27"
versionCode = 40028
versionName = "4.0.28"

// https://medium.com/@crafty/no-if-you-do-that-then-you-cant-use-newer-features-on-older-platforms-e-g-fa595333c0a4
vectorDrawables.useSupportLibrary = true
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import com.elvishew.xlog.XLog
import info.dvkr.screenstream.common.getLog
import org.koin.androidx.fragment.android.setupKoinFragmentFactory

public abstract class BaseActivity(@LayoutRes contentLayoutId: Int) : AppCompatActivity(contentLayoutId) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package info.dvkr.screenstream.activity

import android.Manifest
import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.os.Build
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.LayoutRes
Expand Down Expand Up @@ -54,11 +53,7 @@ public abstract class NotificationPermissionActivity(@LayoutRes contentLayoutId:
if (showSettings) {
message(R.string.app_activity_permission_allow_notifications_settings)
positiveButton(R.string.app_activity_permission_notification_settings) {
try {
startActivity(notificationHelper.getNotificationSettingsIntent(this@NotificationPermissionActivity))
} catch (cause: ActivityNotFoundException) { //TODO Need prod logs
XLog.e(getLog("showPermissionsMandatoryDialog", "showSettings: $showSettings: $cause"), cause)
}
startActivity(notificationHelper.getNotificationSettingsIntent(this@NotificationPermissionActivity))
}
} else {
message(R.string.app_activity_permission_allow_notifications)
Expand All @@ -79,11 +74,7 @@ public abstract class NotificationPermissionActivity(@LayoutRes contentLayoutId:
title(R.string.app_activity_permission_notifications_required_title)
message(R.string.app_activity_permission_enable_notifications)
positiveButton(R.string.app_activity_permission_notification_settings) {
try {
startActivity(notificationHelper.getNotificationSettingsIntent(this@NotificationPermissionActivity))
} catch (cause: ActivityNotFoundException) { //TODO Need prod logs
XLog.e(getLog("showNotificationMandatoryDialog", "$cause"), cause)
}
startActivity(notificationHelper.getNotificationSettingsIntent(this@NotificationPermissionActivity))
}
cancelable(false)
cancelOnTouchOutside(false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package info.dvkr.screenstream.notification

import android.Manifest
import android.app.*
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package info.dvkr.screenstream.settings

import android.os.Build
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ material-dialogs = "3.3.0"
xlog = "1.11.0"
ktor = "2.3.6"
webrtc = "114.5735.06"
relinker = "1.4.5"
socket = "2.1.0"
okhttp = "4.12.0"

Expand Down Expand Up @@ -66,6 +67,7 @@ ktor-server-websockets = { module = "io.ktor:ktor-server-websockets", version.re
ktor-server-status-pages = { module = "io.ktor:ktor-server-status-pages", version.ref = "ktor" }

webrtc = { module = "io.github.webrtc-sdk:android", version.ref = "webrtc" }
relinker = { module = "com.getkeepsafe.relinker:relinker", version.ref = "relinker" }
socket = { module = "io.socket:socket.io-client", version.ref = "socket" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class MjpegService : AbstractService() {

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent == null) {
XLog.e(getLog("onStartCommand"), IllegalArgumentException("MjpegService.onStartCommand: intent = null"))
stopSelfResult(startId)
XLog.e(getLog("onStartCommand"), IllegalArgumentException("MjpegService.onStartCommand: intent = null. Stop self, startId: $startId"))
return START_NOT_STICKY
}
val mjpegEvent = MjpegEvent.Intentable.fromIntent(intent) ?: run {
Expand Down Expand Up @@ -73,8 +74,7 @@ public class MjpegService : AbstractService() {
if (error is MjpegError.AddressNotFoundException || error is MjpegError.AddressInUseException) {
XLog.i(getLog("showErrorNotification", "${error.javaClass.simpleName} ${error.cause}"))
} else {
XLog.i(getLog("showErrorNotification", "${error.javaClass.simpleName} ${error.cause}"))
XLog.e(getLog("showErrorNotification"), error) //TODO Wait for prod logs
XLog.e(getLog("showErrorNotification"), error)
}

val message = error.toString(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ internal class HttpServer(

server.environment.monitor.subscribe(ApplicationStopped) {
XLog.i(getLog("monitor", "KtorStopped: ${it.hashCode()}"))
ktorServer.get().second.complete(Unit) //TODO may be null
ktorServer.get().second.complete(Unit)
coroutineScope.cancel()
serverData.clear()
}
Expand All @@ -158,15 +158,13 @@ internal class HttpServer(
XLog.w(getLog("startServer.CancellationException.BindException", cause.cause.toString()))
sendEvent(MjpegStreamingService.InternalEvent.Error(MjpegError.AddressInUseException))
} else {
XLog.w(getLog("startServer.CancellationException", cause.toString())) //TODO Need real logs
XLog.w(getLog("startServer.CancellationException", cause.toString()), cause)
sendEvent(MjpegStreamingService.InternalEvent.Error(MjpegError.HttpServerException))
}
} catch (cause: BindException) {
XLog.w(getLog("startServer.BindException", cause.toString()))
sendEvent(MjpegStreamingService.InternalEvent.Error(MjpegError.AddressInUseException))
} catch (cause: Throwable) {
XLog.e(getLog("startServer.Throwable", cause.toString())) //TODO Need real logs
XLog.e(getLog("startServer.Throwable"), cause)
sendEvent(MjpegStreamingService.InternalEvent.Error(MjpegError.HttpServerException))
}
Expand Down Expand Up @@ -220,7 +218,6 @@ internal class HttpServer(
install(StatusPages) {
exception<Throwable> { call, cause ->
if (cause is IOException || cause is IllegalArgumentException || cause is IllegalStateException) return@exception
XLog.e(this@appModule.getLog("exception<Throwable>", cause.toString()))
XLog.e(this@appModule.getLog("exception"), RuntimeException("Throwable", cause))
sendEvent(MjpegStreamingService.InternalEvent.Error(MjpegError.HttpServerException))
call.respondText(text = "500: $cause", status = HttpStatusCode.InternalServerError)
Expand Down Expand Up @@ -290,7 +287,6 @@ internal class HttpServer(
}
} catch (ignore: CancellationException) {
} catch (cause: Exception) {
XLog.w(this@appModule.getLog("socket", "catch: ${cause.localizedMessage}"))
XLog.w(this@appModule.getLog("socket", "catch: ${cause.localizedMessage}"), cause)
} finally {
XLog.i(this@appModule.getLog("socket", "finally: $clientId"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ internal sealed class MjpegError(@StringRes open val id: Int, override val messa
internal data object AddressNotFoundException : MjpegError(R.string.mjpeg_error_ip_address_not_found)
internal data object AddressInUseException : MjpegError(R.string.mjpeg_error_port_in_use)
internal data object CastSecurityException : MjpegError(R.string.mjpeg_error_invalid_media_projection)
internal data object BitmapFormatException : MjpegError(R.string.mjpeg_error_wrong_image_format) //TODO not used
internal data object HttpServerException : MjpegError(R.string.mjpeg_error_unspecified)
internal data class BitmapCaptureException(override val cause: Throwable?) : MjpegError(R.string.mjpeg_error_unspecified) {
override fun toString(context: Context): String = context.getString(id) + " [${cause?.message}]"
Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use"> المنفذ قيد الاستخدام. اختر واحد اخر </string>
<string name="mjpeg_error_invalid_media_projection"> خطآ امني : إسقاط وسائل الاعلام غير صحيح. حاول مرة أخرى </string>
<string name="mjpeg_error_ip_address_not_found">عنوان IP غير موجود.\nحاول تعطيل \"استخدام واي فاي فقط\" في إعدادات البث.</string>
<string name="mjpeg_error_wrong_image_format">يقوم النظام بإرجاع الصورة بتنسيق غير معروف .لا يوجد إصلاح المتاحة .آسف</string>
<string name="mjpeg_error_notification_permission_required">يتطلب التطبيق تمكين الإشعارات لبدء خدمة البث.\n\يرجى تمكين الإشعارات في إعدادات التطبيق.</string>
<string name="mjpeg_error_unspecified">حدث خطأ ما. من فضلك حاول مرة أخرى لاحقا.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">Port wird bereits genutzt. Bitte wählen Sie einen anderen Port.</string>
<string name="mjpeg_error_invalid_media_projection">Sicherheitsfehler: Ungültige Medien-Projektion. Bitte versuchen Sie es erneut.</string>
<string name="mjpeg_error_ip_address_not_found">IP-Adresse nicht gefunden.\nVersuchen Sie, \"Nur über WLAN\" in den Stream-Einstellungen zu deaktivieren.</string>
<string name="mjpeg_error_wrong_image_format">Das System liefert ein Bild in einem ungültigen Format zurück. Keine Fehlerbehebung verfügbar. Entschuldigung.</string>
<string name="mjpeg_error_notification_permission_required">Die Anwendung erfordert, dass Benachrichtigungen aktiviert sind, um den Streaming-Dienst zu starten.\n\nBitte aktivieren Sie Benachrichtigungen in den Anwendungseinstellungen.</string>
<string name="mjpeg_error_unspecified">Etwas ist schiefgegangen. Bitte versuchen Sie es später erneut.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">Puerto en uso. Escoja otro por favor.</string>
<string name="mjpeg_error_invalid_media_projection">Error de seguridad: Proyección de medios no válida. Intente nuevamente.</string>
<string name="mjpeg_error_ip_address_not_found">Dirección IP no encontrada.\nIntente desactivar \"Usar solo WiFi\" en la configuración de la transmisión.</string>
<string name="mjpeg_error_wrong_image_format">El sistema devuelve la imagen en formato desconocido. No hay soluciones disponibles. Lo sentimos.</string>
<string name="mjpeg_error_notification_permission_required">La aplicación requiere que las notificaciones estén habilitadas para iniciar el servicio de transmisión.\n\nPor favor, habilite las notificaciones en la configuración de la aplicación.</string>
<string name="mjpeg_error_unspecified">Algo salió mal. Por favor, inténtalo de nuevo más tarde.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">Port déjà utilisé. Sélectionnez une autre valeur.</string>
<string name="mjpeg_error_invalid_media_projection">Erreur de sécurité : projection de média invalide. Veuillez re-essayer.</string>
<string name="mjpeg_error_ip_address_not_found">Adresse IP introuvable.\nEssayez de désactiver \"WiFi uniquement\" dans les paramètres du flux.</string>
<string name="mjpeg_error_wrong_image_format">Le système fournit une image dans un format inconnu. Pas de solution, désolé.</string>
<string name="mjpeg_error_notification_permission_required">La aplicación requiere que las notificaciones estén habilitadas para iniciar el servicio de transmisión.\n\nPor favor, habilite las notificaciones en la configuración de la aplicación.</string>
<string name="mjpeg_error_unspecified">Algo salió mal. Por favor, inténtalo de nuevo más tarde.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">पोर्ट पहले से ही उपयोग में है। कोई दूसरा चुनें।</string>
<string name="mjpeg_error_invalid_media_projection">सुरक्षा त्रुटि: अमान्य मीडिया प्रक्षेपण। एक बार और कोशिश करें।</string>
<string name="mjpeg_error_ip_address_not_found">IP पता नहीं मिला।\nप्रवाह सेटिंग्स में \"वाईफाई का ही इस्तेमाल करें\" को अक्षम करने का प्रयास करें।</string>
<string name="mjpeg_error_wrong_image_format">सिस्टम अज्ञात प्रारूप में छवि लौटाता है। कोई फिक्स उपलब्ध नहीं। माफ़ कीजिये।</string>
<string name="mjpeg_error_notification_permission_required">ऐप्लिकेशन को स्ट्रीमिंग सेवा शुरू करने के लिए सूचनाओं को सक्षम करने की आवश्यकता है।\n\nकृपया ऐप्लिकेशन की सेटिंग्स में सूचनाओं को सक्षम करें।</string>
<string name="mjpeg_error_unspecified">कुछ गलत हो गया है। कृपया बाद में पुनः प्रयास करें।</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">Porta già in uso. Scegline un\'altra.</string>
<string name="mjpeg_error_invalid_media_projection">Errore di sicurezza: protezione multimedia non valida. Riprova.</string>
<string name="mjpeg_error_ip_address_not_found">Indirizzo IP non trovato.\nProva a disabilitare \"Usa solo WiFi\" nelle impostazioni di streaming.</string>
<string name="mjpeg_error_wrong_image_format">Il sistema restituisce l\'immagine in un formato sconosciuto. Nessuna soluzione disponibile. Spiacente.</string>
<string name="mjpeg_error_notification_permission_required">L\'applicazione richiede che le notifiche siano abilitate per avviare il servizio di streaming.\n\nSi prega di abilitare le notifiche nelle impostazioni dell\'applicazione.</string>
<string name="mjpeg_error_unspecified">Qualcosa è andato storto. Per favore, riprova più tardi.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">ポートは既に使用されています。 他のポートを選択してください。</string>
<string name="mjpeg_error_invalid_media_projection">セキュリティエラー: メディアプロジェクションが無効です。 もう一度お試しください。</string>
<string name="mjpeg_error_ip_address_not_found">IPアドレスが見つかりません。\nストリーム設定で「WiFiのみ使用する」を無効にしてみてください。</string>
<string name="mjpeg_error_wrong_image_format">システムが画像を不明な形式で返します。 修正できません。 ごめんなさい。</string>
<string name="mjpeg_error_notification_permission_required">アプリケーションはストリーミングサービスを開始するために通知の有効化が必要です。\n\nアプリケーションの設定で通知を有効にしてください。</string>
<string name="mjpeg_error_unspecified">何か問題が発生しました。後で再試行してください。</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<string name="mjpeg_error_port_in_use">Poort is al in gebruik, kies een andere.</string>
<string name="mjpeg_error_invalid_media_projection">Beveilig fout: Ongeldige media projectie. Probeer het nogmaals.</string>
<string name="mjpeg_error_ip_address_not_found">IP-adres niet gevonden.\nProbeer \"Gebruik alleen WiFi\" uit te schakelen in de streaminstellingen.</string>
<string name="mjpeg_error_wrong_image_format">Systeem maakt een frame in een onbekend formaat. Geen oplossing mogelijk. Sorry.</string>
<string name="mjpeg_error_notification_permission_required">De applicatie vereist dat meldingen zijn ingeschakeld om de streamingdienst te starten.\n\nSchakel meldingen in in de applicatie-instellingen.</string>
<string name="mjpeg_error_unspecified">Er is iets misgegaan. Probeer het later opnieuw.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<string name="mjpeg_error_port_in_use">Port w użyciu. Wybierz inny.</string>
<string name="mjpeg_error_invalid_media_projection">Błąd bezpieczeństwa: nieprawidłowa projekcja multimediów. Spróbuj ponownie.</string>
<string name="mjpeg_error_ip_address_not_found">Nie znaleziono adresu IP.\nSpróbuj wyłączyć opcję \"Użyj tylko WiFi\" w ustawieniach strumienia.</string>
<string name="mjpeg_error_wrong_image_format">System nadaje obrazowi niewłaściwy format. Brak rozwiązania tego problemu.</string>
<string name="mjpeg_error_notification_permission_required">Aplikacja wymaga włączonych powiadomień, aby rozpocząć usługę przesyłania strumieniowego.\n\nProszę włączyć powiadomienia w ustawieniach aplikacji.</string>
<string name="mjpeg_error_unspecified">Coś poszło nie tak. Proszę spróbować ponownie później.</string>

Expand Down
1 change: 0 additions & 1 deletion mjpeg/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
<string name="mjpeg_error_port_in_use">Porta já em uso. Escolha outra.</string>
<string name="mjpeg_error_invalid_media_projection">Erro de segurança: Projeção de mídia inválida. Tente novamente.</string>
<string name="mjpeg_error_ip_address_not_found">Endereço IP não encontrado.\nTente desativar \"Usar apenas Wi-Fi\" nas configurações de transmissão.</string>
<string name="mjpeg_error_wrong_image_format">O sistema retorna a imagem em um formato desconhecido. Não há correção disponível. Desculpe.</string>
<string name="mjpeg_error_notification_permission_required">O aplicativo requer notificações ativadas para iniciar o serviço de transmissão.\n\nPor favor, ative as notificações nas configurações do aplicativo.</string>
<string name="mjpeg_error_unspecified">Algo deu errado. Tente novamente mais tarde.</string>

Expand Down
Loading

0 comments on commit 350aca4

Please sign in to comment.