mirror of
https://github.com/KeymonSoft/ReplyAutoV1---WIP.git
synced 2026-04-20 14:19:22 +00:00
Commit iniical.
This commit is contained in:
102
B4A/Starter.bas
Normal file
102
B4A/Starter.bas
Normal file
@@ -0,0 +1,102 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=9.85
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: False
|
||||
#ExcludeFromLibrary: True
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
Public rp As RuntimePermissions
|
||||
Dim reqManager As DBRequestManager 'ignore
|
||||
Dim cmd As DBCommand 'ignore
|
||||
' Dim DBRServer As String = "http://10.0.0.205:1782"
|
||||
Dim DBRServer As String = "http://keymon.lat:1782"
|
||||
' Dim DBRServer As String = "http://192.168.137.5:1782"
|
||||
Dim ultimoServidorConectado As String = ""
|
||||
' Dim DBRChecked As Boolean = False
|
||||
' Dim pruebaPaso As Int = 0
|
||||
Dim desbloqueoUsrs As Map
|
||||
' Dim ultimaReglaCumplida As Map
|
||||
'Para los Logs
|
||||
Dim logs As StringBuilder
|
||||
Private logcat As LogCat
|
||||
Dim ruta As String
|
||||
Dim starterStatus, nsStatus As Map
|
||||
Dim notisMap2 As Map
|
||||
Dim reglasDB, historicoDB, colaNotifs, waDB As SQL
|
||||
Dim waPackage As String = "com.gbwhatsapp"
|
||||
Dim waApp As String = "GBWhatsApp"
|
||||
Dim waDir As String = $"/sdcard/Android/media/${waPackage}/${waApp}"$
|
||||
Dim Logger As Boolean = True
|
||||
Dim showLogs As Boolean = False
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
'This is the program entry point.
|
||||
'This is a good place to load resources that are not specific to a single activity.
|
||||
'Para los Logs
|
||||
#if RELEASE
|
||||
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
Logger = False
|
||||
#end if
|
||||
logs.Initialize
|
||||
' Logger = True
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
desbloqueoUsrs.Initialize
|
||||
Subs.revisaBD
|
||||
ruta = File.DirInternal
|
||||
' If Not(reglasDB.IsInitialized) Then
|
||||
reglasDB.Initialize(ruta, "bow.db", True)
|
||||
colaNotifs.Initialize(ruta, "colaNotifs.db", True)
|
||||
' End If
|
||||
If Logger Then LogColor(ruta, Colors.Red)
|
||||
notisMap2.Initialize
|
||||
starterStatus.Initialize
|
||||
If NotificationService.starterStatus.IsInitialized Then starterStatus = NotificationService.starterStatus
|
||||
starterStatus.Put(Subs.fechaKMT(DateTime.now),"inicia")
|
||||
If NotificationService.nsStatus.IsInitialized Then
|
||||
nsStatus.Initialize
|
||||
nsStatus = NotificationService.nsStatus
|
||||
Else If Not(NotificationService.nsStatus.IsInitialized) And nsStatus.IsInitialized Then
|
||||
NotificationService.nsStatus.Initialize
|
||||
NotificationService.nsStatus = nsStatus
|
||||
Else
|
||||
nsStatus.Initialize
|
||||
NotificationService.nsStatus.Initialize
|
||||
nsStatus.Put(Subs.fechaKMT(DateTime.now),"inicia")
|
||||
NotificationService.nsStatus.Put(Subs.fechaKMT(DateTime.now),"inicia")
|
||||
End If
|
||||
If Logger Then Log($"starterStatus=${starterStatus}"$)
|
||||
End Sub
|
||||
|
||||
Sub Service_TaskRemoved
|
||||
'This event will be raised when the user removes the app from the recent apps list.
|
||||
End Sub
|
||||
|
||||
'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.Initialize
|
||||
logs.Append("Ver " & Application.VersionName & CRLF)
|
||||
logs.Append(StackTrace)
|
||||
Subs.revisaBD
|
||||
Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
|
||||
' StartActivity(errorManager) 'errorManager despliega una pantalla con el error y manda el mensaje de error al servidor.
|
||||
Return True
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
starterStatus.put(Subs.fechaKMT(DateTime.now),"termina")
|
||||
End Sub
|
||||
Reference in New Issue
Block a user