mirror of
https://github.com/cheveguerra/FLP_2.0.git
synced 2026-04-17 19:36:42 +00:00
- Se agregó código para mande ubicación MINIMO cada minuto
This commit is contained in:
@@ -35,12 +35,12 @@ Module9=Tracker
|
||||
NumberOfFiles=2
|
||||
NumberOfLibraries=18
|
||||
NumberOfModules=9
|
||||
Version=12.5
|
||||
Version=12.8
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: FLP 2.0
|
||||
#VersionCode: 1
|
||||
#VersionName: 4.01.17
|
||||
#VersionName: 4.03.17
|
||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||
#SupportedOrientations: unspecified
|
||||
#CanInstallToExternalStorage: False
|
||||
|
||||
@@ -28,6 +28,6 @@ ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=
|
||||
ModuleClosedNodes8=
|
||||
ModuleClosedNodes9=
|
||||
NavigationStack=Tracker,flpReConnect,197,0,Starter,Service_Create,67,0,errorManager,Activity_Resume,91,0,Starter,Application_Error,67,0,Starter,Process_Globals,18,5,Tracker,Process_Globals,28,0,Tracker,Service_Destroy,189,0,Tracker,StopFLP,141,1,Tracker,CreateLocationRequest2,136,0,NotificationService,NotiMon_NotificationPosted,69,0,Subs,revisaYmandaUUC,289,6
|
||||
NavigationStack=Subs,traeUltimaUbicacionGuardada,245,0,Starter,Service_Start,54,0,FirebaseMessaging,SendMessage,127,0,FirebaseMessaging,mandaLocFM,150,0,Subs,mandaLoc2,197,0,NotificationService,NotiMon_NotificationPosted,85,0,FirebaseMessaging,fm_MessageArrived,94,0,Tracker,CreateLocationRequest,116,0,Tracker,CreateLocationRequest2,128,0,Tracker,flp_LocationChanged,158,6
|
||||
SelectedBuild=0
|
||||
VisibleModules=7,3,9,4,8,5,6,2
|
||||
|
||||
9
Subs.bas
9
Subs.bas
@@ -133,6 +133,7 @@ End Sub
|
||||
Sub revisaBD
|
||||
If Not(File.Exists(File.DirInternal, "gps_hist.db")) Then File.Copy(File.DirAssets, "gps_hist.db", File.DirInternal, "gps_hist.db")
|
||||
If Not(gps_hist.IsInitialized) Then gps_hist.Initialize(File.DirInternal, "gps_hist.db", True)
|
||||
If Not(Starter.errorLog.IsInitialized) Then Starter.errorLog.Initialize(File.DirInternal, "errorLog.db", True)
|
||||
gps_hist.ExecNonQuery("CREATE TABLE IF NOT EXISTS BITACORA(RUTA TEXT, TEXTO TEXT, FECHA TEXT)")
|
||||
gps_hist.ExecNonQuery("CREATE TABLE IF NOT EXISTS RUTA_GPS(FECHA INTEGER, LAT TEXT, LON TEXT, ACC INT, TIME INT)")
|
||||
End Sub
|
||||
@@ -267,9 +268,13 @@ Sub revisaYmandaUUC
|
||||
bitacora("Mas de 10 mins - REQ-UPDATE")
|
||||
LogColor($"Ubicacion vieja (mas de 10 mins.)"$, Colors.Red)
|
||||
LogColor("Pedimos actualizacion!", Colors.blue)
|
||||
If Tracker.flp.IsInitialized And Tracker.locReqSmall.IsInitialized Then
|
||||
If Tracker.flp.IsInitialized And Tracker.flp.IsConnected And Tracker.locReqSmall.IsInitialized Then
|
||||
bitacora("REQ-UPDATE") : LogColor("REQ-UPDATE", Colors.magenta)
|
||||
Tracker.flp.RequestLocationUpdates(Tracker.locReqSmall)
|
||||
Try
|
||||
Tracker.flp.RequestLocationUpdates(Tracker.locReqSmall)
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
Else
|
||||
bitacora("TRACKER APAGADO - RESTART-TRACKER") : LogColor("RESTART-TRACKER", Colors.magenta)
|
||||
StopService(Tracker)
|
||||
|
||||
23
Tracker.bas
23
Tracker.bas
@@ -152,23 +152,30 @@ End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
LogColor($"Location Changed - Acc: ${Location1.Accuracy}"$, Colors.blue)
|
||||
Private minsTranscurridos As String = Subs.ticksAMins(DateTime.Now - Subs.traeUltimaUbicacionGuardada.Time) 'Minutos transcurridos desde la ultima ubicacion guardada.
|
||||
LogColor(">>>>>>>>>>>>>>>>>>>>>>> " & minsTranscurridos, Colors.red)
|
||||
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)
|
||||
If Starter.logger Then LogColor("FLP_LocationChanged", Colors.Red)
|
||||
If Starter.logger Then Log(Location1.Accuracy&" - "&Location1.AccuracyValid)
|
||||
el_texto = $"LocChange - Coords NO enviadas (Acc:${Location1.Accuracy})."$
|
||||
'Solo mandamos la ubicacion si la precision es dentro de XX mts
|
||||
If Location1.Accuracy < minAccuracy Then
|
||||
Subs.mandaLoc2(Location1, Starter.devModel)
|
||||
el_texto = $"LocChange - Coords enviadas (Acc:${Location1.Accuracy})."$
|
||||
If minsTranscurridos > 0 Then
|
||||
flp.RequestLocationUpdates(CreateLocationRequest)
|
||||
'Solo mandamos la ubicacion si la precision es dentro de XX mts
|
||||
el_texto = $"LocChange - Coords NO enviadas (Acc:${Location1.Accuracy})."$
|
||||
If Location1.Accuracy < minAccuracy Then
|
||||
Subs.mandaLoc2(Location1, Starter.devModel)
|
||||
el_texto = $"LocChange - Coords enviadas (Acc:${Location1.Accuracy})."$
|
||||
End If
|
||||
' If Starter.logger Then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Starter.devModel&"|")
|
||||
Subs.bitacora($"${el_texto}"$)
|
||||
' ToastMessageShow("LocChanged MORE than a min.", False)
|
||||
Else
|
||||
' ToastMessageShow("Locatin changed but less than a min!.", False)
|
||||
End If
|
||||
' If Starter.logger Then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Starter.devModel&"|")
|
||||
Subs.bitacora($"${el_texto}"$)
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuspended(SuspendedCause1 As Int)
|
||||
|
||||
164
errorManager.bas
Normal file
164
errorManager.bas
Normal file
@@ -0,0 +1,164 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: True
|
||||
#End Region
|
||||
'******************************************************************************
|
||||
'Este modulo intercepta los errores de la aplicación mediante "Starter.Application_Error" y muestra una pantalla
|
||||
'con el log del error y lo manda al servidor con un query de DBRequestManager, se necesita que exista el query
|
||||
'en el "config.properties" llamado "guardaErrores" y que tenga el siguiente texto:
|
||||
'
|
||||
'sql.guardaErrores=INSERT INTO KELLOGGS.PUSH_INFO (ID, RUTA, FECHA, DATOS) VALUES((?),(?),(?),(?))
|
||||
'
|
||||
'Agregar estas lineas a "Starter.Process_Globals"
|
||||
' 'Para los Logs
|
||||
' Dim logs As StringBuilder
|
||||
' Private logcat As LogCat
|
||||
'
|
||||
'Agregar estas lineas a "Starter.Service_Create"
|
||||
' 'Para los Logs
|
||||
' #if RELEASE
|
||||
' logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
' #end if
|
||||
' logs.Initialize
|
||||
'
|
||||
'Agregar este Sub a "Starter"
|
||||
'
|
||||
'Return true to allow the OS default exceptions handler to handle the uncaught exception. 'Para los Logs
|
||||
'Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||
' 'wait for 500ms to allow the logs to be updated.
|
||||
' Dim jo As JavaObject
|
||||
' Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
|
||||
' logcat.LogCatStop
|
||||
' logs.Append(StackTrace)
|
||||
' Subs.revisaBD
|
||||
' Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
|
||||
' StartActivity(errorManager)
|
||||
' Return True
|
||||
'End Sub
|
||||
'******************************************************************************
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
'These global variables will be redeclared each time the activity is created.
|
||||
'These variables can only be accessed from this module.
|
||||
' Dim errorLog As SQL
|
||||
Dim c As Cursor
|
||||
' Private p_principal As Panel
|
||||
' Private l_titulo As Label
|
||||
' Private svScroll As ScrollView
|
||||
' Private etText As EditText
|
||||
' Private c_continuar As Button
|
||||
' Private p_botones As Panel
|
||||
' Private b_salir As Button
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
'Do not forget to load the layout file created with the visual designer. For example:
|
||||
' Activity.LoadLayout("errorManager")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Dim elError As String = ""
|
||||
Dim laFecha As String = ""
|
||||
' svScroll.Initialize(500dip)
|
||||
' Activity.AddView(svScroll, 0, 300, 100%x, 80%y)
|
||||
' p_principal.Height = Activity.Height
|
||||
' p_principal.Width = Activity.Width
|
||||
' svScroll.Width = Round(p_principal.Width * 0.9)
|
||||
' svScroll.Left = Round(p_principal.Width/2)-Round(svScroll.Width/2)
|
||||
' p_botones.Left = Round(p_principal.Width/2)-Round(p_botones.Width/2)
|
||||
' p_botones.Top = Activity.Height - (p_botones.Height + 80)
|
||||
' etText.Initialize("")
|
||||
' etText.TextSize = 13
|
||||
' etText.Wrap = True
|
||||
' Activity.RemoveViewAt(1)
|
||||
' svScroll.Panel.AddView(etText, 0, 0, 90%x, 80%y)
|
||||
'' etText.Width = svScroll.Width - 100
|
||||
' etText.InputType = etText.INPUT_TYPE_NONE
|
||||
' etText.Gravity = Gravity.TOP
|
||||
' etText.SingleLine = False
|
||||
' etText.Wrap = True
|
||||
' Dim lblText, edtText As StringBuilder
|
||||
' Dim lbl As Label
|
||||
' lbl.Initialize("")
|
||||
' Activity.AddView(lbl, 0, 300, 100%x, 100%y) 'ignore
|
||||
' etText.Text = ""
|
||||
' Subs.revisaBD
|
||||
c = Starter.errorLog.ExecQuery("select * from errores order by fecha desc limit 1")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
elError = c.GetString("error")
|
||||
laFecha = c.GetString("fecha")
|
||||
' etText.Text = elError
|
||||
End If
|
||||
c.Close
|
||||
|
||||
' Log("++++++" & Starter.logsStr)
|
||||
' etText.Text = etText.Text & Starter.logsStr
|
||||
' lbl.TextSize = etText.TextSize
|
||||
' lbl.Text = etText.Text
|
||||
' Dim su As StringUtils
|
||||
' Dim edheight As Int = su.MeasureMultilineTextHeight(lbl, lbl.Text)
|
||||
' lbl.RemoveView
|
||||
' etText.Height = edheight
|
||||
' svScroll.Panel.Height = edheight
|
||||
' svScroll.Height = Round(Activity.Height * 0.9)
|
||||
' Log(edheight)
|
||||
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "guardaErrores"
|
||||
cmd.Parameters = Array As Object(laFecha, Starter.devModel, laFecha, elError)
|
||||
Log($"Mandamos: ${Subs.fechaKMT(DateTime.Now)}, |${Starter.devModel}|, ${Subs.fechaKMT(DateTime.Now)}"$)
|
||||
Starter.reqManager.ExecuteCommand(cmd,"guardaErrores")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
If Job.Success = False Then
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
LogColor("JobDone: '" & Starter.reqManager.HandleJob(Job).tag & "' - Registros: " & Starter.reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = Starter.reqManager.HandleJob(Job)
|
||||
If result.Tag = "guardaErrores" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
For Each k As String In result.Columns.Keys
|
||||
Log("GuardaErrores: " & k & ": " & records(result.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End Sub
|
||||
|
||||
Private Sub c_continuar_Click
|
||||
' Subs.iniciaActividad("Principal")
|
||||
' B4XPages.ShowPage("Principal")
|
||||
End Sub
|
||||
|
||||
Private Sub b_salir_Click
|
||||
cierraActividades
|
||||
End Sub
|
||||
|
||||
Sub cierraActividades
|
||||
Log("closing activities")
|
||||
Dim jo As JavaObject
|
||||
jo.InitializeContext
|
||||
jo.RunMethod("finishAffinity", Null)
|
||||
End Sub
|
||||
Reference in New Issue
Block a user