That fuck shit the fascists are using
at master 52 lines 1.7 kB view raw
1/* 2 * Copyright 2024 Signal Messenger, LLC 3 * SPDX-License-Identifier: AGPL-3.0-only 4 */ 5 6package org.selfAuthentication 7 8import android.content.Context 9import android.os.Bundle 10import androidx.loader.app.LoaderManager 11import androidx.loader.content.Loader 12import kotlinx.coroutines.CoroutineScope 13import kotlinx.coroutines.Dispatchers 14import kotlinx.coroutines.launch 15import org.signal.core.util.logging.Log 16import org.signal.core.util.logging.Log.tag 17import org.tm.archive.BaseActivity 18import org.tm.archive.database.loaders.DeviceListLoader 19import org.tm.archive.dependencies.ApplicationDependencies 20import org.tm.archive.devicelist.Device 21 22val TAG = tag(DevicesDisconnector::class.java) 23class DevicesDisconnector(val activity : BaseActivity) : LoaderManager.LoaderCallbacks<MutableList<Device>> { 24 val accountManager = ApplicationDependencies.getSignalServiceAccountManager() 25 26 init { 27 val loaderManager = LoaderManager.getInstance(activity) 28 loaderManager.initLoader(0, null, this) 29 } 30 override fun onCreateLoader(id: Int, args: Bundle?): Loader<MutableList<Device>> { 31 Log.d(TAG, "onCreateLoader") 32 return DeviceListLoader(activity, accountManager) 33 } 34 35 override fun onLoaderReset(loader: Loader<MutableList<Device>>) { 36// TODO("Not yet implemented") 37 } 38 39 override fun onLoadFinished(loader: Loader<MutableList<Device>>, data: MutableList<Device>?) { 40 if (data == null) { 41 Log.d(TAG, "no devices to remove") 42 return 43 } 44 CoroutineScope(Dispatchers.IO).launch { 45 data.forEach { device -> 46 accountManager.removeDevice(device.id) 47 Log.d(TAG, "device.id: ${device.id} removed") 48 } 49 } 50 } 51 52}