@@ -34,9 +34,15 @@ public class CoreService
3434 public static Version version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
3535 public static string ua = "Mozilla/5.0 (X11; Linux x86_64; Quest) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/23.2.0.4.49.401374055 SamsungBrowser/4.0 Chrome/104.0.5112.111 VR Safari/537.36" ;
3636 public static ActivityResultLauncher launcher ;
37+ public static bool started = false ;
3738
3839 public static async void Start ( )
3940 {
41+ if ( started )
42+ {
43+ AfterPermissionGrantStart ( ) ;
44+ return ;
45+ }
4046 // Accept every ssl certificate, may be a security risk but it's the only way to get the mod list (CoPilot)
4147 ServicePointManager . ServerCertificateValidationCallback = new RemoteCertificateValidationCallback ( delegate { return true ; } ) ;
4248 // Check permissions and request if needed
@@ -66,7 +72,7 @@ public static async void Start()
6672 // Manage storage permission
6773 Android . Net . Uri uri = Android . Net . Uri . Parse ( "package:com.ComputerElite.questappversionswitcher" ) ;
6874 Intent i = new Intent ( Settings . ActionManageAppAllFilesAccessPermission , uri ) ;
69- AndroidCore . context . StartActivity ( i ) ;
75+ launcher . Launch ( i ) ;
7076 return ;
7177 }
7278 AfterPermissionGrantStart ( ) ;
@@ -75,8 +81,6 @@ public static async void Start()
7581
7682 public static void AfterPermissionGrantStart ( )
7783 {
78-
79-
8084 //Set webbrowser settings
8185 browser . SetWebChromeClient ( new WebChromeClient ( ) ) ;
8286 browser . Settings . JavaScriptEnabled = true ;
@@ -93,26 +97,29 @@ public static void AfterPermissionGrantStart()
9397 browser . Settings . AllowFileAccess = true ;
9498 browser . SetDownloadListener ( new DownloadListener ( ) ) ;
9599 CookieManager . Instance . SetAcceptThirdPartyCookies ( browser , true ) ;
100+
101+ Logger . displayLogInConsole = true ;
96102
97103 // Create all directories and files
98- FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSDir ) ;
99- FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSBackupDir ) ;
100- FileManager . RecreateDirectoryIfExisting ( coreVars . QAVSTmpDowngradeDir ) ;
101- FileManager . RecreateDirectoryIfExisting ( coreVars . QAVSTmpPatchingDir ) ;
102- FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSPatchingFilesDir ) ;
103- FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSModAssetsDir ) ;
104- FileManager . RecreateDirectoryIfExisting ( coreVars . QAVSTmpModsDir ) ;
105-
106- Logger . SetLogFile ( coreVars . QAVSDir + "qavslog.log" ) ;
104+ if ( ! started )
105+ {
106+ FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSDir ) ;
107+ FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSBackupDir ) ;
108+ FileManager . RecreateDirectoryIfExisting ( coreVars . QAVSTmpDowngradeDir ) ;
109+ FileManager . RecreateDirectoryIfExisting ( coreVars . QAVSTmpPatchingDir ) ;
110+ FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSPatchingFilesDir ) ;
111+ FileManager . CreateDirectoryIfNotExisting ( coreVars . QAVSModAssetsDir ) ;
112+ FileManager . RecreateDirectoryIfExisting ( coreVars . QAVSTmpModsDir ) ;
113+ Logger . SetLogFile ( coreVars . QAVSDir + "qavslog.log" ) ;
114+ ExternalFilesDownloader . DownloadUrl ( "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher/main/QuestPatcher.Core/Resources/file-copy-paths.json" , coreVars . QAVSFileCopiesFile ) ;
115+ if ( ! File . Exists ( coreVars . QAVSConfigLocation ) ) File . WriteAllText ( coreVars . QAVSConfigLocation , JsonSerializer . Serialize ( coreVars ) ) ;
116+ coreVars = JsonSerializer . Deserialize < CoreVars > ( File . ReadAllText ( coreVars . QAVSConfigLocation ) ) ;
117+ QAVSModManager . Init ( ) ;
118+ CoreVars . cosmetics = Cosmetics . LoadCosmetics ( ) ;
119+ }
107120
108- // Download file copies file
109- ExternalFilesDownloader . DownloadUrl ( "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher/main/QuestPatcher.Core/Resources/file-copy-paths.json" , coreVars . QAVSFileCopiesFile ) ;
110- if ( ! File . Exists ( coreVars . QAVSConfigLocation ) ) File . WriteAllText ( coreVars . QAVSConfigLocation , JsonSerializer . Serialize ( coreVars ) ) ;
111- coreVars = JsonSerializer . Deserialize < CoreVars > ( File . ReadAllText ( coreVars . QAVSConfigLocation ) ) ;
112- CoreVars . cosmetics = Cosmetics . LoadCosmetics ( ) ;
113- Logger . displayLogInConsole = true ;
114- QAVSModManager . Init ( ) ;
115121 qAVSWebserver . Start ( ) ;
122+ started = true ;
116123 }
117124 }
118125
0 commit comments