forked from Tencent/Shadow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(core): 去除加载插件对getPackageArchiveInfo的依赖
由于PackageManager.getPackageArchiveInfo方法在解析较大的Manifest时速度很慢, 而且加载插件过程中只依赖很少量的字段,如className,theme等,所以在主路径不再依赖它, 而是依赖编译期生成好的PluginManifest类。 另一原因是getPackageArchiveInfo的返回类型没有公开API告诉我们Receiver的action字段。 在插件代码主动通过PackageManager获取信息时,再依赖getPackageArchiveInfo方法 获取MetaData等插件框架本身不需要的信息。 close Tencent#696
- Loading branch information
Showing
21 changed files
with
344 additions
and
678 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...r/src/main/kotlin/com/tencent/shadow/core/loader/blocs/CreatePluginApplicationInfoBloc.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.tencent.shadow.core.loader.blocs | ||
|
||
import android.content.Context | ||
import android.content.pm.ApplicationInfo | ||
import android.os.Build | ||
import com.tencent.shadow.core.common.InstalledApk | ||
import com.tencent.shadow.core.load_parameters.LoadParameters | ||
import com.tencent.shadow.core.runtime.PluginManifest | ||
import com.tencent.shadow.core.runtime.ShadowContext | ||
import java.io.File | ||
|
||
object CreatePluginApplicationInfoBloc { | ||
fun create(installedApk: InstalledApk, | ||
loadParameters: LoadParameters, | ||
pluginManifest: PluginManifest, | ||
hostAppContext: Context): ApplicationInfo { | ||
val result = ApplicationInfo(hostAppContext.applicationInfo) | ||
result.sourceDir = installedApk.apkFilePath | ||
result.nativeLibraryDir = installedApk.libraryPath | ||
result.dataDir = makeDataDir(loadParameters, hostAppContext).absolutePath | ||
|
||
result.packageName = pluginManifest.applicationPackageName | ||
result.className = pluginManifest.applicationClassName | ||
result.theme = pluginManifest.applicationTheme | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
result.appComponentFactory = pluginManifest.appComponentFactory | ||
} | ||
return result | ||
} | ||
|
||
fun makeDataDir(loadParameters: LoadParameters, hostAppContext: Context): File { | ||
val tempContext = ShadowContext(hostAppContext, 0).apply { | ||
setBusinessName(loadParameters.businessName) | ||
} | ||
val dataDir = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
tempContext.dataDir | ||
} else { | ||
File(tempContext.filesDir, "dataDir") | ||
} | ||
dataDir.mkdirs() | ||
return dataDir | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.