@qusaieilouti99/call-manager 0.1.103 → 0.1.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -88,9 +88,11 @@ object CallEngine {
|
|
|
88
88
|
// Simplified Audio & Media Management (NO MANUAL AUDIO FOCUS)
|
|
89
89
|
private var ringtone: android.media.Ringtone? = null
|
|
90
90
|
private var ringbackPlayer: MediaPlayer? = null
|
|
91
|
-
|
|
91
|
+
|
|
92
|
+
// Vibration + “ring‐volume” ContentObserver
|
|
92
93
|
private var vibrator: Vibrator? = null
|
|
93
94
|
private var volumeObserver: ContentObserver? = null
|
|
95
|
+
|
|
94
96
|
private var audioManager: AudioManager? = null
|
|
95
97
|
private var wakeLock: PowerManager.WakeLock? = null
|
|
96
98
|
|
|
@@ -969,7 +971,7 @@ object CallEngine {
|
|
|
969
971
|
putExtra("callerName", callerName)
|
|
970
972
|
putExtra("callType", callType)
|
|
971
973
|
if (callerPicUrl != null) {
|
|
972
|
-
putExtra("
|
|
974
|
+
putExtra("callerAvatar", callerPicUrl)
|
|
973
975
|
}
|
|
974
976
|
|
|
975
977
|
putExtra("LOCK_SCREEN_MODE", true) // Flag to identify lock screen mode
|
|
@@ -1010,7 +1012,7 @@ object CallEngine {
|
|
|
1010
1012
|
putExtra("callerName", callerName)
|
|
1011
1013
|
putExtra("callType", callType)
|
|
1012
1014
|
if (callerPicUrl != null) {
|
|
1013
|
-
putExtra("
|
|
1015
|
+
putExtra("callerAvatar", callerPicUrl)
|
|
1014
1016
|
}
|
|
1015
1017
|
// No lock screen flag - standard notification mode
|
|
1016
1018
|
}
|
|
@@ -1215,8 +1217,7 @@ object CallEngine {
|
|
|
1215
1217
|
val context = requireContext()
|
|
1216
1218
|
|
|
1217
1219
|
// 1) start repeating vibration
|
|
1218
|
-
vibrator = context.getSystemService(Context.VIBRATOR_SERVICE)
|
|
1219
|
-
as? Vibrator
|
|
1220
|
+
vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator
|
|
1220
1221
|
vibrator?.let { v ->
|
|
1221
1222
|
val pattern = longArrayOf(0L, 500L, 500L)
|
|
1222
1223
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
@@ -1236,21 +1237,22 @@ object CallEngine {
|
|
|
1236
1237
|
Log.e(TAG, "Failed to play ringtone", e)
|
|
1237
1238
|
}
|
|
1238
1239
|
|
|
1239
|
-
// 3) observe
|
|
1240
|
+
// 3) observe only the ring‐volume URI
|
|
1240
1241
|
if (volumeObserver == null) {
|
|
1241
1242
|
val resolver: ContentResolver = context.contentResolver
|
|
1243
|
+
// build the ring‐volume URI via literal "volume_ring"
|
|
1244
|
+
val ringUri: Uri = Settings.System.getUriFor("volume_ring")
|
|
1242
1245
|
volumeObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
|
|
1243
1246
|
override fun onChange(selfChange: Boolean, uri: Uri?) {
|
|
1244
1247
|
super.onChange(selfChange, uri)
|
|
1245
|
-
|
|
1246
|
-
|
|
1248
|
+
// only react when ringUri actually changed
|
|
1249
|
+
if (uri == ringUri) {
|
|
1250
|
+
Log.d(TAG, "Ring volume changed → silencing ringtone/vibration")
|
|
1251
|
+
stopRingtone()
|
|
1252
|
+
}
|
|
1247
1253
|
}
|
|
1248
1254
|
}
|
|
1249
|
-
resolver.registerContentObserver(
|
|
1250
|
-
Settings.System.CONTENT_URI,
|
|
1251
|
-
true, // listen to descendants too
|
|
1252
|
-
volumeObserver!!
|
|
1253
|
-
)
|
|
1255
|
+
resolver.registerContentObserver(ringUri, false, volumeObserver!!)
|
|
1254
1256
|
}
|
|
1255
1257
|
}
|
|
1256
1258
|
|
|
@@ -1267,7 +1269,7 @@ object CallEngine {
|
|
|
1267
1269
|
vibrator?.cancel()
|
|
1268
1270
|
vibrator = null
|
|
1269
1271
|
|
|
1270
|
-
// unregister our observer
|
|
1272
|
+
// unregister our ring‐volume observer
|
|
1271
1273
|
volumeObserver?.let {
|
|
1272
1274
|
requireContext().contentResolver.unregisterContentObserver(it)
|
|
1273
1275
|
volumeObserver = null
|