@@ -53,12 +53,16 @@ public class VoiceConnection extends Connection {
5353 if (name != null && !name .equals ("" )) {
5454 setCallerDisplayName (name , TelecomManager .PRESENTATION_ALLOWED );
5555 }
56+ Log .e (TAG , "Constructor" );
5657 }
5758
5859 @ Override
5960 public void onExtrasChanged (Bundle extras ) {
6061 super .onExtrasChanged (extras );
61- handle = (HashMap <String , String >)extras .getSerializable ("attributeMap" );
62+ HashMap attributeMap = (HashMap <String , String >)extras .getSerializable ("attributeMap" );
63+ if (attributeMap != null ) {
64+ handle = attributeMap ;
65+ }
6266 }
6367
6468 @ Override
@@ -86,7 +90,11 @@ public void onAnswer() {
8690
8791 @ Override
8892 public void onPlayDtmfTone (char dtmf ) {
89- handle .put ("DTMF" , Character .toString (dtmf ));
93+ try {
94+ handle .put ("DTMF" , Character .toString (dtmf ));
95+ } catch (Throwable exception ) {
96+ Log .e (TAG , "Handle map error" , exception );
97+ }
9098 sendCallRequestToActivity (ACTION_DTMF_TONE , handle );
9199 }
92100
@@ -96,7 +104,11 @@ public void onDisconnect() {
96104 setDisconnected (new DisconnectCause (DisconnectCause .LOCAL ));
97105 sendCallRequestToActivity (ACTION_END_CALL , handle );
98106 Log .d (TAG , "onDisconnect executed" );
99- ((VoiceConnectionService )context ).deinitConnection (handle .get (EXTRA_CALL_UUID ));
107+ try {
108+ ((VoiceConnectionService ) context ).deinitConnection (handle .get (EXTRA_CALL_UUID ));
109+ } catch (Throwable exception ) {
110+ Log .e (TAG , "Handle map error" , exception );
111+ }
100112 destroy ();
101113 }
102114
@@ -125,7 +137,11 @@ public void onAbort() {
125137 setDisconnected (new DisconnectCause (DisconnectCause .REJECTED ));
126138 sendCallRequestToActivity (ACTION_END_CALL , handle );
127139 Log .d (TAG , "onAbort executed" );
128- ((VoiceConnectionService )context ).deinitConnection (handle .get (EXTRA_CALL_UUID ));
140+ try {
141+ ((VoiceConnectionService ) context ).deinitConnection (handle .get (EXTRA_CALL_UUID ));
142+ } catch (Throwable exception ) {
143+ Log .e (TAG , "Handle map error" , exception );
144+ }
129145 destroy ();
130146 }
131147
@@ -149,7 +165,11 @@ public void onReject() {
149165 setDisconnected (new DisconnectCause (DisconnectCause .REJECTED ));
150166 sendCallRequestToActivity (ACTION_END_CALL , handle );
151167 Log .d (TAG , "onReject executed" );
152- ((VoiceConnectionService )context ).deinitConnection (handle .get (EXTRA_CALL_UUID ));
168+ try {
169+ ((VoiceConnectionService ) context ).deinitConnection (handle .get (EXTRA_CALL_UUID ));
170+ } catch (Throwable exception ) {
171+ Log .e (TAG , "Handle map error" , exception );
172+ }
153173 destroy ();
154174 }
155175
@@ -168,9 +188,8 @@ public void run() {
168188 Bundle extras = new Bundle ();
169189 extras .putSerializable ("attributeMap" , attributeMap );
170190 intent .putExtras (extras );
191+ LocalBroadcastManager .getInstance (context ).sendBroadcast (intent );
171192 }
172-
173- LocalBroadcastManager .getInstance (context ).sendBroadcast (intent );
174193 }
175194 });
176195 }
0 commit comments