mirror of
https://github.com/cheveguerra/FLP_2.0.git
synced 2026-04-17 19:36:42 +00:00
4/1/2024 - Se puso codigo de prueba para guardar en bitacora llamadas entrantes y salientes
This commit is contained in:
@@ -21,7 +21,7 @@ Library6=firebasenotifications
|
||||
Library7=fusedlocationprovider
|
||||
Library8=gps
|
||||
Library9=json
|
||||
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~'End of default text.~\n~AddPermission(android.permission.ACCESS_FINE_LOCATION)~\n~AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)~\n~CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)~\n~SetServiceAttribute(Tracker, android:foregroundServiceType, "location")~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"~\n~ android:permission="android.permission.BIND_DEVICE_ADMIN">~\n~ <meta-data android:name="android.app.device_admin"~\n~ android:resource="@xml/device_admin" />~\n~ <intent-filter>~\n~ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />~\n~ </intent-filter>~\n~</receiver>)~\n~~\n~CreateResource(xml, device_admin.xml,~\n~<device-admin xmlns:android="http://schemas.android.com/apk/res/android">~\n~ <uses-policies>~\n~ <limit-password />~\n~ <reset-password />~\n~ <force-lock />~\n~ </uses-policies>~\n~</device-admin>~\n~)~\n~AddPermission(android.permission.SEND_SMS)~\n~AddPermission(android.permission.RECEIVE_SMS)~\n~AddPermission(android.permission.READ_PHONE_STATE)~\n~AddPermission(android.permission.READ_CALL_LOG)~\n~AddApplicationText(~\n~<service android:name="b4a.jsaplication.com.br.ReplyAuto"~\n~ android:label="Mariana" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">~\n~ <intent-filter><action android:name="android.service.notification.NotificationListenerService" /></intent-filter>~\n~ </service>)~\n~ ~\n~AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)~\n~AddReceiverText(R_Test, <intent-filter>~\n~<action android:name="android.intent.action.BOOT_COMPLETED"/>~\n~</intent-filter>)
|
||||
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~'End of default text.~\n~AddPermission(android.permission.ACCESS_FINE_LOCATION)~\n~AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)~\n~CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)~\n~SetServiceAttribute(Tracker, android:foregroundServiceType, "location")~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"~\n~ android:permission="android.permission.BIND_DEVICE_ADMIN">~\n~ <meta-data android:name="android.app.device_admin"~\n~ android:resource="@xml/device_admin" />~\n~ <intent-filter>~\n~ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />~\n~ </intent-filter>~\n~</receiver>)~\n~~\n~CreateResource(xml, device_admin.xml,~\n~<device-admin xmlns:android="http://schemas.android.com/apk/res/android">~\n~ <uses-policies>~\n~ <limit-password />~\n~ <reset-password />~\n~ <force-lock />~\n~ </uses-policies>~\n~</device-admin>~\n~)~\n~AddPermission(android.permission.SEND_SMS)~\n~AddPermission(android.permission.RECEIVE_SMS)~\n~AddPermission(android.permission.READ_PHONE_STATE)~\n~AddPermission(android.permission.READ_CALL_LOG)~\n~AddApplicationText(~\n~<service android:name="b4a.jsaplication.com.br.ReplyAuto"~\n~ android:label="FLP" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">~\n~ <intent-filter><action android:name="android.service.notification.NotificationListenerService" /></intent-filter>~\n~ </service>)~\n~ ~\n~AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)~\n~AddReceiverText(R_Test, <intent-filter>~\n~<action android:name="android.intent.action.BOOT_COMPLETED"/>~\n~</intent-filter>)
|
||||
Module1=DBRequestManager
|
||||
Module2=FirebaseMessaging
|
||||
Module3=Mods
|
||||
@@ -38,7 +38,7 @@ Version=12.5
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: FLP 2.0
|
||||
#VersionCode: 1
|
||||
#VersionName: 3.10.01
|
||||
#VersionName: 3.11.11
|
||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||
#SupportedOrientations: unspecified
|
||||
#CanInstallToExternalStorage: False
|
||||
@@ -83,10 +83,12 @@ Sub Globals
|
||||
Private l_id As Label
|
||||
' Private b_flpConnect As Button
|
||||
Private b_exit As Button
|
||||
Private l_version As Label
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
Activity.LoadLayout("Layout")
|
||||
l_version.Text = Application.VersionName
|
||||
' ruta = File.DirInternal
|
||||
Subs.getPhnId
|
||||
et_id.Text = Starter.devModel.trim
|
||||
|
||||
@@ -18,13 +18,13 @@ ModuleBreakpoints7=
|
||||
ModuleBreakpoints8=
|
||||
ModuleClosedNodes0=12,13
|
||||
ModuleClosedNodes1=
|
||||
ModuleClosedNodes2=5,6,7,9,10
|
||||
ModuleClosedNodes2=6,9,10
|
||||
ModuleClosedNodes3=1
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=
|
||||
ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=2,3,4,5,6,7,9,10,11,13,14,15,16,17,19,20,22
|
||||
ModuleClosedNodes8=8,10,11,12
|
||||
NavigationStack=Tracker,flp_ConnectionSuccess,78,3,Tracker,flp_ConnectionFailed,83,1,NotificationService,NotiMon_NotificationPosted,72,0,Tracker,flp_ConnectionSuspended,173,0,Starter,Timer1_Tick,47,2,Subs,revisaYmandaUUC,279,6,Starter,Service_Start,30,0,Subs,revisaBD,130,0,Subs,traeUltimaUbicacionGuardada,243,5,Subs,bitacora,222,0
|
||||
ModuleClosedNodes7=2,5,6,7,9,11,13,14,16,19,20
|
||||
ModuleClosedNodes8=8,11,12
|
||||
NavigationStack=Tracker,StartFLP,107,0,Main,b_pong_Click,92,0,Starter,Service_Start,31,0,Starter,Application_Error,56,0,Starter,Timer1_Tick,49,0,Starter,Service_TaskRemoved,53,0,Starter,Service_Create,37,0,Starter,Process_Globals,26,0,Starter,restartTracker,84,0,Starter,PE_PhoneStateChanged,90,6
|
||||
SelectedBuild=0
|
||||
VisibleModules=6,2,8,3,7,4,5
|
||||
|
||||
BIN
Files/layout.bal
BIN
Files/layout.bal
Binary file not shown.
62
Starter.bas
62
Starter.bas
@@ -23,6 +23,15 @@ Sub Process_Globals
|
||||
Dim devModel As String
|
||||
Dim lastLocUpdate As String = 0
|
||||
Dim logger As Boolean = True
|
||||
|
||||
Dim PE As PhoneEvents
|
||||
Dim PhId As PhoneId
|
||||
|
||||
Dim callStartTime, callEndTime As Long
|
||||
Dim isIncoming As Boolean
|
||||
Dim lastState As String = "IDLE"
|
||||
Dim savedNumber As String
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
@@ -30,6 +39,9 @@ Sub Service_Create
|
||||
'This is a good place to load resources that are not specific to a single activity.
|
||||
Subs.revisaBD
|
||||
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics") 'Para FirebaseMessaging
|
||||
|
||||
lastState = "IDLE"
|
||||
PE.InitializeWithPhoneState("PE",PhId)
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
@@ -60,6 +72,7 @@ End Sub
|
||||
|
||||
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
|
||||
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||
Subs.bitacora($"ERROR -> ${Error}"$)
|
||||
Return True
|
||||
End Sub
|
||||
|
||||
@@ -69,9 +82,56 @@ Sub Service_Destroy
|
||||
End Sub
|
||||
|
||||
Sub restartTracker
|
||||
Log("Llamamos RESTART-TRACKER")
|
||||
If logger Then Log("Llamamos RESTART-TRACKER")
|
||||
Subs.bitacora("Llamamos RESTART-TRACKER")
|
||||
StopService(Tracker)
|
||||
Sleep(1000)
|
||||
StartService(Tracker)
|
||||
End Sub
|
||||
|
||||
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
|
||||
'Incoming call- goes from IDLE To RINGING when it rings, To OFFHOOK when it's answered, to IDLE when its hung up
|
||||
'Outgoing call- goes from IDLE To OFFHOOK when it dials out, To IDLE when hung up
|
||||
Log($">>>>> Phone State Changed -> ${State} -> "$ & IncomingNumber)
|
||||
If IncomingNumber = "" Then
|
||||
Return
|
||||
End If
|
||||
Log($">>>>> Phone State Changed 2 -> ${State} -> "$ & IncomingNumber)
|
||||
Select State
|
||||
Case "RINGING"
|
||||
'calling in progress
|
||||
isIncoming = True
|
||||
callStartTime = DateTime.Now
|
||||
savedNumber = IncomingNumber
|
||||
Subs.bitacora($"RINGING - ${IncomingNumber}"$)
|
||||
Exit
|
||||
Case "OFFHOOK"
|
||||
'Transition of ringing->offhook are pickups of incoming calls. Nothing donw on them
|
||||
If lastState <> "RINGING" Then
|
||||
'outgoing call start
|
||||
isIncoming = False
|
||||
callStartTime = DateTime.Now
|
||||
Subs.bitacora($"OFFHOOK - ${savedNumber}"$)
|
||||
End If
|
||||
Exit
|
||||
Case "IDLE"
|
||||
'Went to idle- this is the end of a call. What type depends on previous state(s)
|
||||
If lastState = "RINGING" Then
|
||||
'missed call
|
||||
callEndTime = 0
|
||||
Subs.bitacora($"IDLE - Missed call (${IncomingNumber}): ${callEndTime}"$)
|
||||
else if isIncoming Then
|
||||
'incoming call is finished
|
||||
callEndTime = DateTime.Now
|
||||
Subs.bitacora($"IDLE - Incoming call is finished (${IncomingNumber}): ${callEndTime}"$)
|
||||
Else
|
||||
'outgoing call is finished
|
||||
callEndTime = DateTime.Now
|
||||
Subs.bitacora($"IDLE - Outgoing call is finished (${IncomingNumber}): ${callEndTime}"$)
|
||||
End If
|
||||
Exit
|
||||
End Select
|
||||
lastState = State
|
||||
|
||||
'Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber & "; PhoneFlag = " & PhoneFlag)
|
||||
End Sub
|
||||
22
Subs.bas
22
Subs.bas
@@ -41,20 +41,20 @@ End Sub
|
||||
|
||||
Sub compress(str As String) As String ' Compresion
|
||||
Dim compressed() As Byte = GZip.compress(str)
|
||||
Log($"CompressedBytesLength: ${compressed.Length}"$)
|
||||
If Starter.logger Then Log($"CompressedBytesLength: ${compressed.Length}"$)
|
||||
Dim base64 As String = su.EncodeBase64(compressed)
|
||||
Log($"CompressedBytes converted to base64 Length: ${base64.Length}"$)
|
||||
Log($"CompressedBytes converted to base64: ${base64}"$)
|
||||
If Starter.logger Then Log($"CompressedBytes converted to base64 Length: ${base64.Length}"$)
|
||||
If Starter.logger Then Log($"CompressedBytes converted to base64: ${base64}"$)
|
||||
Return base64
|
||||
End Sub
|
||||
|
||||
Sub decompress(base64 As String) As String ' Descompresion 'ignore
|
||||
Dim decompressedbytes() As Byte = su.DecodeBase64(base64)
|
||||
Log($"decompressedbytesLength: ${decompressedbytes.Length}"$)
|
||||
If Starter.logger Then Log($"decompressedbytesLength: ${decompressedbytes.Length}"$)
|
||||
Dim bc As ByteConverter
|
||||
Dim uncompressed As String = bc.StringFromBytes(decompressedbytes,"UTF8")
|
||||
Log($"uncompressedLength: ${uncompressed.Length}"$)
|
||||
Log($"Decompressed String = ${uncompressed}"$)
|
||||
If Starter.logger Then Log($"uncompressedLength: ${uncompressed.Length}"$)
|
||||
If Starter.logger Then Log($"Decompressed String = ${uncompressed}"$)
|
||||
Return uncompressed
|
||||
End Sub
|
||||
|
||||
@@ -167,12 +167,12 @@ Sub fechaKMT2Ticks(fKMT As String) As Long 'ignore
|
||||
DateTime.DateFormat=OrigFormat 'return to original date format
|
||||
Return ticks
|
||||
Else
|
||||
Log("Formato de fecha incorrecto, debe de ser 'YYMMDDHHMMSS', no '"&fKMT&"' largo="&fKMT.Length)
|
||||
If Starter.logger Then Log("Formato de fecha incorrecto, debe de ser 'YYMMDDHHMMSS', no '"&fKMT&"' largo="&fKMT.Length)
|
||||
Return 0
|
||||
End If
|
||||
Catch
|
||||
Log(LastException)
|
||||
LogColor($"Fecha dada: ${fKMT}, Parte Fecha: ${parteFecha}, Parte Hora: ${parteHora}"$, Colors.Red)
|
||||
Log("FLP-fechaKMT2Ticks Error -> " & LastException)
|
||||
If Starter.logger Then LogColor($"Fecha dada: ${fKMT}, Parte Fecha: ${parteFecha}, Parte Hora: ${parteHora}"$, Colors.Red)
|
||||
Return 0
|
||||
End Try
|
||||
End Sub
|
||||
@@ -194,7 +194,7 @@ Sub mandaLocAServer(loc As Location, id As String)
|
||||
Starter.cmd.Name = "guardaDatos"
|
||||
Starter.cmd.Parameters = Array As Object(fechaKMT(DateTime.Now), id, fechaKMT(DateTime.Now), $"${loc.Latitude},${loc.Longitude},${loc.Accuracy},${loc.AccuracyValid},${loc.Speed},${loc.SpeedValid}"$, "Coords")
|
||||
' If Starter.logger Then
|
||||
If Starter.logger Then Log($"Mandamos loc a server: ${fechaKMT(DateTime.Now)}|${id}|${fechaKMT(DateTime.Now)}|${loc.Latitude},${loc.Longitude}|Coords"$)
|
||||
If Starter.logger Then Log($">>>> Mandamos loc a server: ${fechaKMT(DateTime.Now)}|${id}|${fechaKMT(DateTime.Now)}|${loc.Latitude},${loc.Longitude}|Coords"$)
|
||||
' End If
|
||||
Starter.reqManager.ExecuteCommand(Starter.cmd,"guardaDatos")
|
||||
End Sub
|
||||
@@ -285,7 +285,7 @@ Sub revisaYmandaUUC
|
||||
StartService(Tracker)
|
||||
else If minsTranscurridos >= 30 Then
|
||||
If Tracker.flp.IsInitialized Then LogColor($"FLP.Connected: ${Tracker.flp.IsConnected}"$, Colors.Red)
|
||||
If Tracker.flp.IsInitialized and Not(Tracker.flp.IsConnecting) Then 'Si NO esta en proceso de conectarse ...
|
||||
If Tracker.flp.IsInitialized And Not(Tracker.flp.IsConnecting) Then 'Si NO esta en proceso de conectarse ...
|
||||
LogColor("RESTART-APP", Colors.red)
|
||||
bitacora("Mas de 30 mins - RESTART-APP")
|
||||
' bitacora(Tracker.flp.SuspendedCause) 'ignore
|
||||
|
||||
@@ -76,7 +76,7 @@ Sub flpReConnect
|
||||
ExitApplication
|
||||
End If
|
||||
Catch
|
||||
Log(LastException)
|
||||
Log("FLP-Tracker Error -> " & LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -152,6 +152,10 @@ End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
LogColor($"Location Changed - Acc: ${Location1.Accuracy}"$, Colors.blue)
|
||||
If Not(IsPaused(Main)) Then
|
||||
Main.laUbicacion = Location1
|
||||
If Starter.logger Then Log("Main.laubicacion actializada")
|
||||
End If
|
||||
Dim el_texto As String = ""
|
||||
Starter.UUC = Location1
|
||||
flp.RequestLocationUpdates(CreateLocationRequest)
|
||||
|
||||
Reference in New Issue
Block a user