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.
- package/android/build.gradle +14 -42
- package/package.json +1 -1
- package/android/src/main/.DS_Store +0 -0
- package/android/src/main/AndroidManifest.xml +0 -55
- package/android/src/main/java/.DS_Store +0 -0
- package/android/src/main/java/com/.DS_Store +0 -0
- package/android/src/main/java/com/test/.DS_Store +0 -0
- package/android/src/main/java/com/test/callkit/.DS_Store +0 -0
- package/android/src/main/java/com/test/callkit/CallKitVoip.java +0 -12
- package/android/src/main/java/com/test/callkit/CallKitVoipPlugin.java +0 -81
- package/android/src/main/java/com/test/callkit/MyConnectionService.java +0 -200
- package/android/src/main/java/com/test/callkit/MyFirebaseMessagingService.java +0 -90
- package/android/src/main/java/com/test/callkit/androidcall/ApiCalls.java +0 -48
- package/android/src/main/java/com/test/callkit/androidcall/CallActivity.java +0 -1223
- package/android/src/main/java/com/test/callkit/androidcall/RetreivedTokenCallback.java +0 -5
- package/android/src/main/java/com/test/callkit/androidcall/SettingsActivity.java +0 -174
- package/android/src/main/java/com/test/callkit/androidcall/VoipBackgroundService.java +0 -103
- package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundService.java +0 -210
- package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundServiceActionReceiver.java +0 -77
- package/android/src/main/java/com/test/callkit/androidcall/util/CameraCapturerCompat.java +0 -185
- package/android/src/main/java/com/test/callkit/androidcall/util/CodecUtils.kt +0 -23
- package/android/src/main/java/com/test/callkit/androidcall/util/Dialog.java +0 -37
- package/android/src/main/res/.gitkeep +0 -0
@@ -1,174 +0,0 @@
|
|
1
|
-
package com.bfine.capactior.callkitvoip.androidcall;
|
2
|
-
import android.content.Intent;
|
3
|
-
import android.content.SharedPreferences;
|
4
|
-
import android.os.Bundle;
|
5
|
-
import android.preference.PreferenceManager;
|
6
|
-
|
7
|
-
import android.view.MenuItem;
|
8
|
-
|
9
|
-
import androidx.appcompat.app.ActionBar;
|
10
|
-
import androidx.appcompat.app.AppCompatActivity;
|
11
|
-
import androidx.preference.EditTextPreference;
|
12
|
-
import androidx.preference.ListPreference;
|
13
|
-
import androidx.preference.PreferenceFragmentCompat;
|
14
|
-
|
15
|
-
import com.bfine.capactior.callkitvoip.R;
|
16
|
-
import com.twilio.video.AudioCodec;
|
17
|
-
import com.twilio.video.G722Codec;
|
18
|
-
import com.twilio.video.H264Codec;
|
19
|
-
import com.twilio.video.IsacCodec;
|
20
|
-
import com.twilio.video.OpusCodec;
|
21
|
-
import com.twilio.video.PcmaCodec;
|
22
|
-
import com.twilio.video.PcmuCodec;
|
23
|
-
import com.twilio.video.VideoCodec;
|
24
|
-
import com.twilio.video.Vp8Codec;
|
25
|
-
import com.twilio.video.Vp9Codec;
|
26
|
-
|
27
|
-
import java.util.ArrayList;
|
28
|
-
import java.util.Collections;
|
29
|
-
import java.util.List;
|
30
|
-
|
31
|
-
public class SettingsActivity extends AppCompatActivity {
|
32
|
-
public static final String PREF_AUDIO_CODEC = "audio_codec";
|
33
|
-
public static final String PREF_AUDIO_CODEC_DEFAULT = OpusCodec.NAME;
|
34
|
-
public static final String PREF_VIDEO_CODEC = "video_codec";
|
35
|
-
public static final String PREF_VIDEO_CODEC_DEFAULT = Vp8Codec.NAME;
|
36
|
-
public static final String PREF_SENDER_MAX_AUDIO_BITRATE = "sender_max_audio_bitrate";
|
37
|
-
public static final String PREF_SENDER_MAX_AUDIO_BITRATE_DEFAULT = "0";
|
38
|
-
public static final String PREF_SENDER_MAX_VIDEO_BITRATE = "sender_max_video_bitrate";
|
39
|
-
public static final String PREF_SENDER_MAX_VIDEO_BITRATE_DEFAULT = "0";
|
40
|
-
public static final String PREF_VP8_SIMULCAST = "vp8_simulcast";
|
41
|
-
public static final String PREF_ENABLE_AUTOMATIC_SUBSCRIPTION = "enable_automatic_subscription";
|
42
|
-
public static final boolean PREF_ENABLE_AUTOMATIC_SUBSCRIPTION_DEFAULT = true;
|
43
|
-
public static final boolean PREF_VP8_SIMULCAST_DEFAULT = false;
|
44
|
-
|
45
|
-
private static final String[] VIDEO_CODEC_NAMES =
|
46
|
-
new String[] {Vp8Codec.NAME, H264Codec.NAME, Vp9Codec.NAME};
|
47
|
-
|
48
|
-
private static final String[] AUDIO_CODEC_NAMES =
|
49
|
-
new String[] {
|
50
|
-
IsacCodec.NAME, OpusCodec.NAME, PcmaCodec.NAME, PcmuCodec.NAME, G722Codec.NAME
|
51
|
-
};
|
52
|
-
|
53
|
-
@Override
|
54
|
-
protected void onCreate(Bundle savedInstanceState) {
|
55
|
-
super.onCreate(savedInstanceState);
|
56
|
-
setupActionBar();
|
57
|
-
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
58
|
-
SettingsFragment settingsFragment = SettingsFragment.newInstance(sharedPreferences);
|
59
|
-
getSupportFragmentManager()
|
60
|
-
.beginTransaction()
|
61
|
-
.replace(android.R.id.content, settingsFragment)
|
62
|
-
.commit();
|
63
|
-
}
|
64
|
-
|
65
|
-
@Override
|
66
|
-
public boolean onOptionsItemSelected(MenuItem item) {
|
67
|
-
switch (item.getItemId()) {
|
68
|
-
case android.R.id.home:
|
69
|
-
finish();
|
70
|
-
return true;
|
71
|
-
default:
|
72
|
-
return super.onOptionsItemSelected(item);
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
private void setupActionBar() {
|
77
|
-
ActionBar actionBar = getSupportActionBar();
|
78
|
-
if (actionBar != null) {
|
79
|
-
// Show the Up button in the action bar.
|
80
|
-
actionBar.setDisplayHomeAsUpEnabled(true);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
public static class SettingsFragment extends PreferenceFragmentCompat {
|
85
|
-
private SharedPreferences sharedPreferences;
|
86
|
-
|
87
|
-
public static SettingsFragment newInstance(SharedPreferences sharedPreferences) {
|
88
|
-
SettingsFragment settingsFragment = new SettingsFragment();
|
89
|
-
settingsFragment.sharedPreferences = sharedPreferences;
|
90
|
-
|
91
|
-
return settingsFragment;
|
92
|
-
}
|
93
|
-
|
94
|
-
@Override
|
95
|
-
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
96
|
-
addPreferencesFromResource(R.xml.settings);
|
97
|
-
setHasOptionsMenu(true);
|
98
|
-
setupCodecListPreference(
|
99
|
-
AudioCodec.class,
|
100
|
-
PREF_AUDIO_CODEC,
|
101
|
-
PREF_AUDIO_CODEC_DEFAULT,
|
102
|
-
(ListPreference) findPreference(PREF_AUDIO_CODEC));
|
103
|
-
setupCodecListPreference(
|
104
|
-
VideoCodec.class,
|
105
|
-
PREF_VIDEO_CODEC,
|
106
|
-
PREF_VIDEO_CODEC_DEFAULT,
|
107
|
-
(ListPreference) findPreference(PREF_VIDEO_CODEC));
|
108
|
-
setupSenderBandwidthPreferences(
|
109
|
-
PREF_SENDER_MAX_AUDIO_BITRATE,
|
110
|
-
PREF_SENDER_MAX_AUDIO_BITRATE_DEFAULT,
|
111
|
-
(EditTextPreference) findPreference(PREF_SENDER_MAX_AUDIO_BITRATE));
|
112
|
-
setupSenderBandwidthPreferences(
|
113
|
-
PREF_SENDER_MAX_VIDEO_BITRATE,
|
114
|
-
PREF_SENDER_MAX_VIDEO_BITRATE_DEFAULT,
|
115
|
-
(EditTextPreference) findPreference(PREF_SENDER_MAX_VIDEO_BITRATE));
|
116
|
-
}
|
117
|
-
|
118
|
-
@Override
|
119
|
-
public boolean onOptionsItemSelected(MenuItem item) {
|
120
|
-
int id = item.getItemId();
|
121
|
-
if (id == android.R.id.home) {
|
122
|
-
startActivity(new Intent(getActivity(), SettingsActivity.class));
|
123
|
-
return true;
|
124
|
-
}
|
125
|
-
return super.onOptionsItemSelected(item);
|
126
|
-
}
|
127
|
-
|
128
|
-
private void setupCodecListPreference(
|
129
|
-
Class codecClass, String key, String defaultValue, ListPreference preference) {
|
130
|
-
List<String> codecEntries = new ArrayList<>();
|
131
|
-
if (codecClass == AudioCodec.class) {
|
132
|
-
Collections.addAll(codecEntries, AUDIO_CODEC_NAMES);
|
133
|
-
} else {
|
134
|
-
Collections.addAll(codecEntries, VIDEO_CODEC_NAMES);
|
135
|
-
}
|
136
|
-
|
137
|
-
// Remove H264 if not supported
|
138
|
-
// CodecUtils utils = new CodecUtils();
|
139
|
-
// if (!utils.isH264Supported()) {
|
140
|
-
// codecEntries.remove(H264Codec.NAME);
|
141
|
-
// }
|
142
|
-
String[] codecStrings = codecEntries.toArray(new String[codecEntries.size()]);
|
143
|
-
|
144
|
-
// Saved value
|
145
|
-
final String value = sharedPreferences.getString(key, defaultValue);
|
146
|
-
|
147
|
-
// Bind values
|
148
|
-
preference.setEntries(codecStrings);
|
149
|
-
preference.setEntryValues(codecStrings);
|
150
|
-
preference.setValue(value);
|
151
|
-
preference.setSummary(value);
|
152
|
-
preference.setOnPreferenceChangeListener(
|
153
|
-
(preference1, newValue) -> {
|
154
|
-
preference1.setSummary(newValue.toString());
|
155
|
-
return true;
|
156
|
-
});
|
157
|
-
}
|
158
|
-
|
159
|
-
private void setupSenderBandwidthPreferences(
|
160
|
-
String key, String defaultValue, EditTextPreference editTextPreference) {
|
161
|
-
String value = sharedPreferences.getString(key, defaultValue);
|
162
|
-
|
163
|
-
// Set layout with input type number for edit text
|
164
|
-
editTextPreference.setDialogLayoutResource(R.layout.preference_dialog_number_edittext);
|
165
|
-
editTextPreference.setSummary(value);
|
166
|
-
editTextPreference.setOnPreferenceChangeListener(
|
167
|
-
(preference, newValue) -> {
|
168
|
-
preference.setSummary(newValue.toString());
|
169
|
-
return true;
|
170
|
-
});
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
}
|
@@ -1,103 +0,0 @@
|
|
1
|
-
package com.bfine.capactior.callkitvoip.androidcall;
|
2
|
-
|
3
|
-
import android.app.ActivityManager;
|
4
|
-
import android.app.KeyguardManager;
|
5
|
-
import android.app.Service;
|
6
|
-
import android.content.Context;
|
7
|
-
import android.content.Intent;
|
8
|
-
import android.os.Build;
|
9
|
-
import android.os.IBinder;
|
10
|
-
import android.util.Log;
|
11
|
-
|
12
|
-
|
13
|
-
public class VoipBackgroundService extends Service
|
14
|
-
{
|
15
|
-
public static boolean isServiceRunningInForeground(Context context, Class<?> serviceClass) {
|
16
|
-
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
17
|
-
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
18
|
-
if (serviceClass.getName().equals(service.service.getClassName())) {
|
19
|
-
if (service.foreground) {
|
20
|
-
return true;
|
21
|
-
}
|
22
|
-
|
23
|
-
}
|
24
|
-
}
|
25
|
-
return false;
|
26
|
-
}
|
27
|
-
|
28
|
-
|
29
|
-
@Override
|
30
|
-
public IBinder onBind(Intent intent)
|
31
|
-
{
|
32
|
-
return null;
|
33
|
-
}
|
34
|
-
|
35
|
-
@Override
|
36
|
-
public void onTaskRemoved(Intent rootIntent)
|
37
|
-
{
|
38
|
-
super.onTaskRemoved(rootIntent);
|
39
|
-
}
|
40
|
-
|
41
|
-
@Override
|
42
|
-
public int onStartCommand(Intent intent, int flags, int startId)
|
43
|
-
{
|
44
|
-
Log.d("MySipService", "onStartCommand");
|
45
|
-
if(intent.hasExtra("connectionId") && intent.hasExtra("username"))
|
46
|
-
{
|
47
|
-
String connectionId = intent.getStringExtra("connectionId");
|
48
|
-
String username = intent.getStringExtra("username");
|
49
|
-
ApiCalls apiCalls = new ApiCalls();
|
50
|
-
apiCalls.gettwiliotoken(connectionId, new RetreivedTokenCallback() {
|
51
|
-
@Override
|
52
|
-
public void onTokenRetreived(String token) {
|
53
|
-
Log.d("onTokenRetreived",token);
|
54
|
-
if(!isServiceRunningInForeground(VoipBackgroundService.this,VoipForegroundService.class)) {
|
55
|
-
show_call_notification("incoming",token,username,connectionId);
|
56
|
-
|
57
|
-
KeyguardManager km = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE);
|
58
|
-
KeyguardManager.KeyguardLock kl = km.newKeyguardLock("name");
|
59
|
-
kl.disableKeyguard();
|
60
|
-
}
|
61
|
-
|
62
|
-
}
|
63
|
-
});
|
64
|
-
}
|
65
|
-
return START_NOT_STICKY;
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
public void show_call_notification(String action, String token,String username,String roomName)
|
71
|
-
{
|
72
|
-
Log.d("show_call_notification",action);
|
73
|
-
Intent serviceIntent = new Intent(this, VoipForegroundService.class);
|
74
|
-
serviceIntent.setAction(action);
|
75
|
-
serviceIntent.putExtra("token",token);
|
76
|
-
serviceIntent.putExtra("username",username);
|
77
|
-
serviceIntent.putExtra("roomName",roomName);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
83
|
-
|
84
|
-
VoipBackgroundService.this.startForegroundService(serviceIntent);
|
85
|
-
|
86
|
-
} else {
|
87
|
-
VoipBackgroundService.this.startService(serviceIntent);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
@Override
|
94
|
-
public void onCreate()
|
95
|
-
{
|
96
|
-
super.onCreate();
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
}
|
@@ -1,210 +0,0 @@
|
|
1
|
-
package com.bfine.capactior.callkitvoip.androidcall;
|
2
|
-
|
3
|
-
import android.app.NotificationChannel;
|
4
|
-
import android.app.NotificationManager;
|
5
|
-
import android.app.PendingIntent;
|
6
|
-
import android.app.Service;
|
7
|
-
import android.content.Context;
|
8
|
-
import android.content.Intent;
|
9
|
-
import android.media.AudioManager;
|
10
|
-
import android.media.MediaPlayer;
|
11
|
-
import android.media.RingtoneManager;
|
12
|
-
import android.net.Uri;
|
13
|
-
import android.os.Build;
|
14
|
-
import android.os.IBinder;
|
15
|
-
import android.os.Vibrator;
|
16
|
-
import android.util.Log;
|
17
|
-
|
18
|
-
import androidx.annotation.Nullable;
|
19
|
-
import androidx.core.app.NotificationCompat;
|
20
|
-
|
21
|
-
import com.bfine.capactior.callkitvoip.R;
|
22
|
-
|
23
|
-
import java.util.Objects;
|
24
|
-
|
25
|
-
public class VoipForegroundService extends Service {
|
26
|
-
private String INCOMING_CHANNEL_ID = "IncomingCallChannel";
|
27
|
-
private String INCOMING_CHANNEL_NAME = "Incoming Call Channel";
|
28
|
-
private String ONGOING_CHANNEL_ID = "OngoingCallChannel";
|
29
|
-
private String ONGOING_CHANNEL_NAME = "Ongoing Call Channel";
|
30
|
-
private NotificationManager mNotificationManager;
|
31
|
-
NotificationCompat.Builder notificationBuilder;
|
32
|
-
public static MediaPlayer ringtone;
|
33
|
-
public static Vibrator vibrator;
|
34
|
-
String username="",token="",roomName="";
|
35
|
-
|
36
|
-
@Nullable
|
37
|
-
@Override
|
38
|
-
public IBinder onBind(Intent intent) {
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
|
42
|
-
@Override
|
43
|
-
public void onDestroy() {
|
44
|
-
super.onDestroy();
|
45
|
-
stop_ringtone();
|
46
|
-
}
|
47
|
-
|
48
|
-
@Override
|
49
|
-
public void onCreate() {
|
50
|
-
super.onCreate();
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
@Override
|
55
|
-
public int onStartCommand(Intent intent, int flags, int startId) {
|
56
|
-
String action = intent.getAction();
|
57
|
-
Log.d("VoipForegroundService","onStartCommand "+action);
|
58
|
-
switch (action)
|
59
|
-
{
|
60
|
-
case "incoming":
|
61
|
-
build_incoming_call_notification(intent);
|
62
|
-
break;
|
63
|
-
case "answered":
|
64
|
-
build_answered_call_notification();
|
65
|
-
break;
|
66
|
-
|
67
|
-
}
|
68
|
-
return START_NOT_STICKY;
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
public void build_incoming_call_notification(Intent intent)
|
74
|
-
{
|
75
|
-
|
76
|
-
ringtone = new MediaPlayer();
|
77
|
-
username = intent.getStringExtra("username");
|
78
|
-
token = intent.getStringExtra("token");
|
79
|
-
roomName = intent.getStringExtra("roomName");
|
80
|
-
Log.d("VoipForegroundService","build_incoming_call_notification for "+username);
|
81
|
-
|
82
|
-
try {
|
83
|
-
Intent receiveCallAction = new Intent(getApplicationContext(), VoipForegroundServiceActionReceiver.class);
|
84
|
-
receiveCallAction.putExtra("token",token);
|
85
|
-
receiveCallAction.putExtra("roomName",roomName);
|
86
|
-
receiveCallAction.putExtra("username",username);
|
87
|
-
|
88
|
-
receiveCallAction.setAction("RECEIVE_CALL");
|
89
|
-
|
90
|
-
Intent cancelCallAction = new Intent(getApplicationContext(), VoipForegroundServiceActionReceiver.class);
|
91
|
-
cancelCallAction.putExtra("token",token);
|
92
|
-
cancelCallAction.putExtra("roomName",roomName);
|
93
|
-
cancelCallAction.putExtra("username",username);
|
94
|
-
|
95
|
-
cancelCallAction.setAction("CANCEL_CALL");
|
96
|
-
|
97
|
-
Intent fullscreenCallAction = new Intent(getApplicationContext(), VoipForegroundServiceActionReceiver.class);
|
98
|
-
fullscreenCallAction.putExtra("token",token);
|
99
|
-
fullscreenCallAction.putExtra("roomName",roomName);
|
100
|
-
fullscreenCallAction.putExtra("username",username);
|
101
|
-
|
102
|
-
fullscreenCallAction.setAction("FULLSCREEN_CALL");
|
103
|
-
|
104
|
-
PendingIntent receiveCallPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1200, receiveCallAction, PendingIntent.FLAG_UPDATE_CURRENT);
|
105
|
-
PendingIntent cancelCallPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1201, cancelCallAction, PendingIntent.FLAG_UPDATE_CURRENT);
|
106
|
-
PendingIntent fullscreenCallPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1202, fullscreenCallAction, PendingIntent.FLAG_UPDATE_CURRENT);
|
107
|
-
|
108
|
-
notificationBuilder = null;
|
109
|
-
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
110
|
-
notificationBuilder = new NotificationCompat.Builder(this, INCOMING_CHANNEL_ID)
|
111
|
-
.setContentTitle(username)
|
112
|
-
.setContentText(getString(R.string.incoming_call))
|
113
|
-
.setSmallIcon(R.drawable.ic_call_black_24dp)
|
114
|
-
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
115
|
-
.setCategory(NotificationCompat.CATEGORY_CALL)
|
116
|
-
.setSound(alarmSound)
|
117
|
-
|
118
|
-
.addAction(new NotificationCompat.Action.Builder(
|
119
|
-
0,
|
120
|
-
getString(R.string.reject),
|
121
|
-
cancelCallPendingIntent).build())
|
122
|
-
.addAction(new NotificationCompat.Action.Builder(
|
123
|
-
0,
|
124
|
-
getString(R.string.answer),
|
125
|
-
receiveCallPendingIntent).build())
|
126
|
-
.setAutoCancel(false)
|
127
|
-
|
128
|
-
.setFullScreenIntent(fullscreenCallPendingIntent, true);
|
129
|
-
long[] pattern = {0, 100, 1000, 300};
|
130
|
-
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
131
|
-
AudioManager am = (AudioManager) VoipForegroundService.this.getSystemService(Context.AUDIO_SERVICE);
|
132
|
-
if (am.getRingerMode() != AudioManager.RINGER_MODE_SILENT)
|
133
|
-
{
|
134
|
-
vibrator.vibrate(pattern, 0);
|
135
|
-
}
|
136
|
-
Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.call);
|
137
|
-
try
|
138
|
-
{
|
139
|
-
ringtone.setDataSource(getApplicationContext(), sound);
|
140
|
-
ringtone.setAudioStreamType(AudioManager.STREAM_RING);
|
141
|
-
ringtone.prepare();
|
142
|
-
ringtone.setLooping(true);
|
143
|
-
ringtone.start();
|
144
|
-
|
145
|
-
}
|
146
|
-
catch (Exception e)
|
147
|
-
{
|
148
|
-
Log.d("VoipForegroundService","1 "+e.toString());
|
149
|
-
|
150
|
-
}
|
151
|
-
|
152
|
-
createIncomingChannel();
|
153
|
-
startForeground(120, notificationBuilder.build());
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
} catch (Exception e) {
|
158
|
-
e.printStackTrace();
|
159
|
-
Log.d("VoipForegroundService","2 "+e.toString());
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
}
|
164
|
-
public void build_answered_call_notification()
|
165
|
-
{
|
166
|
-
stop_ringtone();
|
167
|
-
stopSelf();
|
168
|
-
}
|
169
|
-
|
170
|
-
|
171
|
-
public void stop_ringtone()
|
172
|
-
{
|
173
|
-
try {
|
174
|
-
ringtone.stop();
|
175
|
-
ringtone.release();
|
176
|
-
ringtone = null;
|
177
|
-
vibrator.cancel();
|
178
|
-
|
179
|
-
}
|
180
|
-
catch (Exception e)
|
181
|
-
{
|
182
|
-
|
183
|
-
}
|
184
|
-
}
|
185
|
-
public void createOngoingChannel() {
|
186
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
187
|
-
|
188
|
-
NotificationChannel channel = new NotificationChannel(ONGOING_CHANNEL_ID, ONGOING_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
189
|
-
channel.setDescription(ONGOING_CHANNEL_NAME);
|
190
|
-
|
191
|
-
channel.setSound(null,null);
|
192
|
-
Objects.requireNonNull(getApplicationContext().getSystemService(NotificationManager.class)).createNotificationChannel(channel);
|
193
|
-
|
194
|
-
}
|
195
|
-
}
|
196
|
-
public void createIncomingChannel() {
|
197
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
198
|
-
|
199
|
-
NotificationChannel channel = new NotificationChannel(INCOMING_CHANNEL_ID, INCOMING_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
|
200
|
-
channel.setDescription(INCOMING_CHANNEL_NAME);
|
201
|
-
|
202
|
-
channel.setSound(null,null);
|
203
|
-
|
204
|
-
|
205
|
-
Objects.requireNonNull(getApplicationContext().getSystemService(NotificationManager.class)).createNotificationChannel(channel);
|
206
|
-
|
207
|
-
}
|
208
|
-
}
|
209
|
-
|
210
|
-
}
|
package/android/src/main/java/com/test/callkit/androidcall/VoipForegroundServiceActionReceiver.java
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
package com.bfine.capactior.callkitvoip.androidcall;
|
2
|
-
|
3
|
-
import android.content.BroadcastReceiver;
|
4
|
-
import android.content.Context;
|
5
|
-
import android.content.Intent;
|
6
|
-
import android.os.Build;
|
7
|
-
import android.util.Log;
|
8
|
-
|
9
|
-
import androidx.annotation.RequiresApi;
|
10
|
-
|
11
|
-
import com.bfine.capactior.callkitvoip.CallKitVoipPlugin;
|
12
|
-
|
13
|
-
|
14
|
-
public class VoipForegroundServiceActionReceiver extends BroadcastReceiver {
|
15
|
-
@Override
|
16
|
-
public void onReceive(Context context, Intent intent) {
|
17
|
-
if (intent != null ) {
|
18
|
-
String action = intent.getAction();
|
19
|
-
String token = intent.getStringExtra("token");
|
20
|
-
String roomName = intent.getStringExtra("roomName");
|
21
|
-
String username = intent.getStringExtra("username");
|
22
|
-
|
23
|
-
|
24
|
-
if (action != null) {
|
25
|
-
performClickAction(context, action,token,roomName,username);
|
26
|
-
}
|
27
|
-
|
28
|
-
// Close the notification after the click action is performed.
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
}
|
33
|
-
private void performClickAction(Context context, String action,String token,String roomName,String username) {
|
34
|
-
Log.d("performClickAction","action "+action + " "+username);
|
35
|
-
|
36
|
-
if (action.equals("RECEIVE_CALL")) {
|
37
|
-
|
38
|
-
Intent dialogIntent = new Intent(context, CallActivity.class);
|
39
|
-
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
40
|
-
dialogIntent.putExtra("auto_answer",true);
|
41
|
-
dialogIntent.putExtra("token",token);
|
42
|
-
dialogIntent.putExtra("roomName",roomName);
|
43
|
-
dialogIntent.putExtra("username",username);
|
44
|
-
|
45
|
-
context.startActivity(dialogIntent);
|
46
|
-
}
|
47
|
-
else if (action.equals("FULLSCREEN_CALL")) {
|
48
|
-
|
49
|
-
|
50
|
-
Intent dialogIntent = new Intent(context, CallActivity.class);
|
51
|
-
|
52
|
-
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
53
|
-
dialogIntent.putExtra("auto_answer",false);
|
54
|
-
dialogIntent.putExtra("token",token);
|
55
|
-
dialogIntent.putExtra("roomName",roomName);
|
56
|
-
dialogIntent.putExtra("username",username);
|
57
|
-
|
58
|
-
context.startActivity(dialogIntent);
|
59
|
-
}
|
60
|
-
else if (action.equals("CANCEL_CALL")) {
|
61
|
-
context.stopService(new Intent(context, VoipForegroundService.class));
|
62
|
-
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
63
|
-
context.sendBroadcast(it);
|
64
|
-
end_call(username,roomName);
|
65
|
-
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
public void end_call( String username,String connectionId)
|
70
|
-
{
|
71
|
-
CallKitVoipPlugin instance = CallKitVoipPlugin.getInstance();
|
72
|
-
instance.notifyEvent("RejectCall",username,connectionId);
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
}
|