react-native-telecom 0.0.0-stage → 0.1.0

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.
Files changed (57) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +309 -2
  3. package/Telecom.podspec +20 -0
  4. package/android/build.gradle +58 -0
  5. package/android/src/main/AndroidManifest.xml +43 -0
  6. package/android/src/main/java/com/telecom/CallSession.kt +37 -0
  7. package/android/src/main/java/com/telecom/CallSessionManager.kt +486 -0
  8. package/android/src/main/java/com/telecom/TelecomAudioRouter.kt +227 -0
  9. package/android/src/main/java/com/telecom/TelecomAvatarLoader.kt +77 -0
  10. package/android/src/main/java/com/telecom/TelecomCallService.kt +395 -0
  11. package/android/src/main/java/com/telecom/TelecomCallUi.kt +65 -0
  12. package/android/src/main/java/com/telecom/TelecomInCallActivity.kt +285 -0
  13. package/android/src/main/java/com/telecom/TelecomIncomingCallActivity.kt +171 -0
  14. package/android/src/main/java/com/telecom/TelecomModule.kt +189 -0
  15. package/android/src/main/java/com/telecom/TelecomPackage.kt +31 -0
  16. package/android/src/main/java/com/telecom/TelecomPushBridge.kt +82 -0
  17. package/android/src/main/java/com/telecom/TelecomRingtonePlayer.kt +109 -0
  18. package/android/src/main/java/com/telecom/TelecomUiConfig.kt +27 -0
  19. package/android/src/main/res/drawable/rn_telecom_action_pill.xml +6 -0
  20. package/android/src/main/res/drawable/rn_telecom_answer_circle.xml +8 -0
  21. package/android/src/main/res/drawable/rn_telecom_answer_circle_green.xml +8 -0
  22. package/android/src/main/res/drawable/rn_telecom_avatar_bg.xml +6 -0
  23. package/android/src/main/res/drawable/rn_telecom_avatar_circle.xml +12 -0
  24. package/android/src/main/res/drawable/rn_telecom_btn_answer.xml +6 -0
  25. package/android/src/main/res/drawable/rn_telecom_btn_decline.xml +6 -0
  26. package/android/src/main/res/drawable/rn_telecom_btn_message.xml +9 -0
  27. package/android/src/main/res/drawable/rn_telecom_btn_secondary.xml +6 -0
  28. package/android/src/main/res/drawable/rn_telecom_control_circle.xml +8 -0
  29. package/android/src/main/res/drawable/rn_telecom_control_circle_on.xml +8 -0
  30. package/android/src/main/res/drawable/rn_telecom_decline_circle.xml +8 -0
  31. package/android/src/main/res/drawable/rn_telecom_ic_call.xml +10 -0
  32. package/android/src/main/res/drawable/rn_telecom_ic_call_end.xml +16 -0
  33. package/android/src/main/res/drawable/rn_telecom_ic_call_white.xml +10 -0
  34. package/android/src/main/res/drawable/rn_telecom_ic_dialpad.xml +13 -0
  35. package/android/src/main/res/drawable/rn_telecom_ic_hold.xml +10 -0
  36. package/android/src/main/res/drawable/rn_telecom_ic_message.xml +10 -0
  37. package/android/src/main/res/drawable/rn_telecom_ic_mic.xml +10 -0
  38. package/android/src/main/res/drawable/rn_telecom_ic_mic_off.xml +10 -0
  39. package/android/src/main/res/drawable/rn_telecom_ic_speaker.xml +10 -0
  40. package/android/src/main/res/layout/rn_telecom_control_item.xml +36 -0
  41. package/android/src/main/res/layout/rn_telecom_incall.xml +168 -0
  42. package/android/src/main/res/layout/rn_telecom_incoming_call.xml +188 -0
  43. package/ios/Telecom.h +5 -0
  44. package/ios/Telecom.mm +66 -0
  45. package/lib/module/NativeTelecom.js +5 -0
  46. package/lib/module/NativeTelecom.js.map +1 -0
  47. package/lib/module/index.js +102 -0
  48. package/lib/module/index.js.map +1 -0
  49. package/lib/module/package.json +1 -0
  50. package/lib/typescript/package.json +1 -0
  51. package/lib/typescript/src/NativeTelecom.d.ts +40 -0
  52. package/lib/typescript/src/NativeTelecom.d.ts.map +1 -0
  53. package/lib/typescript/src/index.d.ts +104 -0
  54. package/lib/typescript/src/index.d.ts.map +1 -0
  55. package/package.json +153 -4
  56. package/src/NativeTelecom.ts +55 -0
  57. package/src/index.tsx +220 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abdul Moiz
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,310 @@
1
- # Temporary Holding Version
1
+ # react-native-telecom
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ### The modern **react-native-callkeep** alternative for New Architecture
4
+
5
+ **Native incoming / outgoing call UI for React Native** — Android Jetpack **Core-Telecom**, CallStyle notifications, lock-screen full-screen UI, ringtone, mute, hold, keypad, speaker / Bluetooth audio routes, and FCM wake hooks.
6
+
7
+ > Looking for **react-native-callkeep**, **CallKeep**, **ConnectionService**, **CallKit-style VoIP UI**, or a **TurboModule telecom** library that works with **React Native New Architecture (Fabric)**? This package is built for that.
8
+
9
+ [![npm version](https://img.shields.io/npm/v/react-native-telecom.svg)](https://www.npmjs.com/package/react-native-telecom)
10
+ [![license](https://img.shields.io/npm/l/react-native-telecom.svg)](./LICENSE)
11
+ [![platform](https://img.shields.io/badge/platform-Android-green.svg)](./docs/android-setup.md)
12
+ [![arch](https://img.shields.io/badge/New%20Architecture-TurboModule-blue.svg)](https://reactnative.dev/docs/the-new-architecture/landing-page)
13
+
14
+ **npm:** `react-native-telecom` · **GitHub:** [itxmoizdev/react-native-telecom](https://github.com/itxmoizdev/react-native-telecom)
15
+
16
+ ---
17
+
18
+ ## Why developers search for this (and leave CallKeep)
19
+
20
+ | Problem with older stacks | What `react-native-telecom` does |
21
+ |---------------------------|----------------------------------|
22
+ | `react-native-callkeep` breaks or fights **New Architecture / Reanimated / Fabric** | **TurboModule-first** Kotlin API |
23
+ | Legacy Android **ConnectionService** path is dated | Official **Jetpack Core-Telecom** (`androidx.core:core-telecom`) |
24
+ | Hard to get **native CallStyle** + full-screen on OEMs (Vivo, Xiaomi…) | CallStyle FGS + full-screen Activity + ringtone player |
25
+ | Want WhatsApp / Phone-app style UI | Pixel-style incoming + in-call screens (overridable layouts) |
26
+ | Need Telnyx / WebRTC / LiveKit / Twilio | Library owns UI + Telecom; you attach media on audio-session events |
27
+
28
+ **Keywords people use that this README targets:**
29
+ `react-native-callkeep`, `callkeep alternative`, `react native voip`, `react native incoming call`, `react native call notification`, `ConnectionService`, `Core Telecom`, `CallStyle`, `full screen intent`, `react native telecom`, `TurboModule calls`, `New Architecture callkeep`, `FCM incoming call`, `Telnyx react native`, `WebRTC call UI`.
30
+
31
+ ---
32
+
33
+ ## Features
34
+
35
+ ### Native Android call experience
36
+ - **CallStyle** system notification (Answer / Decline / End)
37
+ - **Full-screen incoming UI** over the lock screen (`showWhenLocked` + `USE_FULL_SCREEN_INTENT`)
38
+ - **Outgoing + in-call UI** (mute, keypad, audio route, hold, end)
39
+ - **Default ringtone + vibration** (respects silent / vibrate / normal)
40
+ - Quiet ongoing notification after answer (no stuck ringing)
41
+
42
+ ### VoIP app plumbing
43
+ - Jetpack **Core-Telecom** session lifecycle
44
+ - **Mute / hold** via Telecom + `AudioManager`
45
+ - **Audio routes:** earpiece · speaker · Bluetooth SCO
46
+ - **DTMF** local tones + JS `dtmfTone` events (send over your signaling / WebRTC)
47
+ - **Caller avatar** URL (HTTPS / file) with initials fallback
48
+ - **FCM / push wake** via `TelecomPushBridge` when JS is dead
49
+ - **Audio session events** to attach Telnyx, WebRTC, LiveKit, etc.
50
+
51
+ ### Developer experience
52
+ - React Native **New Architecture** / **TurboModules**
53
+ - TypeScript API
54
+ - Overridable XML layouts for brand UI
55
+ - Example app included
56
+
57
+ ### Platform status
58
+ | Platform | Status |
59
+ |----------|--------|
60
+ | **Android** | Supported (minSdk **26**) |
61
+ | **iOS (CallKit)** | Planned — not in v0.x |
62
+
63
+ ---
64
+
65
+ ## Installation (npm / yarn / pnpm)
66
+
67
+ ```bash
68
+ npm install react-native-telecom
69
+ # or
70
+ yarn add react-native-telecom
71
+ # or
72
+ pnpm add react-native-telecom
73
+ ```
74
+
75
+ **Requirements**
76
+ - React Native **New Architecture** enabled
77
+ - Android **minSdk 26+**
78
+ - **Physical device** for reliable Telecom / CallStyle testing
79
+
80
+ Full permissions & OEM notes: [docs/android-setup.md](./docs/android-setup.md)
81
+
82
+ ---
83
+
84
+ ## Quick start
85
+
86
+ ```ts
87
+ import Telecom from 'react-native-telecom';
88
+
89
+ await Telecom.setup({
90
+ appName: 'My App',
91
+ supportsVideo: true,
92
+ ui: {
93
+ backgroundColor: '#F7F4EF',
94
+ launchFullScreenOnIncoming: true,
95
+ },
96
+ });
97
+
98
+ // Attach real media (Telnyx / WebRTC / LiveKit) here
99
+ Telecom.addEventListener('didActivateAudioSession', ({ callUUID }) => {
100
+ // start peer connection / Telnyx call for callUUID
101
+ });
102
+
103
+ Telecom.addEventListener('didDeactivateAudioSession', () => {
104
+ // tear down media
105
+ });
106
+
107
+ Telecom.addEventListener('dtmfTone', ({ digit }) => {
108
+ // insertDTMF / SIP INFO / your signaling
109
+ });
110
+
111
+ // Incoming (optional avatar URL)
112
+ Telecom.displayIncomingCall(
113
+ uuid,
114
+ '+15551234567',
115
+ 'Ada Lovelace',
116
+ false,
117
+ false,
118
+ 'https://example.com/ada.jpg'
119
+ );
120
+
121
+ // Outgoing
122
+ Telecom.startCall(uuid, '+15557654321', 'Grace Hopper', false, avatarUrl);
123
+
124
+ Telecom.setMuted(uuid, true);
125
+ Telecom.setAudioRoute(uuid, 'speaker'); // 'earpiece' | 'speaker' | 'bluetooth'
126
+ Telecom.sendDtmf(uuid, '123#');
127
+ Telecom.endCall(uuid);
128
+ ```
129
+
130
+ ---
131
+
132
+ ## react-native-callkeep vs react-native-telecom
133
+
134
+ | | **react-native-telecom** | **react-native-callkeep** |
135
+ |--|--------------------------|---------------------------|
136
+ | Android API | Jetpack **Core-Telecom** | Legacy ConnectionService focus |
137
+ | Bridge | **TurboModule** / New Arch | Older bridge (painful on New Arch) |
138
+ | Native language | **Kotlin** | Java |
139
+ | Call UI | CallStyle + customizable full-screen | System / limited customization |
140
+ | Ringtone control | App player + silent CallStyle channel | Varies by OEM |
141
+ | Audio routes | Earpiece / speaker / Bluetooth API | Limited / app-side |
142
+ | Push wake helper | `TelecomPushBridge` | DIY |
143
+ | iOS | Coming later | CallKit today |
144
+ | Best for | New Arch VoIP apps (Telnyx, WebRTC…) | Legacy RN apps already on CallKeep |
145
+
146
+ If your search was *“react native callkeep new architecture”* or *“callkeep not working fabric”* — start here.
147
+
148
+ ---
149
+
150
+ ## API reference
151
+
152
+ ### Methods
153
+
154
+ | Method | Description |
155
+ |--------|-------------|
156
+ | `setup(options?)` | Register with Android Telecom (`CallsManager`) |
157
+ | `displayIncomingCall(uuid, handle, callerName, hasVideo?, autoAnswer?, avatarUrl?)` | Show incoming CallStyle + full-screen UI |
158
+ | `startCall(uuid, handle, callerName, hasVideo?, avatarUrl?)` | Start outgoing call UI |
159
+ | `answerCall(uuid)` | Answer (native or JS) |
160
+ | `endCall(uuid)` / `endAllCalls()` | Hang up |
161
+ | `setMuted(uuid, muted)` | Microphone mute |
162
+ | `setOnHold(uuid, hold)` | Hold / resume |
163
+ | `setAudioRoute(uuid, route)` | `earpiece` \| `speaker` \| `bluetooth` |
164
+ | `getAvailableAudioRoutes()` | List routes + availability |
165
+ | `sendDtmf(uuid, digits)` | Local DTMF + `dtmfTone` events |
166
+ | `handlePushMessage(data)` | Foreground FCM data → incoming call |
167
+ | `addEventListener` / `removeAllListeners` | Native events |
168
+
169
+ ### Events
170
+
171
+ | Event | Payload | When |
172
+ |-------|---------|------|
173
+ | `didDisplayIncomingCall` | `{ callUUID, handle, callerName, hasVideo, direction, avatarUrl? }` | Call UI shown |
174
+ | `answerCall` | `{ callUUID }` | Answered |
175
+ | `endCall` | `{ callUUID, error? }` | Ended |
176
+ | `didChangeMuteState` | `{ callUUID, muted }` | Mute toggled |
177
+ | `didChangeHoldState` | `{ callUUID, hold }` | Hold toggled |
178
+ | `didChangeSpeaker` | `{ callUUID, speakerOn }` | Legacy speaker flag |
179
+ | `didChangeAudioRoute` | `{ callUUID, route }` | Route changed |
180
+ | `didActivateAudioSession` | `{ callUUID, route }` | **Attach media here** |
181
+ | `didDeactivateAudioSession` | `{ callUUID? }` | **Detach media here** |
182
+ | `dtmfTone` | `{ callUUID, digit }` | Keypad / `sendDtmf` |
183
+
184
+ ---
185
+
186
+ ## FCM / push (background & killed)
187
+
188
+ When the app is killed, JS may not run. Use native:
189
+
190
+ ```kotlin
191
+ // FirebaseMessagingService.onMessageReceived
192
+ TelecomPushBridge.handleIncomingCall(applicationContext, message.data)
193
+ ```
194
+
195
+ Payload example:
196
+
197
+ ```json
198
+ {
199
+ "type": "incoming_call",
200
+ "uuid": "in-1710000000",
201
+ "handle": "+15551234567",
202
+ "callerName": "Ada Lovelace",
203
+ "avatarUrl": "https://example.com/ada.jpg"
204
+ }
205
+ ```
206
+
207
+ Details: [docs/fcm.md](./docs/fcm.md)
208
+
209
+ ---
210
+
211
+ ## Media: Telnyx, WebRTC, LiveKit, Twilio
212
+
213
+ This library is **UI + Telecom**, not a media engine.
214
+
215
+ 1. Show native call UI with `displayIncomingCall` / `startCall`
216
+ 2. On `didActivateAudioSession` → connect Telnyx / WebRTC / LiveKit
217
+ 3. On `didDeactivateAudioSession` → hang up media
218
+ 4. Sync mute with `didChangeMuteState`
219
+ 5. Forward `dtmfTone` into your SIP / WebRTC DTMF API
220
+
221
+ Guide: [docs/media.md](./docs/media.md)
222
+
223
+ ---
224
+
225
+ ## Customize the call screens
226
+
227
+ Override in your app:
228
+
229
+ - `android/app/src/main/res/layout/rn_telecom_incoming_call.xml`
230
+ - `android/app/src/main/res/layout/rn_telecom_incall.xml`
231
+
232
+ Or theme via `Telecom.setup({ ui: { … } })`.
233
+
234
+ Keep the documented view ids if you override XML.
235
+
236
+ ---
237
+
238
+ ## Example app
239
+
240
+ ```bash
241
+ git clone https://github.com/itxmoizdev/react-native-telecom.git
242
+ cd react-native-telecom
243
+ yarn
244
+ yarn prepare
245
+ yarn example android
246
+ ```
247
+
248
+ Use a **physical Android device**. Emulators are unreliable for Telecom / CallStyle / full-screen intent.
249
+
250
+ ---
251
+
252
+ ## Documentation
253
+
254
+ | Doc | Topic |
255
+ |-----|--------|
256
+ | [docs/android-setup.md](./docs/android-setup.md) | Permissions, OEM, CallStyle, minSdk |
257
+ | [docs/fcm.md](./docs/fcm.md) | FCM high-priority incoming wake |
258
+ | [docs/media.md](./docs/media.md) | WebRTC / Telnyx audio session wiring |
259
+
260
+ ---
261
+
262
+ ## FAQ (AEO — answers search engines & assistants extract)
263
+
264
+ ### Is this a react-native-callkeep alternative?
265
+ **Yes.** It targets the same job (native VoIP call UI) with Jetpack Core-Telecom and TurboModules for New Architecture.
266
+
267
+ ### Does it support iOS CallKit?
268
+ **Not in v0.x.** Android is production-focused first; CallKit is planned.
269
+
270
+ ### Can I use it with Telnyx / WebRTC?
271
+ **Yes.** Use audio-session events to attach your media SDK. The library does not ship Telnyx or WebRTC binaries.
272
+
273
+ ### Does it show a native Android call screen?
274
+ It shows **system CallStyle notifications** plus a **Pixel-style full-screen Activity** you can brand. Third-party apps cannot open the stock Dialer UI.
275
+
276
+ ### New Architecture required?
277
+ **Yes** — this is a TurboModule library.
278
+
279
+ ### minSdk?
280
+ **26** (Android 8.0).
281
+
282
+ ---
283
+
284
+ ## Roadmap
285
+
286
+ - [x] Android Core-Telecom + CallStyle + full-screen UI
287
+ - [x] Ringtone / vibrate / mute / hold / DTMF events / audio routes
288
+ - [x] Avatar URL + FCM push bridge + media session events
289
+ - [ ] iOS CallKit
290
+ - [ ] Deeper Telecom audio endpoint APIs
291
+ - [ ] Published examples: Telnyx + LiveKit
292
+
293
+ ---
294
+
295
+ ## Contributing
296
+
297
+ See [CONTRIBUTING.md](./CONTRIBUTING.md). Issues and PRs welcome — especially OEM test reports (Vivo, Xiaomi, Oppo, Samsung).
298
+
299
+ ## License
300
+
301
+ MIT © [Abdul Moiz](https://github.com/itxmoizdev)
302
+
303
+ ---
304
+
305
+ ### Discoverability
306
+
307
+ **npm package name:** `react-native-telecom`
308
+ **GitHub:** https://github.com/itxmoizdev/react-native-telecom
309
+
310
+ If you found this while searching for **react-native-callkeep**, **CallKeep New Architecture**, **React Native VoIP incoming call notification**, or **Android Core-Telecom React Native**, star the repo and open an issue with your stack (Telnyx, WebRTC, Expo prebuild, etc.) so we can improve docs and examples.
@@ -0,0 +1,20 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "Telecom"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => "https://github.com/itxmoizdev/react-native-telecom.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
+ s.private_header_files = "ios/**/*.h"
18
+
19
+ install_modules_dependencies(s)
20
+ end
@@ -0,0 +1,58 @@
1
+ buildscript {
2
+ ext.Telecom = [
3
+ kotlinVersion: "2.4.20",
4
+ minSdkVersion: 26,
5
+ compileSdkVersion: 36
6
+ ]
7
+
8
+ ext.getExtOrDefault = { prop ->
9
+ if (rootProject.ext.has(prop)) {
10
+ return rootProject.ext.get(prop)
11
+ }
12
+
13
+ return Telecom[prop]
14
+ }
15
+
16
+ repositories {
17
+ google()
18
+ mavenCentral()
19
+ }
20
+
21
+ dependencies {
22
+ classpath "com.android.tools.build:gradle:8.13.2"
23
+ // noinspection DifferentKotlinGradleVersion
24
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
25
+ }
26
+ }
27
+
28
+
29
+ apply plugin: "com.android.library"
30
+
31
+ if (project.extensions.findByName("kotlin") == null) {
32
+ apply plugin: "kotlin-android"
33
+ }
34
+
35
+
36
+ apply plugin: "com.facebook.react"
37
+
38
+ android {
39
+ namespace "com.telecom"
40
+
41
+ compileSdkVersion getExtOrDefault("compileSdkVersion")
42
+
43
+ defaultConfig {
44
+ minSdkVersion getExtOrDefault("minSdkVersion")
45
+ }
46
+
47
+ compileOptions {
48
+ sourceCompatibility JavaVersion.VERSION_17
49
+ targetCompatibility JavaVersion.VERSION_17
50
+ }
51
+ }
52
+
53
+ dependencies {
54
+ implementation "com.facebook.react:react-android"
55
+ implementation "androidx.core:core-telecom:1.0.1"
56
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.11.0"
57
+ implementation "androidx.core:core-ktx:1.19.1"
58
+ }
@@ -0,0 +1,43 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
3
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
4
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
5
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
6
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
7
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
8
+ <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
9
+ <uses-permission android:name="android.permission.VIBRATE" />
10
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
11
+ <uses-permission android:name="android.permission.INTERNET" />
12
+ <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
13
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
14
+
15
+ <application>
16
+ <service
17
+ android:name="com.telecom.TelecomCallService"
18
+ android:exported="false"
19
+ android:foregroundServiceType="phoneCall" />
20
+
21
+ <activity
22
+ android:name="com.telecom.TelecomIncomingCallActivity"
23
+ android:excludeFromRecents="true"
24
+ android:exported="false"
25
+ android:launchMode="singleTop"
26
+ android:showOnLockScreen="true"
27
+ android:showWhenLocked="true"
28
+ android:turnScreenOn="true"
29
+ android:taskAffinity=""
30
+ android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar" />
31
+
32
+ <activity
33
+ android:name="com.telecom.TelecomInCallActivity"
34
+ android:excludeFromRecents="true"
35
+ android:exported="false"
36
+ android:launchMode="singleTop"
37
+ android:showOnLockScreen="true"
38
+ android:showWhenLocked="true"
39
+ android:turnScreenOn="true"
40
+ android:taskAffinity=""
41
+ android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar" />
42
+ </application>
43
+ </manifest>
@@ -0,0 +1,37 @@
1
+ package com.telecom
2
+
3
+ import androidx.core.telecom.CallAttributesCompat
4
+ import androidx.core.telecom.CallControlResult
5
+ import androidx.core.telecom.CallControlScope
6
+
7
+ internal class CallSession(
8
+ val uuid: String,
9
+ private val controlScope: CallControlScope,
10
+ private val hasVideo: Boolean,
11
+ val displayName: String,
12
+ val handle: String,
13
+ val avatarUrl: String = "",
14
+ ) {
15
+ suspend fun answer(): CallControlResult {
16
+ val callType =
17
+ if (hasVideo) {
18
+ CallAttributesCompat.CALL_TYPE_VIDEO_CALL
19
+ } else {
20
+ CallAttributesCompat.CALL_TYPE_AUDIO_CALL
21
+ }
22
+ controlScope.answer(callType)
23
+ return controlScope.setActive()
24
+ }
25
+
26
+ suspend fun setActive(): CallControlResult {
27
+ return controlScope.setActive()
28
+ }
29
+
30
+ suspend fun setInactive(): CallControlResult {
31
+ return controlScope.setInactive()
32
+ }
33
+
34
+ suspend fun disconnect(cause: android.telecom.DisconnectCause): CallControlResult {
35
+ return controlScope.disconnect(cause)
36
+ }
37
+ }