Skip to content

Don't try to get phone account if self managed when creating a connection #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ To implement a self managed calling app, the following steps are necessary:
- When `showIncomingCallUi` is fired, you must show an incoming call UI. This would be a high priority notification ([Android: Display time-sensitive notifications](https://developer.android.com/training/notify-user/time-sensitive)).
- If the user answers the call, you call the appropriate RNCallKeep actions such as `answerCall` or `endCall`
- In certain cases Android will not allow you to show an incoming call notification. In that case the 'createIncomingConnectionFailed' event is fired and you should reject the incoming SIP Invite.
- When using self managed mode, all connections created by the foreground service will be self managed.

Self Managed calling apps are an advanced topic, and there are many steps involved in implementing them, but here are some things to keep in mind:
- React Native Headless Tasks are a great way to execute React Native code. Remember to start up the headless task as a Foreground Service.
Expand Down
1 change: 1 addition & 0 deletions android/src/main/java/io/wazo/callkeep/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Constants {
public static final String EXTRA_CALL_UUID = "EXTRA_CALL_UUID";
public static final String EXTRA_CALLER_NAME = "EXTRA_CALLER_NAME";
public static final String EXTRA_HAS_VIDEO = "EXTRA_HAS_VIDEO";
public static final String EXTRA_SELF_MANAGED = "EXTRA_SELF_MANAGED";
public static final String EXTRA_PAYLOAD = "EXTRA_PAYLOAD";
// Can't use telecom.EXTRA_DISABLE_ADD_CALL ...
public static final String EXTRA_DISABLE_ADD_CALL = "android.telecom.extra.DISABLE_ADD_CALL";
Expand Down
2 changes: 2 additions & 0 deletions android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import static io.wazo.callkeep.Constants.EXTRA_CALL_UUID;
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER;
import static io.wazo.callkeep.Constants.EXTRA_HAS_VIDEO;
import static io.wazo.callkeep.Constants.EXTRA_SELF_MANAGED;
import static io.wazo.callkeep.Constants.EXTRA_PAYLOAD;
import static io.wazo.callkeep.Constants.ACTION_END_CALL;
import static io.wazo.callkeep.Constants.ACTION_ANSWER_CALL;
Expand Down Expand Up @@ -382,6 +383,7 @@ public void startCall(String uuid, String number, String callerName, boolean has
callExtras.putString(EXTRA_CALL_UUID, uuid);
callExtras.putString(EXTRA_CALL_NUMBER, number);
callExtras.putString(EXTRA_HAS_VIDEO, String.valueOf(hasVideo));
callExtras.putString(EXTRA_SELF_MANAGED, String.valueOf(isSelfManaged()));
if (payload != null) {
callExtras.putBundle(EXTRA_PAYLOAD, payload);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER;
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER_SCHEMA;
import static io.wazo.callkeep.Constants.EXTRA_CALL_UUID;
import static io.wazo.callkeep.Constants.EXTRA_SELF_MANAGED;
import static io.wazo.callkeep.Constants.EXTRA_DISABLE_ADD_CALL;
import static io.wazo.callkeep.Constants.FOREGROUND_SERVICE_TYPE_MICROPHONE;
import static io.wazo.callkeep.Constants.ACTION_ON_CREATE_CONNECTION_FAILED;
Expand Down Expand Up @@ -448,7 +449,10 @@ private Connection createConnection(ConnectionRequest request) {
VoiceConnection connection = new VoiceConnection(this, extrasMap);
connection.setConnectionCapabilities(Connection.CAPABILITY_MUTE | Connection.CAPABILITY_SUPPORT_HOLD);

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Boolean.parseBoolean(extras.getString(EXTRA_SELF_MANAGED))) {
Log.d(TAG, "[VoiceConnectionService] self managed is enabled in setup, so connection will be too");
connection.setConnectionProperties(Connection.PROPERTY_SELF_MANAGED);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Context context = getApplicationContext();
TelecomManager telecomManager = (TelecomManager) context.getSystemService(context.TELECOM_SERVICE);
PhoneAccount phoneAccount = telecomManager.getPhoneAccount(request.getAccountHandle());
Expand Down