mSettingsCache is only assigned in onListenerConnected(), but onListenerDisconnected() unregisters from it unconditionally. The framework calls onListenerDisconnected() from NotificationListenerService.onDestroy(), so a service that is destroyed before it ever connects dereferences null and kills the process. Guard the unregister; the connected path is unchanged. Co-authored-by: caizhixing <17589399+caizhixing03@user.noreply.gitee.com>