mirror of
https://github.com/cheveguerra/FLP_2.0.git
synced 2026-04-17 19:36:42 +00:00
- Se paso la logica y restricciones de Tracker.FLP_LocationChanged a Subs.mandaLoc2.
- Se puso que con cualquier notificacion revise si puede mandar la ubicacion. - Se puso que cuando se solicite la ubicacion con FirebaseMessaging, se mande tambien a PUSH_INFO.
This commit is contained in:
12
FLP_2.0.b4a
12
FLP_2.0.b4a
@@ -22,7 +22,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="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>)
|
||||
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="33"/>~\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" android:exported="true">~\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" android:exported="true" />~\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" android:exported="true">~\n~ <intent-filter><action android:name="android.service.notification.NotificationListenerService" android:exported="true" /></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" android:exported="true"/>~\n~</intent-filter>)
|
||||
Module1=DBRequestManager
|
||||
Module2=errorManager
|
||||
Module3=FirebaseMessaging
|
||||
@@ -40,7 +40,7 @@ Version=12.8
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: FLP 2.0
|
||||
#VersionCode: 1
|
||||
#VersionName: 4.04.23
|
||||
#VersionName: 4.05.10
|
||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||
#SupportedOrientations: unspecified
|
||||
#CanInstallToExternalStorage: False
|
||||
@@ -133,18 +133,18 @@ End Sub
|
||||
|
||||
Sub b_pong_Click
|
||||
CallSubDelayed(Tracker, "StartFLP")
|
||||
If laUbicacion.IsInitialized Then Subs.mandaLocAServer(laUbicacion, Starter.devModel.Trim)
|
||||
If Starter.UUC.IsInitialized Then Subs.mandaLocAServer(Starter.UUC, Starter.devModel.Trim)
|
||||
Dim params As Map = CreateMap("topic": FirebaseMessaging.Sprvsr,"title":"Prueba Trckr", "body":"Prueba Trckr", "d":Starter.devModel, "t":"pong")
|
||||
CallSubDelayed2(FirebaseMessaging, "SendMessage",params)
|
||||
If Starter.logger Then Log("Start wifi scan")
|
||||
wifiS.startscan("WiFi", True)
|
||||
Wait For WiFi_ScanDone (Results() As String, Count As Int)
|
||||
Wait For WiFi_ScanDone (Results() As String, Count As Int)
|
||||
End Sub
|
||||
|
||||
Sub b_pong_LongClick
|
||||
' copiaDB
|
||||
CallSubDelayed(Tracker, "StartFLP")
|
||||
If laUbicacion.IsInitialized Then Subs.mandaLocAServer(laUbicacion, Starter.devModel.Trim)
|
||||
If Starter.UUC.IsInitialized Then Subs.mandaLocAServer(Starter.UUC, Starter.devModel.Trim)
|
||||
Dim params As Map = CreateMap("topic": FirebaseMessaging.Sprvsr,"title":"Prueba Trckr", "body":l_coords.Text, "d":Starter.devModel, "t":"au")
|
||||
CallSubDelayed2(FirebaseMessaging, "SendMessage",params)
|
||||
If Starter.logger Then Log("Start wifi scan")
|
||||
@@ -187,7 +187,7 @@ End Sub
|
||||
Sub chkPermisosEstadoTelefono
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
|
||||
wait for Activity_PermissionResult(permission As String, result As Boolean)
|
||||
if starter.logger then Log("READ_PHONE_STATE: " & result)
|
||||
If Starter.logger Then Log("READ_PHONE_STATE: " & result)
|
||||
End Sub
|
||||
|
||||
Sub getSSID
|
||||
|
||||
@@ -21,13 +21,13 @@ ModuleBreakpoints9=
|
||||
ModuleClosedNodes0=
|
||||
ModuleClosedNodes1=
|
||||
ModuleClosedNodes2=
|
||||
ModuleClosedNodes3=
|
||||
ModuleClosedNodes3=1,2,4
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=
|
||||
ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=
|
||||
ModuleClosedNodes8=
|
||||
ModuleClosedNodes9=
|
||||
NavigationStack=Main,chkPermisosEstadoTelefono,150,0,FirebaseMessaging,fm_MessageArrived,94,0,FirebaseMessaging,SendMessage,127,0,FirebaseMessaging,mandaLocFM,150,0,Subs,mandaLoc2,197,0,Subs,borraArribaDeXXXBitacora,226,0,Starter,Service_Start,54,0,Subs,revisaYmandaUUC,254,2,NotificationService,NotiMon_NotificationPosted,69,0,Tracker,flp_LocationChanged,150,6
|
||||
ModuleClosedNodes9=2,3,4,5,6,7,8,9,10,11,12
|
||||
NavigationStack=Tracker,StopFLP,146,0,Subs,traeVar,332,6,Subs,actualizaVar,328,2,Subs,traeUltimaUbicacionGuardada,256,0,FirebaseMessaging,SubscribeToTopics,58,0,FirebaseMessaging,fm_MessageArrived,85,5,Subs,Process_Globals,15,3,Tracker,flp_LocationChanged,178,6,Subs,mandaLoc2,212,6,Main,getSSID,157,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=7,3,9,4,8,5,6,2
|
||||
|
||||
@@ -54,7 +54,7 @@ Sub Service_Create
|
||||
End Sub
|
||||
|
||||
Public Sub SubscribeToTopics
|
||||
' fm.SubscribeToTopic("Trckr") 'Global (you can subscribe to more topics)
|
||||
fm.SubscribeToTopic("Trckr") 'Global (you can subscribe to more topics)
|
||||
fm.SubscribeToTopic("Trckr") 'Tracker Global
|
||||
If Starter.logger Then Log("Subscrito a tracker global")
|
||||
fm.SubscribeToTopic("Trckr-ML") 'Global (you can subscribe to more topics)
|
||||
@@ -63,6 +63,9 @@ Public Sub SubscribeToTopics
|
||||
If Starter.logger Then Log("Subscrito a "&Starter.devModel)
|
||||
If Starter.logger Then Log(fm.token)
|
||||
fm.UnsubscribeFromTopic("Sprvsr") 'Unsubscribe from topic
|
||||
' fm.UnsubscribeFromTopic("Trckr") 'Unsubscribe from topic
|
||||
' fm.UnsubscribeFromTopic("Trckr-ML") 'Unsubscribe from topic
|
||||
' fm.UnsubscribeFromTopic(Starter.devModel) 'Unsubscribe from topic
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
@@ -75,6 +78,7 @@ End Sub
|
||||
|
||||
Sub fm_MessageArrived (Message As RemoteMessage)
|
||||
If Starter.logger Then Log("Message arrived")
|
||||
If Starter.logger Then Log($"Message from: ${Message.From}"$)
|
||||
If Starter.logger Then Log($"Message data: ${Message.GetData}"$)
|
||||
Subs.getPhnId
|
||||
Subs.getSSID
|
||||
@@ -83,9 +87,11 @@ Sub fm_MessageArrived (Message As RemoteMessage)
|
||||
If tipos.IndexOf("pu") <> -1 Or tipos.IndexOf("au") <> -1 Then 'Si es una peticion de ubicacion
|
||||
If Starter.logger Then Log("Es una peticion de ubicacion")
|
||||
If Starter.logger Then Log($"UUC: ${Starter.UUC.Latitude},${Starter.UUC.Longitude}"$)
|
||||
If Starter.UUC.Latitude <> 0.0 Then
|
||||
mandaLocFM(Starter.UUC)
|
||||
If Starter.logger Then LogColor($"Mandamos UUC: ${Starter.UUC.Latitude},${Starter.UUC.Longitude},${Subs.formatoFecha(Starter.UUC.Time)}"$, Colors.Magenta)
|
||||
If Starter.UUC.IsInitialized And Starter.UUC.Latitude <> 0.0 Then
|
||||
' mandaLocFM(Starter.UUC)
|
||||
Subs.actualizaVar("solicitudFM", 1)
|
||||
If Starter.logger Then LogColor($"Llamamos mandaLoc2: ${Starter.UUC.Latitude},${Starter.UUC.Longitude},${Subs.formatoFecha(Starter.UUC.Time)}"$, Colors.Magenta)
|
||||
Subs.mandaLoc2(Starter.UUC, Starter.devModel)
|
||||
End If
|
||||
locRequest="Activa"
|
||||
If Starter.logger Then Log("Llamamos StartFLP")
|
||||
|
||||
@@ -76,23 +76,24 @@ Sub NotiMon_NotificationPosted (SBN As StatusBarNotification)
|
||||
Subs.revisaYmandaUUC
|
||||
If Starter.logger Then LogColor(SBN.PackageName & " - " & SBN.Message, Colors.blue)
|
||||
' Log("-= Notificacion recibida =-")
|
||||
If SBN.PackageName = "com.whatsapp" Then
|
||||
' If SBN.PackageName = "com.whatsapp" Then
|
||||
' If logger Then LogColor(SBN.PackageName, Colors.Red)
|
||||
' If logger Then LogColor("isGroupWA2: "&isGroupWA(SBN),Colors.Magenta)
|
||||
' If logger Then LogColor("isPersonWA: "&isPersonWA(SBN),Colors.Magenta)
|
||||
' If logger Then Log($"getGroupName: |${getGroupName(SBN.Title)}|"$)
|
||||
|
||||
' Si recibimos un mensaje con la palabra "donde", "Donde" o "bien", entonces mandamos la última ubicación conocida.
|
||||
If SBN.Message.Contains("donde") Or SBN.Message.Contains("Donde") Or SBN.Message.Contains("bien") Then 'Si el mensaje contiene "#NS" y tiene un segundo parametro ...
|
||||
If esMensajeWAValido(SBN) Then
|
||||
Subs.bitacora($"Recibimos notificación, pedimos actualización y mandamos UUC."$)
|
||||
Tracker.flp.RequestLocationUpdates(Tracker.locReqSmall)
|
||||
' If SBN.Message.Contains("donde") Or SBN.Message.Contains("Donde") Or SBN.Message.Contains("bien") Then 'Si el mensaje contiene "#NS" y tiene un segundo parametro ...
|
||||
' If esMensajeWAValido(SBN) Then
|
||||
' Subs.bitacora($"Recibimos notificación, pedimos actualización y mandamos UUC."$)
|
||||
If Starter.logger Then LogColor($"Recibimos notificación, pedimos actualización y mandamos UUC."$, Colors.Green)
|
||||
If Tracker.flp.IsInitialized Then Tracker.flp.RequestLocationUpdates(Tracker.locReqSmall)
|
||||
Sleep(2000)
|
||||
Private ultimaLoc As Location = Subs.traeUltimaUbicacionGuardada
|
||||
Subs.mandaLoc2(ultimaLoc, Starter.devModel)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
'Regresa verdadero si el mensaje de whatsapp es un mensaje valido.
|
||||
|
||||
@@ -22,7 +22,6 @@ Sub Process_Globals
|
||||
Dim run As Int = 0 'ignore
|
||||
Dim devModel As String
|
||||
Dim lastLocUpdate As String = 0
|
||||
Dim logger As Boolean = True
|
||||
Dim errorLog As SQL
|
||||
Dim PE As PhoneEvents
|
||||
Dim PhId As PhoneId
|
||||
@@ -31,7 +30,9 @@ Sub Process_Globals
|
||||
Dim isIncoming As Boolean
|
||||
Dim lastState As String = "IDLE"
|
||||
Dim savedNumber As String
|
||||
|
||||
Dim locAntTime As String = "0"
|
||||
|
||||
Dim logger As Boolean = True
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
@@ -39,7 +40,6 @@ 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
|
||||
|
||||
51
Subs.bas
51
Subs.bas
@@ -16,6 +16,8 @@ Sub Process_Globals
|
||||
Dim gps_hist As SQL
|
||||
Dim wifi As MLwifi
|
||||
Dim ssid As String
|
||||
Dim locAntTime As String = "0"
|
||||
Dim solicitudFM As Int = 0
|
||||
End Sub
|
||||
|
||||
Sub getPhnId 'Pone el valor de phn.Model en la variable global "devModel"
|
||||
@@ -136,6 +138,7 @@ Sub revisaBD
|
||||
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)")
|
||||
gps_hist.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_VARIABLES(NOMBRE TEXT, VALOR TEXT)")
|
||||
End Sub
|
||||
|
||||
Sub getSSID
|
||||
@@ -202,10 +205,32 @@ End Sub
|
||||
|
||||
'Manda la ubicacion al servidor de BD y a FirebaseMessage.
|
||||
Sub mandaLoc2(loc As Location, id As String) 'ignore
|
||||
mandaLocAServer(loc, id)
|
||||
FirebaseMessaging.locRequest = "Activa"
|
||||
CallSubDelayed2(FirebaseMessaging, "mandaLocFM", loc)
|
||||
guardaInfoEnBD(loc)'Escribimos coordenadas y fecha a una bd
|
||||
Private minsTranscurridosLoc As String = ticksAMins(loc.time - traeVar("locAntTime", 0)) 'Minutos transcurridos desde la ultima ubicacion ACTUALIZADA.
|
||||
Private minsTranscurridos As String = ticksAMins(DateTime.Now - traeUltimaUbicacionGuardada.Time) 'Minutos transcurridos desde la ultima ubicacion guardada.
|
||||
Dim el_texto As String = ""
|
||||
' If Starter.logger Then
|
||||
LogColor("Guardada: " & minsTranscurridos & " mins., Actualizada: " & minsTranscurridosLoc & " mins.", Colors.green)
|
||||
If traeVar("solicitudFM", 0) = 1 Or minsTranscurridos >= 3 Or minsTranscurridosLoc >= 3 Then ' Para que no mande mensajes constantes, minimo 1 minuto entre mensajes.
|
||||
' CallSubDelayed(Tracker,"CreateLocationRequest")
|
||||
Tracker.flp.RequestLocationUpdates(Tracker.locReqNormal)
|
||||
'Solo mandamos la ubicacion si la precision es dentro de XX mts
|
||||
el_texto = $"LocChange - Coords NO enviadas (Acc:${loc.Accuracy})."$
|
||||
If loc.Accuracy < 50 Then
|
||||
' If Starter.logger Then
|
||||
LogColor("Guardamos y enviamos ubicacion.", Colors.green)
|
||||
mandaLocAServer(loc, id)
|
||||
FirebaseMessaging.locRequest = "Activa"
|
||||
CallSubDelayed2(FirebaseMessaging, "mandaLocFM", loc)
|
||||
guardaInfoEnBD(loc)'Escribimos coordenadas y fecha a una bd
|
||||
el_texto = $"LocChange - Coords enviadas (Acc:${loc.Accuracy})."$
|
||||
End If
|
||||
bitacora($"${el_texto}"$)
|
||||
actualizaVar("solicitudFM", 0)
|
||||
' ToastMessageShow("LocChanged MORE than a min.", False)
|
||||
Else
|
||||
' ToastMessageShow("Locatin changed but less than a min!.", False)
|
||||
End If
|
||||
actualizaVar("locAntTime", loc.time)
|
||||
End Sub
|
||||
|
||||
Sub ConvertMillisecondsToString(t As Long) As String 'ignore
|
||||
@@ -239,10 +264,10 @@ End Sub
|
||||
'Regresa la ultima ubicacion guardada o una ubicacion sin inicializar si no encuentra nada.
|
||||
Sub traeUltimaUbicacionGuardada As Location 'ignore
|
||||
Private loc As Location
|
||||
loc.Initialize
|
||||
Private c As Cursor = gps_hist.ExecQuery($"select FECHA, LAT, LON, ACC, TIME from RUTA_GPS order by fecha desc limit 1"$)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
loc.Initialize
|
||||
loc.Latitude = c.GetString("LAT")
|
||||
loc.Longitude = c.GetString("LON")
|
||||
loc.Accuracy = 0
|
||||
@@ -307,3 +332,19 @@ Sub revisaYmandaUUC
|
||||
' LogColor($"Ultima loc: ${Subs.fechaNormal(ultimaLoc.Time)}"$, Colors.blue)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub actualizaVar(nombre As String, valor As String)
|
||||
gps_hist.ExecNonQuery($"delete from CAT_VARIABLES where NOMBRE = '${nombre}'"$)
|
||||
gps_hist.ExecNonQuery($"insert into CAT_VARIABLES (NOMBRE, VALOR) values ('${nombre}', '${valor}')"$)
|
||||
End Sub
|
||||
|
||||
'Regresa el valor desde CAT_VARIABLES o del default espacificado en DEFAULT
|
||||
Sub traeVar(nombre As String, default As String) As String
|
||||
Private v As String = default
|
||||
Private c As Cursor = gps_hist.ExecQuery2("select VALOR from CAT_VARIABLES WHERE NOMBRE = ?", Array As String (nombre))
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
v = c.GetString("VALOR")
|
||||
End If
|
||||
Return v
|
||||
End Sub
|
||||
63
Tracker.bas
63
Tracker.bas
@@ -40,7 +40,7 @@ Sub Process_Globals
|
||||
Private flpStarted As Boolean
|
||||
Dim minAccuracy As Int = 50
|
||||
Dim killerCalled As Int = 0
|
||||
Dim locReqSmall As LocationRequest
|
||||
Dim locReqSmall, locReqNormal As LocationRequest
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
@@ -50,12 +50,13 @@ Sub Service_Create
|
||||
flp.Connect
|
||||
lock.PartialLock
|
||||
StartFLP
|
||||
If Starter.logger Then Log("FLP initialized")
|
||||
' If Starter.logger Then Log("FLP initialized")
|
||||
Subs.bitacora($"Iniciamos Tracker"$)
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
locReqSmall = CreateLocationRequest2(1000, 0) 'ignore
|
||||
locReqNormal = CreateLocationRequest2(30000, 30) 'ignore
|
||||
Service.StopAutomaticForeground
|
||||
Service.StartForeground(nid, Subs.CreateNotification("..."))
|
||||
Track
|
||||
@@ -81,7 +82,7 @@ Sub flpReConnect
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuccess
|
||||
If Starter.logger Then Log("FLP - Connected to location provider")
|
||||
' If Starter.logger Then Log("FLP - Connected to location provider")
|
||||
Subs.bitacora("FLP - Connection Success")
|
||||
End Sub
|
||||
|
||||
@@ -106,7 +107,7 @@ Public Sub StartFLP
|
||||
Private cont As Int = 0
|
||||
Do While flp.IsConnected = False
|
||||
Sleep(500)
|
||||
If Starter.logger Then Log($"FLP Sleeping - ${cont}"$)
|
||||
' If Starter.logger Then Log($"FLP Sleeping - ${cont}"$)
|
||||
Subs.bitacora($"Sleeping - ${cont}"$)
|
||||
cont = cont + 1
|
||||
If cont > 70 Then
|
||||
@@ -151,31 +152,37 @@ Public Sub StopFLP
|
||||
End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
If Starter.logger Then 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.
|
||||
If Starter.logger Then 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
|
||||
If Starter.logger Then LogColor("FLP_LocationChanged", Colors.Red)
|
||||
If Starter.logger Then Log(Location1.Accuracy&" - "&Location1.AccuracyValid)
|
||||
If minsTranscurridos > 1 Then ' Para que no mande mensajes constantes, minimo 1 minuto entre mensajes.
|
||||
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 LogColor("FLP_LocationChanged", Colors.Red)
|
||||
If Starter.logger Then LogColor($"FLP_LocationChanged - Acc: ${Location1.Accuracy}"$, Colors.Red)
|
||||
Private vel As String = (Location1.Speed * 60 * 60) / 1000 ' Kms x hora de ultima ubicacion.
|
||||
' If Starter.logger Then Log((Location1.time & " - " & Starter.locAntTime))
|
||||
If Starter.logger Then Log(((Location1.time - Subs.traeVar("locAntTime", 0)) / 1000) & " segs")
|
||||
' Private minsTranscurridosLoc As String = Subs.ticksAMins(Location1.time - Starter.locAntTime) 'Minutos transcurridos desde la ultima ubicacion ACTUALIZADA.
|
||||
' Private minsTranscurridos As String = Subs.ticksAMins(DateTime.Now - Subs.traeUltimaUbicacionGuardada.Time) 'Minutos transcurridos desde la ultima ubicacion guardada.
|
||||
' If Starter.logger Then LogColor(">>>>>>>> Guardada: " & minsTranscurridos & " mins., Actualizada: " & minsTranscurridosLoc & " mins.", Colors.red)
|
||||
' If Not(IsPaused(Main)) Then
|
||||
' Main.laUbicacion = Location1 ' Actualizamos la etiqueta de ubicacion en la pantalla principal.
|
||||
' If Starter.logger Then Log("Main.laubicacion actializada")
|
||||
' End If
|
||||
' Dim el_texto As String = ""
|
||||
' If Starter.logger Then Log(Location1.Accuracy&" - "&Starter.UUC.AccuracyValid)
|
||||
' If minsTranscurridosLoc > 1 Or minsTranscurridos >= 15 Then ' Para que no mande mensajes constantes, minimo 1 minuto entre mensajes.
|
||||
' 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
|
||||
' If Starter.logger Then LogColor("Guardamos y enviamos ubicacion.", Colors.green)
|
||||
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
|
||||
' Subs.actualizaVar("locAntTime", Location1.time)
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuspended(SuspendedCause1 As Int)
|
||||
|
||||
Reference in New Issue
Block a user