@@ -16,6 +16,7 @@ import android.util.Log
1616import hidden.HiddenApiBridge
1717import io.github.libxposed.service.IXposedScopeCallback
1818import kotlinx.coroutines.launch
19+ import org.lsposed.lspd.models.Application
1920import org.lsposed.lspd.service.IDaemonService
2021import org.lsposed.lspd.service.ILSPApplicationService
2122import org.matrix.vector.daemon.data.ConfigCache
@@ -275,10 +276,32 @@ object VectorService : IDaemonService.Stub() {
275276 isXposedModule =
276277 ModuleDatabase .updateModuleApkPath(
277278 moduleName, ConfigCache .getModuleApkPath(appInfo), false )
278- } else if (ConfigCache .state.scopes.keys.any { it.uid == uid }) {
279- // If not a module, but it's an app that was previously a "scope" (target)
280- // for a module, we need to refresh the cache.
281- ConfigCache .requestCacheUpdate()
279+ } else {
280+ if (ConfigCache .state.scopes.keys.any { it.uid == uid }) {
281+ // If not a module, but it's an app that was previously a "scope" (target)
282+ // for a module, we need to refresh the cache.
283+ ConfigCache .requestCacheUpdate()
284+ }
285+
286+ if (action == Intent .ACTION_PACKAGE_ADDED &&
287+ ! intent.getBooleanExtra(Intent .EXTRA_REPLACING , false ) &&
288+ moduleName != null ) {
289+
290+ ConfigCache .getAutoIncludeModules().forEach { xposedModule ->
291+ val scopeList = ConfigCache .getModuleScope(xposedModule) ? : mutableListOf ()
292+
293+ val newScope =
294+ Application ().apply {
295+ this .packageName = moduleName
296+ this .userId = userId
297+ }
298+
299+ scopeList.add(newScope)
300+ if (! ModuleDatabase .setModuleScope(xposedModule, scopeList)) {
301+ Log .e(TAG , " Failed to auto-include $moduleName for $xposedModule " )
302+ }
303+ }
304+ }
282305 }
283306 }
284307 Intent .ACTION_UID_REMOVED -> {
@@ -353,7 +376,7 @@ object VectorService : IDaemonService.Stub() {
353376 val scopes = ConfigCache .getModuleScope(packageName) ? : mutableListOf ()
354377 if (scopes.none { it.packageName == scopePackageName && it.userId == userId }) {
355378 scopes.add(
356- org.lsposed.lspd.models. Application ().apply {
379+ Application ().apply {
357380 this .packageName = scopePackageName
358381 this .userId = userId
359382 })
0 commit comments