Skip to content
Merged
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
27 changes: 8 additions & 19 deletions src/android/MyConnectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,12 @@ public static void deinitConnection() {
conn = null;
}

private static JSONObject convertBundleToJson(Bundle bundle) {
JSONObject jsonObject = new JSONObject();
if (bundle != null) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
try {
jsonObject.put(key, value);
} catch (JSONException e) {
Log.e(TAG, "Failed to convert bundle to JSON", e);
}
}
}
return jsonObject;
}

@Override
public Connection onCreateIncomingConnection(final PhoneAccountHandle connectionManagerPhoneAccount, final ConnectionRequest request) {
Bundle requestExtras = request.getExtras() != null ? request.getExtras() : new Bundle();
String fromAddress = requestExtras.getString("from");
String payloadString = requestExtras.getString("payload");

final Connection connection = new Connection() {
@Override
public void onAnswer() {
Expand Down Expand Up @@ -82,8 +71,7 @@ public void run() {
for (final CallbackContext callbackContext : callbackContexts) {
CordovaCall.getCordova().getThreadPool().execute(new Runnable() {
public void run() {
Bundle data = request.getExtras() != null ? request.getExtras() : new Bundle();
PluginResult result = new PluginResult(PluginResult.Status.OK, convertBundleToJson(data));
PluginResult result = new PluginResult(PluginResult.Status.OK, payloadString);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
}
Expand All @@ -103,7 +91,7 @@ public void onReject() {
for (final CallbackContext callbackContext : callbackContexts) {
CordovaCall.getCordova().getThreadPool().execute(new Runnable() {
public void run() {
PluginResult result = new PluginResult(PluginResult.Status.OK, "reject event called successfully");
PluginResult result = new PluginResult(PluginResult.Status.OK, payloadString);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
}
Expand Down Expand Up @@ -134,7 +122,8 @@ public void run() {
}
}
};
connection.setAddress(Uri.parse(request.getExtras().getString("from")), TelecomManager.PRESENTATION_ALLOWED);

connection.setAddress(Uri.parse(fromAddress), TelecomManager.PRESENTATION_ALLOWED);
Icon icon = CordovaCall.getIcon();
if(icon != null) {
StatusHints statusHints = new StatusHints((CharSequence)"", icon, new Bundle());
Expand Down