@qusaieilouti99/call-manager 0.1.102 → 0.1.103

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.
@@ -43,8 +43,8 @@ import android.database.ContentObserver
43
43
  import android.os.Vibrator
44
44
  import android.os.VibrationEffect
45
45
  import android.provider.Settings
46
- import android.content.ContentResolver
47
- import android.database.ContentObserver
46
+
47
+
48
48
 
49
49
  /**
50
50
  * Core call‐management engine. Manages self-managed telecom calls,
@@ -89,8 +89,8 @@ object CallEngine {
89
89
  private var ringtone: android.media.Ringtone? = null
90
90
  private var ringbackPlayer: MediaPlayer? = null
91
91
  // Vibration + volume‐key observer
92
- private var vibrator: android.os.Vibrator? = null
93
- private var volumeObserver: android.database.ContentObserver? = null
92
+ private var vibrator: Vibrator? = null
93
+ private var volumeObserver: ContentObserver? = null
94
94
  private var audioManager: AudioManager? = null
95
95
  private var wakeLock: PowerManager.WakeLock? = null
96
96
 
@@ -1214,10 +1214,11 @@ object CallEngine {
1214
1214
  private fun playRingtone() {
1215
1215
  val context = requireContext()
1216
1216
 
1217
- // 1) Start repeating vibration
1218
- vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator
1217
+ // 1) start repeating vibration
1218
+ vibrator = context.getSystemService(Context.VIBRATOR_SERVICE)
1219
+ as? Vibrator
1219
1220
  vibrator?.let { v ->
1220
- val pattern = longArrayOf(0L, 500L, 500L) // wait, vibrate, pause
1221
+ val pattern = longArrayOf(0L, 500L, 500L)
1221
1222
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
1222
1223
  v.vibrate(VibrationEffect.createWaveform(pattern, 0))
1223
1224
  } else {
@@ -1226,7 +1227,7 @@ object CallEngine {
1226
1227
  }
1227
1228
  }
1228
1229
 
1229
- // 2) Play the ringtone
1230
+ // 2) play the ringtone
1230
1231
  try {
1231
1232
  val uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)
1232
1233
  ringtone = RingtoneManager.getRingtone(context, uri)
@@ -1235,22 +1236,19 @@ object CallEngine {
1235
1236
  Log.e(TAG, "Failed to play ringtone", e)
1236
1237
  }
1237
1238
 
1238
- // 3) Observe any change to the ring‐volume setting
1239
+ // 3) observe ANY system‐settings change (will include volume changes)
1239
1240
  if (volumeObserver == null) {
1240
1241
  val resolver: ContentResolver = context.contentResolver
1241
1242
  volumeObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
1242
1243
  override fun onChange(selfChange: Boolean, uri: Uri?) {
1243
1244
  super.onChange(selfChange, uri)
1244
- // If the ring volume changed, silence both ringtone+vibration
1245
- if (uri == Settings.System.getUriFor(Settings.System.VOLUME_RING)) {
1246
- Log.d(TAG, "Ring volume changed → silencing ringtone/vibration")
1247
- stopRingtone()
1248
- }
1245
+ Log.d(TAG, "Settings change observed silencing ringtone/vibration")
1246
+ stopRingtone()
1249
1247
  }
1250
1248
  }
1251
1249
  resolver.registerContentObserver(
1252
- Settings.System.getUriFor(Settings.System.VOLUME_RING),
1253
- false,
1250
+ Settings.System.CONTENT_URI,
1251
+ true, // listen to descendants too
1254
1252
  volumeObserver!!
1255
1253
  )
1256
1254
  }
@@ -1265,11 +1263,11 @@ object CallEngine {
1265
1263
  }
1266
1264
  ringtone = null
1267
1265
 
1268
- // 1) Cancel vibration
1266
+ // cancel vibration
1269
1267
  vibrator?.cancel()
1270
1268
  vibrator = null
1271
1269
 
1272
- // 2) Unregister volume observer
1270
+ // unregister our observer
1273
1271
  volumeObserver?.let {
1274
1272
  requireContext().contentResolver.unregisterContentObserver(it)
1275
1273
  volumeObserver = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.102",
3
+ "version": "0.1.103",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",