@@ -75,14 +75,14 @@ import android.util.Log
7575class IDEApplication : TermuxApplication () {
7676
7777 private var uncaughtExceptionHandler: UncaughtExceptionHandler ? = null
78- // private var ideLogcatReader: IDELogcatReader? = null
78+ private var ideLogcatReader: IDELogcatReader ? = null
7979
8080 init {
8181 if (! VMUtils .isJvm()) {
8282 TreeSitter .loadLibrary()
8383 }
8484
85- // RecyclableObjectPool.DEBUG = BuildConfig.DEBUG
85+ RecyclableObjectPool .DEBUG = BuildConfig .DEBUG
8686 }
8787
8888 override fun attachBaseContext (base : Context ) {
@@ -99,14 +99,14 @@ class IDEApplication : TermuxApplication() {
9999
100100 super .onCreate()
101101
102- // if (BuildConfig.DEBUG) {
103- // StrictMode.setVmPolicy(
104- // StrictMode.VmPolicy.Builder(StrictMode.getVmPolicy()).penaltyLog().detectAll().build()
105- // )
106- // if (DevOpsPreferences.dumpLogs) {
107- // startLogcatReader()
108- // }
109- // }
102+ if (BuildConfig .DEBUG ) {
103+ StrictMode .setVmPolicy(
104+ StrictMode .VmPolicy .Builder (StrictMode .getVmPolicy()).penaltyLog().detectAll().build()
105+ )
106+ if (DevOpsPreferences .dumpLogs) {
107+ startLogcatReader()
108+ }
109+ }
110110
111111 EventBus .builder()
112112 .addIndex(AppEventsIndex ())
@@ -142,15 +142,15 @@ class IDEApplication : TermuxApplication() {
142142 try {
143143 startActivity(intent)
144144 } catch (th: Throwable ) {
145- // log.error("Unable to start activity to show changelog", th)
145+ log.error(" Unable to start activity to show changelog" , th)
146146 flashError(" Unable to start activity" )
147147 }
148148 }
149149
150150 fun reportStatsIfNecessary () {
151151
152152 if (! StatPreferences .statOptIn) {
153- // log.info("Stat collection is disabled.")
153+ log.info(" Stat collection is disabled." )
154154 return
155155 }
156156
@@ -162,7 +162,7 @@ class IDEApplication : TermuxApplication() {
162162
163163 val workManager = WorkManager .getInstance(this )
164164
165- // log.info("reportStatsIfNecessary: Enqueuing StatUploadWorker...")
165+ log.info(" reportStatsIfNecessary: Enqueuing StatUploadWorker..." )
166166 val operation = workManager.enqueueUniquePeriodicWork(
167167 StatUploadWorker .WORKER_WORK_NAME ,
168168 ExistingPeriodicWorkPolicy .UPDATE , request
@@ -171,7 +171,7 @@ class IDEApplication : TermuxApplication() {
171171 operation.state.observeForever(object : Observer <Operation .State > {
172172 override fun onChanged (value : Operation .State ) {
173173 operation.state.removeObserver(this )
174- // log.debug("reportStatsIfNecessary: WorkManager enqueue result: {}", value)
174+ log.debug(" reportStatsIfNecessary: WorkManager enqueue result: {}" , value)
175175 }
176176 })
177177 }
@@ -194,7 +194,7 @@ class IDEApplication : TermuxApplication() {
194194 }
195195
196196 private fun handleCrash (thread : Thread , th : Throwable ) {
197- // writeException(th)
197+ writeException(th)
198198
199199 try {
200200
@@ -213,38 +213,38 @@ class IDEApplication : TermuxApplication() {
213213 }
214214 }
215215
216- // private fun cancelStatUploadWorker() {
217- // log.info("Opted-out of stat collection. Cancelling StatUploadWorker if enqueued...")
218- // val operation = WorkManager.getInstance(this)
219- // .cancelUniqueWork(StatUploadWorker.WORKER_WORK_NAME)
220- // operation.state.observeForever(object : Observer<Operation.State> {
221- // override fun onChanged(value: Operation.State) {
222- // operation.state.removeObserver(this)
223- // log.info("StatUploadWorker: Cancellation result state: {}", value)
224- // }
225- // })
226- // }
227-
228- // private fun startLogcatReader() {
229- // if (ideLogcatReader != null) {
230- // // already started
231- // return
232- // }
233-
234- // log.info("Starting logcat reader...")
235- // ideLogcatReader = IDELogcatReader().also { it.start() }
236- // }
237-
238- // private fun stopLogcatReader() {
239- // log.info("Stopping logcat reader...")
240- // ideLogcatReader?.stop()
241- // ideLogcatReader = null
242- // }
216+ private fun cancelStatUploadWorker () {
217+ log.info(" Opted-out of stat collection. Cancelling StatUploadWorker if enqueued..." )
218+ val operation = WorkManager .getInstance(this )
219+ .cancelUniqueWork(StatUploadWorker .WORKER_WORK_NAME )
220+ operation.state.observeForever(object : Observer <Operation .State > {
221+ override fun onChanged (value : Operation .State ) {
222+ operation.state.removeObserver(this )
223+ log.info(" StatUploadWorker: Cancellation result state: {}" , value)
224+ }
225+ })
226+ }
227+
228+ private fun startLogcatReader () {
229+ if (ideLogcatReader != null ) {
230+ // already started
231+ return
232+ }
233+
234+ log.info(" Starting logcat reader..." )
235+ ideLogcatReader = IDELogcatReader ().also { it.start() }
236+ }
237+
238+ private fun stopLogcatReader () {
239+ log.info(" Stopping logcat reader..." )
240+ ideLogcatReader?.stop()
241+ ideLogcatReader = null
242+ }
243243
244244
245245 companion object {
246246
247- // private val log = LoggerFactory.getLogger(IDEApplication::class.java)
247+ private val log = LoggerFactory .getLogger(IDEApplication ::class .java)
248248
249249 @JvmStatic
250250 lateinit var instance: IDEApplication
0 commit comments