Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
e1204944
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
e1204944
编写于
5月 26, 2021
作者:
G
Gary Qian
提交者:
GitHub
5月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix deferred components startup threading and improve .so search algorithm. (#26429)
上级
a832502e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
5 deletion
+57
-5
shell/common/shell.cc
shell/common/shell.cc
+9
-2
shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java
...deferredcomponents/PlayStoreDeferredComponentManager.java
+19
-3
shell/platform/android/test/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManagerTest.java
...rredcomponents/PlayStoreDeferredComponentManagerTest.java
+29
-0
未找到文件。
shell/common/shell.cc
浏览文件 @
e1204944
...
...
@@ -1313,8 +1313,15 @@ void Shell::LoadDartDeferredLibrary(
intptr_t
loading_unit_id
,
std
::
unique_ptr
<
const
fml
::
Mapping
>
snapshot_data
,
std
::
unique_ptr
<
const
fml
::
Mapping
>
snapshot_instructions
)
{
engine_
->
LoadDartDeferredLibrary
(
loading_unit_id
,
std
::
move
(
snapshot_data
),
std
::
move
(
snapshot_instructions
));
task_runners_
.
GetUITaskRunner
()
->
PostTask
(
fml
::
MakeCopyable
(
[
engine
=
engine_
->
GetWeakPtr
(),
loading_unit_id
,
data
=
std
::
move
(
snapshot_data
),
instructions
=
std
::
move
(
snapshot_instructions
)]()
mutable
{
if
(
engine
)
{
engine
->
LoadDartDeferredLibrary
(
loading_unit_id
,
std
::
move
(
data
),
std
::
move
(
instructions
));
}
}));
}
void
Shell
::
LoadDartDeferredLibraryError
(
intptr_t
loading_unit_id
,
...
...
shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java
浏览文件 @
e1204944
...
...
@@ -425,18 +425,34 @@ public class PlayStoreDeferredComponentManager implements DeferredComponentManag
List
<
String
>
apkPaths
=
new
ArrayList
<>();
// If not found in APKs, we check in extracted native libs for the lib directly.
List
<
String
>
soPaths
=
new
ArrayList
<>();
Queue
<
File
>
searchFiles
=
new
LinkedList
<>();
// Downloaded modules are stored here
searchFiles
.
add
(
context
.
getFilesDir
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
// The initial installed apks are provided by `sourceDirs` in ApplicationInfo.
// The jniLibs we want are in the splits not the baseDir. These
// APKs are only searched as a fallback, as base libs generally do not need
// to be fully path referenced.
for
(
String
path
:
context
.
getApplicationInfo
().
splitSourceDirs
)
{
searchFiles
.
add
(
new
File
(
path
));
}
}
while
(!
searchFiles
.
isEmpty
())
{
File
file
=
searchFiles
.
remove
();
if
(
file
!=
null
&&
file
.
isDirectory
())
{
if
(
file
!=
null
&&
file
.
isDirectory
()
&&
file
.
listFiles
()
!=
null
)
{
for
(
File
f
:
file
.
listFiles
())
{
searchFiles
.
add
(
f
);
}
continue
;
}
String
name
=
file
.
getName
();
if
(
name
.
endsWith
(
".apk"
)
&&
name
.
startsWith
(
componentName
)
&&
name
.
contains
(
pathAbi
))
{
// Special case for "split_config" since android base module non-master apks are
// initially installed with the "split_config" prefix/name.
if
(
name
.
endsWith
(
".apk"
)
&&
(
name
.
startsWith
(
componentName
)
||
name
.
startsWith
(
"split_config"
))
&&
name
.
contains
(
pathAbi
))
{
apkPaths
.
add
(
file
.
getAbsolutePath
());
continue
;
}
...
...
@@ -459,7 +475,7 @@ public class PlayStoreDeferredComponentManager implements DeferredComponentManag
}
flutterJNI
.
loadDartDeferredLibrary
(
loadingUnitId
,
searchPaths
.
toArray
(
new
String
[
apk
Paths
.
size
()]));
loadingUnitId
,
searchPaths
.
toArray
(
new
String
[
search
Paths
.
size
()]));
}
public
boolean
uninstallDeferredComponent
(
int
loadingUnitId
,
String
componentName
)
{
...
...
shell/platform/android/test/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManagerTest.java
浏览文件 @
e1204944
...
...
@@ -14,6 +14,7 @@ import static org.mockito.Mockito.mock;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
...
...
@@ -32,6 +33,7 @@ import org.robolectric.annotation.Config;
@Config
(
manifest
=
Config
.
NONE
)
@RunWith
(
RobolectricTestRunner
.
class
)
@TargetApi
(
21
)
public
class
PlayStoreDeferredComponentManagerTest
{
private
class
TestFlutterJNI
extends
FlutterJNI
{
public
int
loadDartDeferredLibraryCalled
=
0
;
...
...
@@ -90,9 +92,12 @@ public class PlayStoreDeferredComponentManagerTest {
PackageManager
packageManager
=
mock
(
PackageManager
.
class
);
ApplicationInfo
applicationInfo
=
mock
(
ApplicationInfo
.
class
);
applicationInfo
.
metaData
=
metadata
;
applicationInfo
.
splitSourceDirs
=
new
String
[
1
];
applicationInfo
.
splitSourceDirs
[
0
]
=
"some.invalid.apk"
;
when
(
packageManager
.
getApplicationInfo
(
any
(
String
.
class
),
any
(
int
.
class
)))
.
thenReturn
(
applicationInfo
);
doReturn
(
packageManager
).
when
(
spyContext
).
getPackageManager
();
doReturn
(
applicationInfo
).
when
(
spyContext
).
getApplicationInfo
();
return
spyContext
;
}
...
...
@@ -239,6 +244,30 @@ public class PlayStoreDeferredComponentManagerTest {
assertEquals
(
jni
.
loadingUnitId
,
123
);
}
@Test
public
void
searchPathsSearchesSplitConfig
()
throws
NameNotFoundException
{
TestFlutterJNI
jni
=
new
TestFlutterJNI
();
Context
spyContext
=
createSpyContext
(
null
);
doReturn
(
null
).
when
(
spyContext
).
getAssets
();
String
apkTestPath
=
"test/path/split_config.armeabi_v7a.apk"
;
doReturn
(
new
File
(
apkTestPath
)).
when
(
spyContext
).
getFilesDir
();
TestPlayStoreDeferredComponentManager
playStoreManager
=
new
TestPlayStoreDeferredComponentManager
(
spyContext
,
jni
);
jni
.
setDeferredComponentManager
(
playStoreManager
);
assertEquals
(
jni
.
loadingUnitId
,
0
);
playStoreManager
.
installDeferredComponent
(
123
,
"TestModuleName"
);
assertEquals
(
jni
.
loadDartDeferredLibraryCalled
,
1
);
assertEquals
(
jni
.
updateAssetManagerCalled
,
1
);
assertEquals
(
jni
.
deferredComponentInstallFailureCalled
,
0
);
assertEquals
(
jni
.
searchPaths
[
0
],
"libapp.so-123.part.so"
);
assertTrue
(
jni
.
searchPaths
[
1
].
endsWith
(
apkTestPath
+
"!lib/armeabi-v7a/libapp.so-123.part.so"
));
assertEquals
(
jni
.
searchPaths
.
length
,
2
);
assertEquals
(
jni
.
loadingUnitId
,
123
);
}
@Test
public
void
invalidSearchPathsAreIgnored
()
throws
NameNotFoundException
{
TestFlutterJNI
jni
=
new
TestFlutterJNI
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录