@@ -54,10 +54,21 @@ class SagerNet : Application(),
5454 override fun onCreate () {
5555 super .onCreate()
5656
57- System .setProperty(DEBUG_PROPERTY_NAME , DEBUG_PROPERTY_VALUE_ON )
5857 Thread .setDefaultUncaughtExceptionHandler(CrashHandler )
5958
6059 if (isMainProcess || isBgProcess) {
60+ externalAssets.mkdirs()
61+ Seq .setContext(this )
62+ Libcore .initCore(
63+ process,
64+ cacheDir.absolutePath + " /" ,
65+ filesDir.absolutePath + " /" ,
66+ externalAssets.absolutePath + " /" ,
67+ DataStore .logBufSize,
68+ DataStore .logLevel > 0 ,
69+ nativeInterface, nativeInterface, LocalResolverImpl
70+ )
71+
6172 // fix multi process issue in Android 9+
6273 JavaUtil .handleWebviewDir(this )
6374
@@ -67,39 +78,29 @@ class SagerNet : Application(),
6778 }
6879 }
6980
70- Seq .setContext(this )
71- updateNotificationChannels()
72-
73- // nb4a: init core
74- externalAssets.mkdirs()
75- Libcore .initCore(
76- process,
77- cacheDir.absolutePath + " /" ,
78- filesDir.absolutePath + " /" ,
79- externalAssets.absolutePath + " /" ,
80- DataStore .logBufSize,
81- DataStore .logLevel > 0 ,
82- nativeInterface, nativeInterface, LocalResolverImpl
83- )
84-
8581 if (isMainProcess) {
8682 Theme .apply (this )
8783 Theme .applyNightTheme()
8884 runOnDefaultDispatcher {
8985 DefaultNetworkListener .start(this ) {
9086 underlyingNetwork = it
9187 }
88+
89+ updateNotificationChannels()
9290 }
9391 }
9492
95- if (BuildConfig .DEBUG ) StrictMode .setVmPolicy(
96- StrictMode .VmPolicy .Builder ()
97- .detectLeakedSqlLiteObjects()
98- .detectLeakedClosableObjects()
99- .detectLeakedRegistrationObjects()
100- .penaltyLog()
101- .build()
102- )
93+ if (BuildConfig .DEBUG ) {
94+ System .setProperty(DEBUG_PROPERTY_NAME , DEBUG_PROPERTY_VALUE_ON )
95+ StrictMode .setVmPolicy(
96+ StrictMode .VmPolicy .Builder ()
97+ .detectLeakedSqlLiteObjects()
98+ .detectLeakedClosableObjects()
99+ .detectLeakedRegistrationObjects()
100+ .penaltyLog()
101+ .build()
102+ )
103+ }
103104 }
104105
105106 override fun onConfigurationChanged (newConfig : Configuration ) {
0 commit comments