Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
be36ba64
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
be36ba64
编写于
12月 10, 2018
作者:
S
Stanislav Baranov
提交者:
GitHub
12月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generalize runFromBundle to support multiple bundlePaths (#7151)
上级
da9985a8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
39 deletion
+41
-39
shell/platform/android/io/flutter/view/FlutterNativeView.java
...l/platform/android/io/flutter/view/FlutterNativeView.java
+19
-12
shell/platform/android/io/flutter/view/FlutterRunArguments.java
...platform/android/io/flutter/view/FlutterRunArguments.java
+1
-0
shell/platform/android/platform_view_android_jni.cc
shell/platform/android/platform_view_android_jni.cc
+21
-27
未找到文件。
shell/platform/android/io/flutter/view/FlutterNativeView.java
浏览文件 @
be36ba64
...
...
@@ -76,12 +76,20 @@ public class FlutterNativeView implements BinaryMessenger {
}
public
void
runFromBundle
(
FlutterRunArguments
args
)
{
if
(
args
.
bundlePath
==
null
)
{
throw
new
AssertionError
(
"A bundlePath must be specified"
);
if
(
args
.
bundlePath
==
null
&&
args
.
bundlePaths
.
length
==
0
)
{
throw
new
AssertionError
(
"Either bundlePath or bundlePaths must be specified"
);
}
else
if
((
args
.
bundlePath
!=
null
||
args
.
defaultPath
!=
null
)
&&
args
.
bundlePaths
.
length
!=
0
)
{
throw
new
AssertionError
(
"Can't specify both bundlePath and bundlePaths"
);
}
else
if
(
args
.
entrypoint
==
null
)
{
throw
new
AssertionError
(
"An entrypoint must be specified"
);
throw
new
AssertionError
(
"An entrypoint must be specified"
);
}
if
(
args
.
bundlePaths
.
length
!=
0
)
{
runFromBundleInternal
(
args
.
bundlePaths
,
args
.
entrypoint
,
args
.
libraryPath
);
}
else
{
runFromBundleInternal
(
new
String
[]
{
args
.
bundlePath
,
args
.
defaultPath
},
args
.
entrypoint
,
args
.
libraryPath
);
}
runFromBundleInternal
(
args
.
bundlePath
,
args
.
entrypoint
,
args
.
libraryPath
,
args
.
defaultPath
);
}
/**
...
...
@@ -92,17 +100,17 @@ public class FlutterNativeView implements BinaryMessenger {
@Deprecated
public
void
runFromBundle
(
String
bundlePath
,
String
defaultPath
,
String
entrypoint
,
boolean
reuseRuntimeController
)
{
runFromBundleInternal
(
bundlePath
,
entrypoint
,
null
,
defaultPath
);
runFromBundleInternal
(
new
String
[]
{
bundlePath
,
defaultPath
},
entrypoint
,
null
);
}
private
void
runFromBundleInternal
(
String
bundlePath
,
String
entrypoint
,
String
libraryPath
,
String
defaultPath
)
{
private
void
runFromBundleInternal
(
String
[]
bundlePaths
,
String
entrypoint
,
String
libraryPath
)
{
assertAttached
();
if
(
applicationIsRunning
)
throw
new
AssertionError
(
"This Flutter engine instance is already running an application"
);
nativeRunBundleAndSnapshotFromLibrary
(
mNativePlatformView
,
bundlePath
,
defaultPath
,
entrypoint
,
libraryPath
,
mContext
.
getResources
().
getAssets
());
nativeRunBundleAndSnapshotFromLibrary
(
mNativePlatformView
,
bundlePath
s
,
entrypoint
,
libraryPath
,
mContext
.
getResources
().
getAssets
());
applicationIsRunning
=
true
;
}
...
...
@@ -240,9 +248,8 @@ public class FlutterNativeView implements BinaryMessenger {
private
static
native
void
nativeDetach
(
long
nativePlatformViewAndroid
);
private
static
native
void
nativeRunBundleAndSnapshotFromLibrary
(
long
nativePlatformViewAndroid
,
String
bundlePath
,
String
defaultPath
,
String
entrypoint
,
String
libraryUrl
,
AssetManager
manager
);
long
nativePlatformViewAndroid
,
String
[]
bundlePaths
,
String
entrypoint
,
String
libraryUrl
,
AssetManager
manager
);
private
static
native
String
nativeGetObservatoryUri
();
...
...
shell/platform/android/io/flutter/view/FlutterRunArguments.java
浏览文件 @
be36ba64
...
...
@@ -9,6 +9,7 @@ package io.flutter.view;
* the first time.
*/
public
class
FlutterRunArguments
{
public
String
[]
bundlePaths
;
public
String
bundlePath
;
public
String
entrypoint
;
public
String
libraryPath
;
...
...
shell/platform/android/platform_view_android_jni.cc
浏览文件 @
be36ba64
...
...
@@ -236,15 +236,17 @@ std::unique_ptr<IsolateConfiguration> CreateIsolateConfiguration(
static
void
RunBundleAndSnapshotFromLibrary
(
JNIEnv
*
env
,
jobject
jcaller
,
jlong
shell_holder
,
jstring
jbundlepath
,
jstring
jdefaultPath
,
jobjectArray
jbundlepaths
,
jstring
jEntrypoint
,
jstring
jLibraryUrl
,
jobject
jAssetManager
)
{
auto
asset_manager
=
std
::
make_shared
<
blink
::
AssetManager
>
();
for
(
const
auto
&
bundlepath
:
fml
::
jni
::
StringArrayToVector
(
env
,
jbundlepaths
))
{
if
(
bundlepath
.
empty
())
{
continue
;
}
const
auto
bundlepath
=
fml
::
jni
::
JavaStringToString
(
env
,
jbundlepath
);
if
(
bundlepath
.
size
()
>
0
)
{
// If we got a bundle path, attempt to use that as a directory asset
// bundle or a zip asset bundle.
const
auto
file_ext_index
=
bundlepath
.
rfind
(
"."
);
...
...
@@ -255,30 +257,23 @@ static void RunBundleAndSnapshotFromLibrary(JNIEnv* env,
asset_manager
->
PushBack
(
std
::
make_unique
<
blink
::
DirectoryAssetBundle
>
(
fml
::
OpenDirectory
(
bundlepath
.
c_str
(),
false
,
fml
::
FilePermission
::
kRead
)));
}
// Use the last path component of the bundle path to determine the
// directory in the APK assets.
const
auto
last_slash_index
=
bundlepath
.
rfind
(
"/"
,
bundlepath
.
size
());
if
(
last_slash_index
!=
std
::
string
::
npos
)
{
auto
apk_asset_dir
=
bundlepath
.
substr
(
last_slash_index
+
1
,
bundlepath
.
size
()
-
last_slash_index
);
asset_manager
->
PushBack
(
std
::
make_unique
<
blink
::
APKAssetProvider
>
(
env
,
// jni environment
jAssetManager
,
// asset manager
std
::
move
(
apk_asset_dir
))
// apk asset dir
);
// Use the last path component of the bundle path to determine the
// directory in the APK assets.
const
auto
last_slash_index
=
bundlepath
.
rfind
(
"/"
,
bundlepath
.
size
());
if
(
last_slash_index
!=
std
::
string
::
npos
)
{
auto
apk_asset_dir
=
bundlepath
.
substr
(
last_slash_index
+
1
,
bundlepath
.
size
()
-
last_slash_index
);
asset_manager
->
PushBack
(
std
::
make_unique
<
blink
::
APKAssetProvider
>
(
env
,
// jni environment
jAssetManager
,
// asset manager
std
::
move
(
apk_asset_dir
))
// apk asset dir
);
}
}
}
const
auto
defaultpath
=
fml
::
jni
::
JavaStringToString
(
env
,
jdefaultPath
);
if
(
defaultpath
.
size
()
>
0
)
{
asset_manager
->
PushBack
(
std
::
make_unique
<
blink
::
DirectoryAssetBundle
>
(
fml
::
OpenDirectory
(
defaultpath
.
c_str
(),
false
,
fml
::
FilePermission
::
kRead
)));
}
auto
isolate_configuration
=
CreateIsolateConfiguration
(
*
asset_manager
);
if
(
!
isolate_configuration
)
{
FML_DLOG
(
ERROR
)
...
...
@@ -591,9 +586,8 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
},
{
.
name
=
"nativeRunBundleAndSnapshotFromLibrary"
,
.
signature
=
"(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;"
"Ljava/lang/String;Landroid/content/res/AssetManager;)V"
,
.
signature
=
"(J[Ljava/lang/String;Ljava/lang/String;"
"Ljava/lang/String;Landroid/content/res/AssetManager;)V"
,
.
fnPtr
=
reinterpret_cast
<
void
*>
(
&
shell
::
RunBundleAndSnapshotFromLibrary
),
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录