voip-callkit 0.0.1 → 0.0.4

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 (23) hide show
  1. package/android/build.gradle +14 -42
  2. package/package.json +1 -1
  3. package/android/src/main/.DS_Store +0 -0
  4. package/android/src/main/AndroidManifest.xml +0 -55
  5. package/android/src/main/java/.DS_Store +0 -0
  6. package/android/src/main/java/com/.DS_Store +0 -0
  7. package/android/src/main/java/com/test/.DS_Store +0 -0
  8. package/android/src/main/java/com/test/callkit/.DS_Store +0 -0
  9. package/android/src/main/java/com/test/callkit/CallKitVoip.java +0 -12
  10. package/android/src/main/java/com/test/callkit/CallKitVoipPlugin.java +0 -81
  11. package/android/src/main/java/com/test/callkit/MyConnectionService.java +0 -200
  12. package/android/src/main/java/com/test/callkit/MyFirebaseMessagingService.java +0 -90
  13. package/android/src/main/java/com/test/callkit/androidcall/ApiCalls.java +0 -48
  14. package/android/src/main/java/com/test/callkit/androidcall/CallActivity.java +0 -1223
  15. package/android/src/main/java/com/test/callkit/androidcall/RetreivedTokenCallback.java +0 -5
  16. package/android/src/main/java/com/test/callkit/androidcall/SettingsActivity.java +0 -174
  17. package/android/src/main/java/com/test/callkit/androidcall/VoipBackgroundService.java +0 -103
  18. package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundService.java +0 -210
  19. package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundServiceActionReceiver.java +0 -77
  20. package/android/src/main/java/com/test/callkit/androidcall/util/CameraCapturerCompat.java +0 -185
  21. package/android/src/main/java/com/test/callkit/androidcall/util/CodecUtils.kt +0 -23
  22. package/android/src/main/java/com/test/callkit/androidcall/util/Dialog.java +0 -37
  23. package/android/src/main/res/.gitkeep +0 -0
@@ -1,58 +1,30 @@
1
- ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
6
- }
1
+ // Top-level build file where you can add configuration options common to all sub-projects/modules.
7
2
 
8
3
  buildscript {
4
+
9
5
  repositories {
10
6
  google()
11
7
  jcenter()
12
8
  }
13
9
  dependencies {
14
10
  classpath 'com.android.tools.build:gradle:4.2.1'
11
+ classpath 'com.google.gms:google-services:4.3.5'
12
+ classpath 'com.google.gms:google-services:4.3.13'
13
+
14
+ // NOTE: Do not place your application dependencies here; they belong
15
+ // in the individual module build.gradle files
15
16
  }
16
17
  }
17
18
 
18
- apply plugin: 'com.android.library'
19
+ apply from: "variables.gradle"
19
20
 
