Skip to content

Commit 3122123

Browse files
authored
Merge pull request #44 from react-native-webrtc/add_debug
Add some android debug
2 parents 9b6b4df + f12c332 commit 3122123

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ class RNCallKeepExample extends React.Component {
426426

427427
- On iOS, you should call `setup` each time you want to use callKeep.
428428

429+
## Debug
430+
431+
### Android
432+
433+
```
434+
adb logcat *:S RNCallKeepModule:V
435+
```
436+
429437
## Contributing
430438

431439
Any pull request, issue report and suggestion are highly welcome!

android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.content.pm.ApplicationInfo;
2828
import android.content.pm.PackageManager;
2929
import android.net.Uri;
30+
import android.util.Log;
3031
import android.os.Build;
3132
import android.os.Bundle;
3233
import android.support.annotation.Nullable;
@@ -68,6 +69,7 @@ public class RNCallKeepModule extends ReactContextBaseJavaModule {
6869
private static final String REACT_NATIVE_MODULE_NAME = "RNCallKeep";
6970
private static final String[] permissions = { Manifest.permission.READ_PHONE_STATE, Manifest.permission.CALL_PHONE };
7071

72+
private static final String TAG = "RNCallKeepModule";
7173
private static TelecomManager telecomManager;
7274
private static Promise hasPhoneAccountPromise;
7375
private ReactApplicationContext reactContext;
@@ -110,6 +112,8 @@ public void displayIncomingCall(String number, String callerName) {
110112
return;
111113
}
112114

115+
Log.d(TAG, "displayIncomingCall number: " + number + ", callerName: " + callerName);
116+
113117
Bundle extras = new Bundle();
114118
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
115119

@@ -121,10 +125,12 @@ public void displayIncomingCall(String number, String callerName) {
121125

122126
@ReactMethod
123127
public void startCall(String number, String callerName) {
124-
if (!isConnectionServiceAvailable() || !hasPhoneAccount() || !hasPermissions()) {
128+
if (!isConnectionServiceAvailable() || !hasPhoneAccount() || !hasPermissions() || number == null) {
125129
return;
126130
}
127131

132+
Log.d(TAG, "startCall number: " + number + ", callerName: " + callerName);
133+
128134
Bundle extras = new Bundle();
129135
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
130136

@@ -139,6 +145,7 @@ public void startCall(String number, String callerName) {
139145

140146
@ReactMethod
141147
public void endCall() {
148+
Log.d(TAG, "endCall called");
142149
if (!isConnectionServiceAvailable() || !hasPhoneAccount()) {
143150
return;
144151
}
@@ -151,6 +158,8 @@ public void endCall() {
151158
conn.setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
152159
conn.destroy();
153160
VoiceConnectionService.deinitConnection();
161+
162+
Log.d(TAG, "endCall executed");
154163
}
155164

156165
@ReactMethod

android/src/main/java/io/wazo/callkeep/VoiceConnectionService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
public class VoiceConnectionService extends ConnectionService {
5050
private static Connection connection;
5151
private static Boolean isAvailable = false;
52+
private static final String TAG = "RNCallKeepModule";
5253

5354
public static Connection getConnection() {
5455
return connection;
@@ -60,6 +61,7 @@ public static void setAvailable(Boolean value) {
6061

6162

6263
public static void deinitConnection() {
64+
Log.d(TAG, "deinitConnection");
6365
connection = null;
6466
}
6567

@@ -109,6 +111,7 @@ public void onCallAudioStateChanged(CallAudioState state) {
109111
@Override
110112
public void onAnswer() {
111113
super.onAnswer();
114+
Log.d(TAG, "onAnswer called");
112115
if (connection == null) {
113116
return;
114117
}
@@ -118,6 +121,7 @@ public void onAnswer() {
118121

119122
sendCallRequestToActivity(ACTION_ANSWER_CALL, null);
120123
sendCallRequestToActivity(ACTION_AUDIO_SESSION, null);
124+
Log.d(TAG, "onAnswer executed");
121125
}
122126

123127
@Override
@@ -128,20 +132,24 @@ public void onPlayDtmfTone(char dtmf) {
128132
@Override
129133
public void onDisconnect() {
130134
super.onDisconnect();
135+
Log.d(TAG, "onDisconnect called");
131136
if (connection == null) {
132137
return;
133138
}
134139

140+
135141
connection.setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
136142
connection.destroy();
137143
connection = null;
138144

139145
sendCallRequestToActivity(ACTION_END_CALL, null);
146+
Log.d(TAG, "onDisconnect executed");
140147
}
141148

142149
@Override
143150
public void onAbort() {
144151
super.onAbort();
152+
Log.d(TAG, "onAbort called");
145153
if (connection == null) {
146154
return;
147155
}
@@ -150,6 +158,7 @@ public void onAbort() {
150158
connection.destroy();
151159

152160
sendCallRequestToActivity(ACTION_END_CALL, null);
161+
Log.d(TAG, "onAbort executed");
153162
}
154163

155164
@Override
@@ -171,6 +180,7 @@ public void onUnhold() {
171180
@Override
172181
public void onReject() {
173182
super.onReject();
183+
Log.d(TAG, "onReject called");
174184
if (connection == null) {
175185
return;
176186
}
@@ -179,6 +189,7 @@ public void onReject() {
179189
connection.destroy();
180190

181191
sendCallRequestToActivity(ACTION_END_CALL, null);
192+
Log.d(TAG, "onReject executed");
182193
}
183194
};
184195

0 commit comments

Comments
 (0)