优化:消灭任何可能导致内存泄露的代码(长期跟踪的改造点)

This commit is contained in:
pppscn 2022-08-02 15:22:50 +08:00
parent db195610d3
commit 6e2a53e54a
1 changed files with 1 additions and 9 deletions

View File

@ -1,7 +1,6 @@
package com.idormy.sms.forwarder.service package com.idormy.sms.forwarder.service
import android.content.ComponentName import android.content.ComponentName
import android.content.Context
import android.os.Build import android.os.Build
import android.service.notification.NotificationListenerService import android.service.notification.NotificationListenerService
import android.service.notification.StatusBarNotification import android.service.notification.StatusBarNotification
@ -23,16 +22,9 @@ import java.util.*
@Suppress("PrivatePropertyName", "DEPRECATION") @Suppress("PrivatePropertyName", "DEPRECATION")
class NotifyService : NotificationListenerService()/*, LifecycleOwner*/ { class NotifyService : NotificationListenerService()/*, LifecycleOwner*/ {
private lateinit var context: Context
/*private val mRegistry = LifecycleRegistry(this)*/ /*private val mRegistry = LifecycleRegistry(this)*/
private val TAG: String = "NotifyService" private val TAG: String = "NotifyService"
override fun onCreate() {
super.onCreate()
context = applicationContext
}
override fun onListenerConnected() { override fun onListenerConnected() {
//super.onListenerConnected() //super.onListenerConnected()
// Check if Notification Listener Permission is allowed // Check if Notification Listener Permission is allowed
@ -97,7 +89,7 @@ class NotifyService : NotificationListenerService()/*, LifecycleOwner*/ {
) )
) )
.build() .build()
WorkManager.getInstance(context).enqueue(request) WorkManager.getInstance(applicationContext).enqueue(request)
//TODO收不到返回信息自动消除待解决 //TODO收不到返回信息自动消除待解决
/*WorkManager.getInstance(context).getWorkInfoByIdLiveData(request.id) /*WorkManager.getInstance(context).getWorkInfoByIdLiveData(request.id)