Sub Voip_OnIncomingCall(uri As String, callId As Long)
'Log("incoming call -> " & uri)
Dim Pws As PhoneWakeState
Pws.KeepAlive(True)
CallSubDelayed(DownQueue,"GetQueue")
If uri.Contains("52.67.239.109") Then
'ToastMessageShow ("svc() evt Voip OnIncomingCall", False)
Dim RadioActive As Boolean = False
Dim Login As String = ""
If Kvs.ContainsKey("radioactive") Then
RadioActive = Kvs.Get("radioactive")
Login = Kvs.Get("remotelogin")
End If
Dim sf As StringFunctions
Dim ContatoReal As String
sf.Initialize
'ContatoReal = sf.Mid(uri,2,sf.Len(uri)-1)
'ContatoReal = sf.Left(ContatoReal,sf.At(ContatoReal,"<") - 2)
If sf.Left(uri,1) <> Chr(34) Then 'direct call
Dim PosicaoDt As Int = sf.At(uri,":")
Dim PosicaoArr As Int = sf.At(uri,"@")
ContatoReal = sf.Mid(uri,PosicaoDt + 2,PosicaoArr - PosicaoDt - 1)
Else
ContatoReal = sf.Mid(uri,2,sf.Len(uri)-1)
ContatoReal = sf.Left(ContatoReal,sf.At(ContatoReal,"<") - 2)
End If
If Not(RadioActive) Or RadioActive And ContatoReal <> Login Then
'clear radio event if true (needed???) - TODO test!
If sf.InString(ContatoReal,".") < 0 And sf.Len(ContatoReal) < 5 Then
Phone.rejectCall
End If
ToastMessageShow ("Recebendo Chamada!", False)
If SdkVersion < 23 Then
Nb.Initialize
Nb.SmallIcon = "oncall"
Nb.LargeIcon = LoadBitmap(File.DirAssets,"largecall.png")
Nb.ContentTitle = "Chamada Telefônica"
Nb.ContentText = " Telefone tocando..."
Nb.SubText = "Clique aqui para atender ou recusar"
Nb.DefaultSound = False
Nb.setActivity(emchamada)
Nb.DefaultVibrate = False
Nb.OnGoingEvent = True
Nb.Notify(1)
Else
NotifyV6("largecall.png","Chamada Telefônica","Clique aqui para atender ou recusar","Chamada Telefonica","Clique para atender ou recusar", 1 ,emchamada)
End If
OnCall=True
emchamada.Contact = ContatoReal
emchamada.Incomming = True
emchamada.VideoFlag = Phone.isVideoCall
emchamada.ShouldClose = False
emchamada.Refresh = IsPaused(emchamada)
StartActivity(emchamada)
Phone.SpeakerphoneOn = False
Else 'Radio Call
If sf.InString(ContatoReal,".") < 0 And sf.Len(ContatoReal) < 5 Then
Phone.rejectCall
Else
Phone.answerCall(200,False)
Phone.SpeakerphoneOn = True
End If
'Will Generate OnCallConnected
End If
' Call.Contact = uri
' Call.Incomming = True
' Call.VideoFlag = Phone.isVideoCall
' Call.ShouldClose = False
' Call.Refresh = IsPaused(Call)
' StartActivity(Call)
Else
Phone.rejectCall
End If
End Sub