stcp: фикс UAF log_dump, дренаж очередей при закрытии, защита pre-closed серверной ветки, логирование тихих сбросов rx
This commit is contained in:
1 parent
ceaf466b1c
commit
3f7b4351cd
4 files changed
+56
-13
No files matched your search
@@ -9,6 +9,8 @@ import android.media.Ringtone
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import com.utun.chat.ChatApplication
|
||||
@@ -36,6 +38,17 @@ class RingtonePlayer {
|
||||
private var vibrator: Vibrator? = null
|
||||
private var focusRequest: AudioFocusRequest? = null
|
||||
|
||||
/* Вибрация идёт конечными one-shot (repeat=-1), пере-запускаемыми таймером из приложения:
|
||||
на ряде OEM-чипов (sc27xx и пр.) бесконечный repeat=0 живёт в HAL и не гасится cancel(). */
|
||||
private val vibrateHandler = Handler(Looper.getMainLooper())
|
||||
private val vibrateRunnable = object : Runnable {
|
||||
override fun run() {
|
||||
if (vibrator == null) return
|
||||
vibrator?.vibrate(VibrationEffect.createWaveform(longArrayOf(0, 1000), -1))
|
||||
vibrateHandler.postDelayed(this, 2000)
|
||||
}
|
||||
}
|
||||
|
||||
fun play() {
|
||||
stop()
|
||||
val ctx = ChatApplication.instance
|
||||
@@ -130,8 +143,9 @@ class RingtonePlayer {
|
||||
} ?: return
|
||||
if (!v.hasVibrator()) return
|
||||
try {
|
||||
v.vibrate(VibrationEffect.createWaveform(longArrayOf(1000, 1000), 0))
|
||||
vibrator = v
|
||||
vibrateHandler.removeCallbacks(vibrateRunnable)
|
||||
vibrateRunnable.run()
|
||||
LogManager.addLog("INFO", "Ringtone", "vibration started")
|
||||
} catch (e: Exception) {
|
||||
LogManager.addLog("WARN", "Ringtone", "vibrate failed: ${e.message}")
|
||||
@@ -141,6 +155,8 @@ class RingtonePlayer {
|
||||
private fun stopVibrate() {
|
||||
vibrator?.let { try { it.cancel() } catch (_: Exception) {} }
|
||||
vibrator = null
|
||||
vibrateHandler.removeCallbacks(vibrateRunnable)
|
||||
LogManager.addLog("INFO", "Ringtone", "vibration stopped")
|
||||
}
|
||||
|
||||
/* ── audio focus (fallback API 26–27) ── */
|
||||
|
||||
Reference in new issue
Block a user