Loading app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt +14 −8 Original line number Diff line number Diff line Loading @@ -20,10 +20,11 @@ package foundation.e.apps.install.splitinstall import android.content.Context import androidx.core.content.pm.PackageInfoCompat import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.ISplitInstallService import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.login.AuthenticatorRepository import foundation.e.apps.data.login.exceptions.GPlayLoginException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading @@ -35,7 +36,7 @@ class SplitInstallBinder( private val coroutineScope: CoroutineScope, val applicationRepository: ApplicationRepository, val downloadManager: DownloadManager, val authData: AuthData?, val authenticatorRepository: AuthenticatorRepository, private var splitInstallSystemService: foundation.e.splitinstall.ISplitInstallService? ) : ISplitInstallService.Stub() { Loading @@ -43,17 +44,22 @@ class SplitInstallBinder( companion object { const val TAG = "SplitInstallerBinder" const val AUTH_DATA_ERROR_MESSAGE = "Could not get auth data" } override fun installSplitModule(packageName: String, moduleName: String) { if (authData == null) { Timber.i("No authentication data. Could not install on demand module") try { if (authenticatorRepository.gplayAuth == null) { Timber.w(AUTH_DATA_ERROR_MESSAGE) return } coroutineScope.launch { downloadModule(packageName, moduleName) } } catch (exception: GPlayLoginException) { Timber.w("$AUTH_DATA_ERROR_MESSAGE $exception") } } fun setService(service: foundation.e.splitinstall.ISplitInstallService) { Loading app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallService.kt +3 −14 Original line number Diff line number Diff line Loading @@ -24,15 +24,14 @@ import android.content.ServiceConnection import android.os.IBinder import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import com.aurora.gplayapi.data.models.AuthData import com.google.gson.Gson import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.login.AuthenticatorRepository import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.splitinstall.ISplitInstallService import foundation.e.splitinstall.SplitInstall import kotlinx.coroutines.launch import javax.inject.Inject @AndroidEntryPoint Loading @@ -46,8 +45,8 @@ class SplitInstallService : LifecycleService() { @Inject lateinit var applicationRepository: ApplicationRepository @Inject lateinit var downloadManager: DownloadManager @Inject lateinit var gson: Gson @Inject lateinit var authenticatorRepository: AuthenticatorRepository private lateinit var binder: SplitInstallBinder private var authData: AuthData? = null private var splitInstallSystemService: ISplitInstallService? = null private val serviceConnection = object : ServiceConnection { Loading @@ -68,10 +67,6 @@ class SplitInstallService : LifecycleService() { component = SplitInstall.SPLIT_INSTALL_SYSTEM_SERVICE } bindService(intent, serviceConnection, BIND_AUTO_CREATE) lifecycleScope.launch { fetchAuthData() } } override fun onDestroy() { Loading @@ -81,12 +76,6 @@ class SplitInstallService : LifecycleService() { super.onDestroy() } private suspend fun fetchAuthData() { appLoungeDataStore.authData.collect { authData = gson.fromJson(it, AuthData::class.java) } } override fun onBind(intent: Intent): IBinder { super.onBind(intent) binder = SplitInstallBinder( Loading @@ -94,7 +83,7 @@ class SplitInstallService : LifecycleService() { lifecycleScope, applicationRepository, downloadManager, authData, authenticatorRepository, splitInstallSystemService ) return binder Loading Loading
app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt +14 −8 Original line number Diff line number Diff line Loading @@ -20,10 +20,11 @@ package foundation.e.apps.install.splitinstall import android.content.Context import androidx.core.content.pm.PackageInfoCompat import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.ISplitInstallService import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.login.AuthenticatorRepository import foundation.e.apps.data.login.exceptions.GPlayLoginException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch Loading @@ -35,7 +36,7 @@ class SplitInstallBinder( private val coroutineScope: CoroutineScope, val applicationRepository: ApplicationRepository, val downloadManager: DownloadManager, val authData: AuthData?, val authenticatorRepository: AuthenticatorRepository, private var splitInstallSystemService: foundation.e.splitinstall.ISplitInstallService? ) : ISplitInstallService.Stub() { Loading @@ -43,17 +44,22 @@ class SplitInstallBinder( companion object { const val TAG = "SplitInstallerBinder" const val AUTH_DATA_ERROR_MESSAGE = "Could not get auth data" } override fun installSplitModule(packageName: String, moduleName: String) { if (authData == null) { Timber.i("No authentication data. Could not install on demand module") try { if (authenticatorRepository.gplayAuth == null) { Timber.w(AUTH_DATA_ERROR_MESSAGE) return } coroutineScope.launch { downloadModule(packageName, moduleName) } } catch (exception: GPlayLoginException) { Timber.w("$AUTH_DATA_ERROR_MESSAGE $exception") } } fun setService(service: foundation.e.splitinstall.ISplitInstallService) { Loading
app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallService.kt +3 −14 Original line number Diff line number Diff line Loading @@ -24,15 +24,14 @@ import android.content.ServiceConnection import android.os.IBinder import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import com.aurora.gplayapi.data.models.AuthData import com.google.gson.Gson import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.login.AuthenticatorRepository import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.splitinstall.ISplitInstallService import foundation.e.splitinstall.SplitInstall import kotlinx.coroutines.launch import javax.inject.Inject @AndroidEntryPoint Loading @@ -46,8 +45,8 @@ class SplitInstallService : LifecycleService() { @Inject lateinit var applicationRepository: ApplicationRepository @Inject lateinit var downloadManager: DownloadManager @Inject lateinit var gson: Gson @Inject lateinit var authenticatorRepository: AuthenticatorRepository private lateinit var binder: SplitInstallBinder private var authData: AuthData? = null private var splitInstallSystemService: ISplitInstallService? = null private val serviceConnection = object : ServiceConnection { Loading @@ -68,10 +67,6 @@ class SplitInstallService : LifecycleService() { component = SplitInstall.SPLIT_INSTALL_SYSTEM_SERVICE } bindService(intent, serviceConnection, BIND_AUTO_CREATE) lifecycleScope.launch { fetchAuthData() } } override fun onDestroy() { Loading @@ -81,12 +76,6 @@ class SplitInstallService : LifecycleService() { super.onDestroy() } private suspend fun fetchAuthData() { appLoungeDataStore.authData.collect { authData = gson.fromJson(it, AuthData::class.java) } } override fun onBind(intent: Intent): IBinder { super.onBind(intent) binder = SplitInstallBinder( Loading @@ -94,7 +83,7 @@ class SplitInstallService : LifecycleService() { lifecycleScope, applicationRepository, downloadManager, authData, authenticatorRepository, splitInstallSystemService ) return binder Loading