20
- android {
21
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
22
- defaultConfig {
23
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
24
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
25
- versionCode 1
26
- versionName "1.0"
27
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
- }
29
- buildTypes {
30
- release {
31
- minifyEnabled false
32
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
- }
34
- }
35
- lintOptions {
36
- abortOnError false
37
- }
38
- compileOptions {
39
- sourceCompatibility JavaVersion.VERSION_1_8
40
- targetCompatibility JavaVersion.VERSION_1_8
21
+ allprojects {
22
+ repositories {
23
+ google()
24
+ jcenter()
41
25
  }
42
26
  }
43
27
 
44
- repositories {
45
- google()
46
- mavenCentral()
47
- jcenter()
48
- }
49
-
50
-
51
- dependencies {
52
- implementation fileTree(dir: 'libs', include: ['*.jar'])
53
- implementation project(':capacitor-android')
54
- implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
- testImplementation "junit:junit:$junitVersion"
56
- androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
- androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
28
+ task clean(type: Delete) {
29
+ delete rootProject.buildDir
58
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voip-callkit",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "description": "capacitor plugin for callkit and voip",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
Binary file
@@ -1,55 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.test.callkit">
3
-
4
- <uses-permission android:name="android.permission.CALL_PHONE"/>
5
- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
6
- <uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>
7
- <uses-permission android:name="android.permission.INTERNET" />
8
-
9
- <uses-permission android:name="android.permission.VIBRATE" />
10
-
11
- <application
12
- android:usesCleartextTraffic="true"
13
- >
14
- <activity
15
- android:name=".androidcall.CallActivity"
16
- android:label="@string/app_name"
17
- android:launchMode="singleTop"
18
- android:configChanges="locale"
19
-
20
- android:turnScreenOn="true"
21
- android:autoRemoveFromRecents="true"
22
- android:showWhenLocked="true"
23
- android:windowSoftInputMode="adjustResize|stateHidden"
24
- android:screenOrientation="portrait"
25
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
26
- <service android:name="com.test.callkit.MyConnectionService"
27
- android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
28
- android:exported="false">
29
- <intent-filter>
30
- <action android:name="android.telecom.ConnectionService" />
31
- </intent-filter>
32
- </service>
33
- <service
34
- android:name="com.test.callkit.androidcall.VoipForegroundService"
35
- android:enabled="true"
36
- android:stopWithTask="true"
37
- android:exported="true"></service>
38
- <receiver
39
- android:name="com.test.callkit.androidcall.VoipForegroundServiceActionReceiver">
40
- </receiver>
41
- <service
42
- android:name="com.test.callkit.androidcall.VoipBackgroundService"
43
- android:enabled="true"
44
- android:exported="false"
45
- android:stopWithTask="true">
46
-
47
- </service>
48
- <service
49
- android:name="com.test.callkit.MyFirebaseMessagingService">
50
- <intent-filter>
51
- <action android:name="com.google.firebase.MESSAGING_EVENT" />
52
- </intent-filter>
53
- </service>
54
- </application>
55
- </manifest>
Binary file
Binary file
@@ -1,12 +0,0 @@
1
- package com.test.callkit;
2
-
3
- import android.util.Log;
4
-
5
- public class CallKitVoip {
6
-
7
- public String echo(String value) {
8
-
9
- Log.d("CallKitVoip","called");
10
- return value;
11
- }
12
- }
@@ -1,81 +0,0 @@
1
- package com.test.callkit;
2
-
3
- import com.getcapacitor.Bridge;
4
- import com.getcapacitor.JSObject;
5
- import com.getcapacitor.Logger;
6
- import com.getcapacitor.Plugin;
7
- import com.getcapacitor.PluginCall;
8
- import com.getcapacitor.PluginHandle;
9
- import com.getcapacitor.PluginMethod;
10
- import com.google.firebase.messaging.FirebaseMessaging;
11
-
12
-
13
- import android.content.Context;
14
- import android.util.Log;
15
- import android.widget.Toast;
16
-
17
- import androidx.annotation.NonNull;
18
- import androidx.annotation.RequiresApi;
19
-
20
- public class CallKitVoipPlugin extends Plugin {
21
- public static Bridge staticBridge = null;
22
- public MyFirebaseMessagingService messagingService;
23
-
24
-
25
- @Override
26
- public void load(){
27
- staticBridge = this.bridge;
28
-
29
-
30
- this.getActivity().getApplicationContext();
31
-
32
- }
33
-
34
- @PluginMethod
35
- public void register(PluginCall call) {
36
- final String topicName = call.getString("userToken");
37
- Log.d("CallKitVoip","register");
38
-
39
- if(topicName == null){
40
- call.reject("Topic name hasn't been specified correctly");
41
- return;
42
- }
43
- FirebaseMessaging
44
- .getInstance()
45
- .subscribeToTopic(topicName)
46
- .addOnSuccessListener(unused -> {
47
- JSObject ret = new JSObject();
48
- Logger.debug("CallKit: Subscribed");
49
- ret.put("message", "Subscribed to topic " + topicName);
50
- call.resolve(ret);
51
-
52
- })
53
- .addOnFailureListener(e -> {
54
- Logger.debug("CallKit: Cannot subscribe");
55
- call.reject("Cant subscribe to topic" + topicName);
56
- });
57
- call.resolve();
58
- }
59
- public void notifyEvent(String eventName, String username, String connectionId){
60
- Log.d("notifyEvent",eventName + " " + username + " " + connectionId);
61
-
62
- // JSObject data = new JSObject();
63
- // data.put("username", username);
64
- // data.put("connectionId", connectionId);
65
- // notifyListeners("callAnswered", data);
66
- }
67
-
68
-
69
-
70
- public static CallKitVoipPlugin getInstance() {
71
- if (staticBridge == null || staticBridge.getWebView() == null)
72
- return null;
73
-
74
- PluginHandle handler = staticBridge.getPlugin("CallKitVoip");
75
-
76
- return handler == null
77
- ? null
78
- : (CallKitVoipPlugin) handler.getInstance();
79
- }
80
-
81
- }
@@ -1,200 +0,0 @@
1
- package com.test.callkit;
2
-
3
- import android.content.Intent;
4
- import android.graphics.drawable.Icon;
5
- import android.os.Build;
6
- import android.os.Bundle;
7
- import android.telecom.Connection;
8
- import android.telecom.ConnectionRequest;
9
- import android.telecom.ConnectionService;
10
- import android.telecom.DisconnectCause;
11
- import android.telecom.PhoneAccountHandle;
12
- import android.telecom.StatusHints;
13
- import android.telecom.TelecomManager;
14
- import android.os.Handler;
15
- import android.net.Uri;
16
- import java.util.ArrayList;
17
- import android.util.Log;
18
-
19
- import androidx.annotation.RequiresApi;
20
-
21
- import com.getcapacitor.Logger;
22
-
23
- @RequiresApi(api = Build.VERSION_CODES.M)
24
- public class MyConnectionService extends ConnectionService {
25
-
26
- private static String TAG = "MyConnectionService";
27
- private static Connection conn;
28
-
29
- public static Connection getConnection() {
30
- return conn;
31
- }
32
-
33
- public static void deinitConnection() {
34
- conn = null;
35
- }
36
-
37
- @RequiresApi(api = Build.VERSION_CODES.M)
38
- @Override
39
- public Connection onCreateIncomingConnection(final PhoneAccountHandle connectionManagerPhoneAccount, final ConnectionRequest request) {
40
- final Connection connection = new Connection() {
41
- @RequiresApi(api = Build.VERSION_CODES.O)
42
- @Override
43
- public void onAnswer() {
44
- this.setActive();
45
- CallKitVoipPlugin plugin = CallKitVoipPlugin.getInstance();
46
-
47
-
48
-
49
- if(plugin != null)
50
- plugin.notifyEvent("callAnswered",
51
- request.getExtras().getString("username"),
52
- request.getExtras().getString("connectionId")
53
- );
54
-
55
-
56
- Intent launchIntent = getPackageManager().getLaunchIntentForPackage("app.appname");
57
- if (launchIntent != null) {
58
- startActivity(launchIntent);//null pointer check in case package name was not found
59
- }
60
-
61
- this.setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
62
-
63
- }
64
-
65
- @Override
66
- public void onReject() {
67
- DisconnectCause cause = new DisconnectCause(DisconnectCause.REJECTED);
68
- this.setDisconnected(cause);
69
- this.destroy();
70
- conn = null;
71
- // ArrayList<CallbackContext> callbackContexts = AndroidCall.getCallbackContexts().get("reject");
72
- // for (final CallbackContext callbackContext : callbackContexts) {
73
- // AndroidCall.getCordova().getThreadPool().execute(new Runnable() {
74
- // public void run() {
75
- // PluginResult result = new PluginResult(PluginResult.Status.OK, "reject event called successfully");
76
- // result.setKeepCallback(true);
77
- // callbackContext.sendPluginResult(result);
78
- // }
79
- // });
80
- // }
81
- }
82
-
83
- @Override
84
- public void onAbort() {
85
- super.onAbort();
86
- }
87
-
88
- @Override
89
- public void onDisconnect() {
90
- DisconnectCause cause = new DisconnectCause(DisconnectCause.LOCAL);
91
- this.setDisconnected(cause);
92
- this.destroy();
93
- conn = null;
94
- // ArrayList<CallbackContext> callbackContexts = AndroidCall.getCallbackContexts().get("hangup");
95
- // for (final CallbackContext callbackContext : callbackContexts) {
96
- // AndroidCall.getCordova().getThreadPool().execute(new Runnable() {
97
- // public void run() {
98
- // PluginResult result = new PluginResult(PluginResult.Status.OK, "hangup event called successfully");
99
- // result.setKeepCallback(true);
100
- // callbackContext.sendPluginResult(result);
101
- // }
102
- // });
103
- // }
104
- }
105
- };
106
- connection.setAddress(Uri.parse(request.getExtras().getString("from")), TelecomManager.PRESENTATION_ALLOWED);
107
- // Icon icon = AndroidCall.getIcon();
108
- // if(icon != null) {
109
- // StatusHints statusHints = new StatusHints((CharSequence)"", icon, new Bundle());
110
- // connection.setStatusHints(statusHints);
111
- // }
112
- conn = connection;
113
- // ArrayList<CallbackContext> callbackContexts = AndroidCall.getCallbackContexts().get("receiveCall");
114
- // for (final CallbackContext callbackContext : callbackContexts) {
115
- // AndroidCall.getCordova().getThreadPool().execute(new Runnable() {
116
- // public void run() {
117
- // PluginResult result = new PluginResult(PluginResult.Status.OK, "receiveCall event called successfully");
118
- // result.setKeepCallback(true);
119
- // callbackContext.sendPluginResult(result);
120
- // }
121
- // });
122
- // }
123
- return connection;
124
- }
125
-
126
- @RequiresApi(api = Build.VERSION_CODES.M)
127
- @Override
128
- public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
129
- final Connection connection = new Connection() {
130
- @Override
131
- public void onAnswer() {
132
- super.onAnswer();
133
- }
134
-
135
- @Override
136
- public void onReject() {
137
- super.onReject();
138
- }
139
-
140
- @Override
141
- public void onAbort() {
142
- super.onAbort();
143
- }
144
-
145
- @Override
146
- public void onDisconnect() {
147
- DisconnectCause cause = new DisconnectCause(DisconnectCause.LOCAL);
148
- this.setDisconnected(cause);
149
- this.destroy();
150
- conn = null;
151
- // ArrayList<CallbackContext> callbackContexts = AndroidCall.getCallbackContexts().get("hangup");
152
- // for (final CallbackContext callbackContext : callbackContexts) {
153
- // AndroidCall.getCordova().getThreadPool().execute(new Runnable() {
154
- // public void run() {
155
- // PluginResult result = new PluginResult(PluginResult.Status.OK, "hangup event called successfully");
156
- // result.setKeepCallback(true);
157
- // callbackContext.sendPluginResult(result);
158
- // }
159
- // });
160
- // }
161
- }
162
-
163
- @Override
164
- public void onStateChanged(int state) {
165
- if(state == Connection.STATE_DIALING) {
166
- final Handler handler = new Handler();
167
- handler.postDelayed(new Runnable() {
168
- @Override
169
- public void run() {
170
- // Intent intent = new Intent(AndroidCall.getCapacitor().getActivity().getApplicationContext(), AndroidCall.getCordova().getActivity().getClass());
171
- // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
172
- // AndroidCall.getCapacitor().getActivity().getApplicationContext().startActivity(intent);
173
- }
174
- }, 500);
175
- }
176
- }
177
- };
178
- connection.setAddress(Uri.parse(request.getExtras().getString("to")), TelecomManager.PRESENTATION_ALLOWED);
179
- // Icon icon = AndroidCall.getIcon();
180
- // if(icon != null) {
181
- // StatusHints statusHints = new StatusHints((CharSequence)"", icon, new Bundle());
182
- // connection.setStatusHints(statusHints);
183
- // }
184
- connection.setDialing();
185
- conn = connection;
186
- // ArrayList<CallbackContext> callbackContexts = AndroidCall.getCallbackContexts().get("sendCall");
187
- // if(callbackContexts != null) {
188
- // for (final CallbackContext callbackContext : callbackContexts) {
189
- // AndroidCall.getCordova().getThreadPool().execute(new Runnable() {
190
- // public void run() {
191
- // PluginResult result = new PluginResult(PluginResult.Status.OK, "sendCall event called successfully");
192
- // result.setKeepCallback(true);
193
- // callbackContext.sendPluginResult(result);
194
- // }
195
- // });
196
- // }
197
- // }
198
- return connection;
199
- }
200
- }
@@ -1,90 +0,0 @@
1
- package com.test.callkit;
2
-
3
-
4
- import android.annotation.SuppressLint;
5
- import android.app.ActivityManager;
6
- import android.content.Intent;
7
- import android.os.Build;
8
- import android.util.Log;
9
-
10
- import androidx.annotation.RequiresApi;
11
-
12
- import com.test.callkit.androidcall.VoipBackgroundService;
13
- import com.google.firebase.messaging.FirebaseMessagingService;
14
- import com.google.firebase.messaging.RemoteMessage;
15
-
16
-
17
- /**
18
- * NOTE: There can only be one service in each app that receives FCM messages. If multiple
19
- * are declared in the Manifest then the first one will be chosen.
20
- * <p>
21
- * In order to make this Java sample functional, you must remove the following from the Kotlin messaging
22
- * service in the AndroidManifest.xml:
23
- * <p>
24
- * <intent-filter>
25
- * <action android:name="com.google.firebase.MESSAGING_EVENT" />
26
- * </intent-filter>
27
- */
28
- @SuppressLint("MissingFirebaseInstanceTokenRefresh")
29
- public class MyFirebaseMessagingService extends FirebaseMessagingService {
30
-
31
- private static final String TAG = "MyFirebaseMsgService";
32
-
33
- public MyFirebaseMessagingService() {
34
- super();
35
- Log.d(TAG, "class instantiated");
36
- }
37
-
38
- /**
39
- * Called when message is received.
40
- *
41
- * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
42
- */
43
-
44
- @Override
45
- public void onMessageReceived(RemoteMessage remoteMessage) {
46
- Log.d(TAG, "received " + remoteMessage.getData());
47
-
48
- if (remoteMessage.getData().containsKey("type") && remoteMessage.getData().get("type").equals("call")) {
49
- show_call_notification(remoteMessage.getData().get("connectionId"), remoteMessage.getData().get("username"));
50
- }
51
-
52
- if (remoteMessage.getData().containsKey("type") && remoteMessage.getData().get("type").equals("stopCall")) {
53
-
54
- }
55
-
56
- private boolean isServiceRunning(String service_name) {
57
- ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(getApplicationContext().ACTIVITY_SERVICE);
58
- for (ActivityManager.RunningServiceInfo service_running : manager.getRunningServices(Integer.MAX_VALUE)) {
59
- if (service_name.equals(service_running.service.getClassName())) {
60
- return true;
61
- }
62
- }
63
- return false;
64
- }
65
-
66
- public void show_call_notification(String connectionId, String username) {
67
- Intent voip_service = new Intent(getApplicationContext(), VoipBackgroundService.class);
68
- voip_service.putExtra("connectionId", connectionId);
69
- voip_service.putExtra("username", username);
70
- Log.d("show_call_notification", "called");
71
-
72
- if (!isServiceRunning("com.test.callkit.androidcall.VoipBackgroundService")) {
73
- try {
74
- getApplicationContext().startService(voip_service);
75
- } catch (Exception e) {
76
- }
77
- } else {
78
- try {
79
- getApplicationContext().stopService(voip_service);
80
- } catch (Exception e) {
81
- }
82
- try {
83
- getApplicationContext().startService(voip_service);
84
- } catch (Exception e) {
85
- Log.d("sip_call_init", e.toString());
86
- }
87
- }
88
-
89
- }
90
- }
@@ -1,48 +0,0 @@
1
- package com.bfine.capactior.callkitvoip.androidcall;
2
-
3
- import android.util.Log;
4
-
5
- import com.androidnetworking.AndroidNetworking;
6
- import com.androidnetworking.error.ANError;
7
- import com.androidnetworking.interfaces.JSONObjectRequestListener;
8
-
9
- import org.json.JSONException;
10
- import org.json.JSONObject;
11
-
12
-
13
- public class ApiCalls {
14
-
15
- public void gettwiliotoken(final String connectionId,final RetreivedTokenCallback callback)
16
- {
17
- Log.d("gettwiliotoken","called " + connectionId);
18
-
19
- AndroidNetworking.get("http://us-central1-bettercall-app.cloudfunctions.net/getTokenTwilioVideo?name=operator&token="+connectionId)
20
- .build()
21
- .getAsJSONObject(new JSONObjectRequestListener()
22
- {
23
- @Override
24
- public void onResponse(JSONObject response)
25
- {
26
- try {
27
- Log.d("gettwiliotoken","called " + response);
28
-
29
- String token = response.getString("token");
30
- Log.d("token",token);
31
- callback.onTokenRetreived(token);
32
- } catch (JSONException e) {
33
- Log.d("gettwiliotoken",e.toString());
34
-
35
- e.printStackTrace();
36
- }
37
- }
38
-
39
- @Override
40
- public void onError(ANError error)
41
- {
42
- Log.d("gettwiliotoken",error.toString());
43
-
44
- }
45
- });
46
-
47
- }
48
- }