ПОШЛО НАХУЙ КТО ЭТИ ЗВОВНКИ ДЕЛАЛ

This commit is contained in:
Jganenokk
2026-07-29 19:10:03 +07:00
parent f4f9e22be8
commit 0e51038051
17 changed files with 2562 additions and 217 deletions
+2 -1
View File
@@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
@@ -123,7 +124,7 @@
tools:node="remove" />
<service
android:name=".CallForegroundService"
android:foregroundServiceType="microphone"
android:foregroundServiceType="microphone|mediaProjection"
android:exported="false" />
<receiver
android:name=".CallActionReceiver"
@@ -20,8 +20,31 @@ class CallForegroundService : Service() {
companion object {
const val ACTION_START = "ru.komet.app.CALL_ONGOING_START"
const val ACTION_STOP = "ru.komet.app.CALL_ONGOING_STOP"
const val ACTION_SCREEN_SHARE = "ru.komet.app.CALL_SCREEN_SHARE"
const val EXTRA_SCREEN_SHARE = "screenShare"
const val ONGOING_ID = 424243
@Volatile
var screenShare = false
fun setScreenShare(ctx: Context, enabled: Boolean, caller: String) {
screenShare = enabled
val intent = Intent(ctx, CallForegroundService::class.java).apply {
action = ACTION_SCREEN_SHARE
putExtra(CallConst.EXTRA_CALLER, caller)
putExtra(EXTRA_SCREEN_SHARE, enabled)
}
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ctx.startForegroundService(intent)
} else {
ctx.startService(intent)
}
} catch (e: Exception) {
Log.w("KometFcm", "screen share FGS update failed: ${e.message}")
}
}
fun start(ctx: Context, caller: String) {
CallState.inCall = true
val intent = Intent(ctx, CallForegroundService::class.java).apply {
@@ -41,6 +64,7 @@ class CallForegroundService : Service() {
fun stop(ctx: Context) {
CallState.inCall = false
screenShare = false
try {
ctx.startService(
Intent(ctx, CallForegroundService::class.java).apply {
@@ -66,6 +90,12 @@ class CallForegroundService : Service() {
stopForeground(true)
stopSelf()
}
ACTION_SCREEN_SHARE -> {
screenShare = intent.getBooleanExtra(EXTRA_SCREEN_SHARE, false)
val caller = intent.getStringExtra(CallConst.EXTRA_CALLER) ?: "Звонок"
CallNotifier.ensureChannel(this)
startAsForeground(caller)
}
else -> {
val caller = intent?.getStringExtra(CallConst.EXTRA_CALLER) ?: "Звонок"
CallNotifier.ensureChannel(this)
@@ -103,15 +133,16 @@ class CallForegroundService : Service() {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(
ONGOING_ID, notif,
ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE,
)
var types = ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
if (screenShare) {
types = types or ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
}
startForeground(ONGOING_ID, notif, types)
} else {
startForeground(ONGOING_ID, notif)
}
} catch (e: Exception) {
Log.w("KometFcm", "startForeground(mic) failed: ${e.message}")
Log.w("KometFcm", "startForeground failed: ${e.message}")
stopSelf()
}
}
@@ -296,6 +296,16 @@ class MainActivity : FlutterActivity() {
CallForegroundService.start(applicationContext, caller)
result.success(null)
}
"setScreenShare" -> {
val enabled = call.argument<Boolean>("enabled") ?: false
val caller = call.argument<String>("caller") ?: "Звонок"
CallForegroundService.setScreenShare(
applicationContext,
enabled,
caller,
)
result.success(null)
}
"notifyEnded" -> {
CallRinger.stop()
NotificationManagerCompat.from(this).cancel(CallConst.NOTIF_ID)