Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
a00f8e8b
E
engine
项目概览
liujiuri
/
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,发现更多精彩内容 >>
未验证
提交
a00f8e8b
编写于
3月 05, 2018
作者:
S
Sarah Zakarias
提交者:
GitHub
3月 05, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Read assets out of APK on Android (#4742)
上级
b2807f81
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
242 addition
and
121 deletion
+242
-121
assets/BUILD.gn
assets/BUILD.gn
+1
-0
assets/asset_provider.h
assets/asset_provider.h
+25
-0
assets/directory_asset_bundle.h
assets/directory_asset_bundle.h
+4
-3
lib/ui/text/font_collection.cc
lib/ui/text/font_collection.cc
+7
-7
lib/ui/text/font_collection.h
lib/ui/text/font_collection.h
+2
-4
runtime/asset_font_selector.cc
runtime/asset_font_selector.cc
+9
-9
runtime/asset_font_selector.h
runtime/asset_font_selector.h
+3
-3
shell/common/engine.cc
shell/common/engine.cc
+14
-12
shell/common/engine.h
shell/common/engine.h
+2
-0
shell/common/platform_view.cc
shell/common/platform_view.cc
+4
-0
shell/common/platform_view.h
shell/common/platform_view.h
+5
-0
shell/platform/android/BUILD.gn
shell/platform/android/BUILD.gn
+3
-0
shell/platform/android/apk_asset_provider.cc
shell/platform/android/apk_asset_provider.cc
+38
-0
shell/platform/android/apk_asset_provider.h
shell/platform/android/apk_asset_provider.h
+32
-0
shell/platform/android/io/flutter/view/FlutterMain.java
shell/platform/android/io/flutter/view/FlutterMain.java
+10
-2
shell/platform/android/io/flutter/view/FlutterNativeView.java
...l/platform/android/io/flutter/view/FlutterNativeView.java
+6
-2
shell/platform/android/io/flutter/view/ResourceExtractor.java
...l/platform/android/io/flutter/view/ResourceExtractor.java
+19
-35
shell/platform/android/platform_view_android.cc
shell/platform/android/platform_view_android.cc
+9
-2
shell/platform/android/platform_view_android.h
shell/platform/android/platform_view_android.h
+3
-2
shell/platform/android/platform_view_android_jni.cc
shell/platform/android/platform_view_android_jni.cc
+6
-3
travis/licenses_golden/licenses_flutter
travis/licenses_golden/licenses_flutter
+40
-37
未找到文件。
assets/BUILD.gn
浏览文件 @
a00f8e8b
...
...
@@ -4,6 +4,7 @@
source_set("assets") {
sources = [
"asset_provider.h",
"directory_asset_bundle.cc",
"directory_asset_bundle.h",
"unzipper_provider.cc",
...
...
assets/asset_provider.h
0 → 100644
浏览文件 @
a00f8e8b
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_ASSETS_ASSET_PROVIDER_H_
#define FLUTTER_ASSETS_ASSET_PROVIDER_H_
#include <string>
#include <vector>
#include "lib/fxl/memory/ref_counted.h"
namespace
blink
{
class
AssetProvider
:
public
fxl
::
RefCountedThreadSafe
<
AssetProvider
>
{
public:
virtual
bool
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
)
=
0
;
virtual
~
AssetProvider
()
=
default
;
};
}
// namespace blink
#endif // FLUTTER_ASSETS_ASSET_PROVIDER_H
assets/directory_asset_bundle.h
浏览文件 @
a00f8e8b
...
...
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include "flutter/assets/asset_provider.h"
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
...
...
@@ -15,14 +16,14 @@
namespace
blink
{
class
DirectoryAssetBundle
:
public
fxl
::
RefCountedThreadSafe
<
DirectoryAssetBundle
>
{
:
public
AssetProvider
{
public:
explicit
DirectoryAssetBundle
(
std
::
string
directory
);
// Expects fd to be valid, otherwise the file descriptor is ignored.
explicit
DirectoryAssetBundle
(
fxl
::
UniqueFD
fd
);
~
DirectoryAssetBundle
();
virtual
~
DirectoryAssetBundle
();
bool
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
);
virtual
bool
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
);
std
::
string
GetPathForAsset
(
const
std
::
string
&
asset_name
);
...
...
lib/ui/text/font_collection.cc
浏览文件 @
a00f8e8b
...
...
@@ -34,15 +34,15 @@ std::shared_ptr<txt::FontCollection> FontCollection::GetFontCollection() const {
return
collection_
;
}
void
FontCollection
::
RegisterFontsFromDirectoryAssetBundle
(
fxl
::
RefPtr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundle
)
{
if
(
!
directory_asset_bundle
)
{
void
FontCollection
::
RegisterFontsFromAssetProvider
(
fxl
::
RefPtr
<
blink
::
AssetProvider
>
asset_provider
)
{
if
(
!
asset_provider
){
return
;
}
std
::
vector
<
uint8_t
>
manifest_data
;
if
(
!
directory_asset_bundle
->
GetAsBuffer
(
"FontManifest.json"
,
&
manifest_data
))
{
if
(
!
asset_provider
->
GetAsBuffer
(
"FontManifest.json"
,
&
manifest_data
))
{
FXL_DLOG
(
WARNING
)
<<
"Could not find the font manifest in the asset store."
;
return
;
}
...
...
@@ -92,8 +92,8 @@ void FontCollection::RegisterFontsFromDirectoryAssetBundle(
// TODO: Handle weights and styles.
std
::
vector
<
uint8_t
>
font_data
;
if
(
directory_asset_bundle
->
GetAsBuffer
(
font_asset
->
value
.
GetString
(),
&
font_data
))
{
if
(
asset_provider
->
GetAsBuffer
(
font_asset
->
value
.
GetString
(),
&
font_data
))
{
// The data must be copied because it needs to be moved into the
// typeface as a stream.
auto
data
=
...
...
lib/ui/text/font_collection.h
浏览文件 @
a00f8e8b
...
...
@@ -7,7 +7,7 @@
#include <memory>
#include <vector>
#include "flutter/assets/
directory_asset_bundle
.h"
#include "flutter/assets/
asset_provider
.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_ptr.h"
#include "txt/asset_data_provider.h"
...
...
@@ -21,9 +21,7 @@ class FontCollection {
std
::
shared_ptr
<
txt
::
FontCollection
>
GetFontCollection
()
const
;
void
RegisterFontsFromDirectoryAssetBundle
(
fxl
::
RefPtr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundle
);
void
RegisterFontsFromAssetProvider
(
fxl
::
RefPtr
<
blink
::
AssetProvider
>
asset_provider
);
void
RegisterTestFonts
();
private:
...
...
runtime/asset_font_selector.cc
浏览文件 @
a00f8e8b
...
...
@@ -81,9 +81,9 @@ struct FontMatcher {
}
// namespace
void
AssetFontSelector
::
Install
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
)
{
fxl
::
RefPtr
<
AssetProvider
>
asset_provider
)
{
RefPtr
<
AssetFontSelector
>
font_selector
=
adoptRef
(
new
AssetFontSelector
(
std
::
move
(
directory_asset_bundle
)));
adoptRef
(
new
AssetFontSelector
(
std
::
move
(
asset_provider
)));
font_selector
->
parseFontManifest
();
UIDartState
::
Current
()
->
set_font_selector
(
font_selector
);
}
...
...
@@ -96,8 +96,8 @@ void AssetFontSelector::Install(fxl::RefPtr<ZipAssetStore> asset_store) {
}
AssetFontSelector
::
AssetFontSelector
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
)
:
directory_asset_bundle_
(
std
::
move
(
directory_asset_bundle
))
{}
fxl
::
RefPtr
<
AssetProvider
>
asset_provider
)
:
asset_provider_
(
std
::
move
(
asset_provider
))
{}
AssetFontSelector
::
AssetFontSelector
(
fxl
::
RefPtr
<
ZipAssetStore
>
asset_store
)
:
asset_store_
(
std
::
move
(
asset_store
))
{}
...
...
@@ -118,9 +118,9 @@ AssetFontSelector::FlutterFontAttributes::~FlutterFontAttributes() {}
void
AssetFontSelector
::
parseFontManifest
()
{
std
::
vector
<
uint8_t
>
font_manifest_data
;
if
(
!
directory_asset_bundle
_
||
!
directory_asset_bundle
_
->
GetAsBuffer
(
kFontManifestAssetPath
,
&
font_manifest_data
))
{
if
(
!
asset_provider
_
||
!
asset_provider
_
->
GetAsBuffer
(
kFontManifestAssetPath
,
&
font_manifest_data
))
{
if
(
!
asset_store_
||
!
asset_store_
->
GetAsBuffer
(
kFontManifestAssetPath
,
&
font_manifest_data
))
return
;
...
...
@@ -239,8 +239,8 @@ sk_sp<SkTypeface> AssetFontSelector::getTypefaceAsset(
}
std
::
unique_ptr
<
TypefaceAsset
>
typeface_asset
(
new
TypefaceAsset
);
if
(
!
directory_asset_bundle_
||
!
directory_asset_bundle
_
->
GetAsBuffer
(
asset_path
,
&
typeface_asset
->
data
))
{
if
(
!
asset_provider_
||
!
asset_provider
_
->
GetAsBuffer
(
asset_path
,
&
typeface_asset
->
data
))
{
if
(
!
asset_store_
||
!
asset_store_
->
GetAsBuffer
(
asset_path
,
&
typeface_asset
->
data
))
{
typeface_cache_
.
insert
(
std
::
make_pair
(
asset_path
,
nullptr
));
...
...
runtime/asset_font_selector.h
浏览文件 @
a00f8e8b
...
...
@@ -24,7 +24,7 @@ class AssetFontSelector : public FontSelector {
~
AssetFontSelector
()
override
;
static
void
Install
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
);
static
void
Install
(
fxl
::
RefPtr
<
AssetProvider
>
asset_provider
);
// TODO(zarah): Remove this and related code using asset_store once flx is
// removed.
...
...
@@ -45,7 +45,7 @@ class AssetFontSelector : public FontSelector {
struct
TypefaceAsset
;
explicit
AssetFontSelector
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
);
fxl
::
RefPtr
<
AssetProvider
>
asset_provider
);
explicit
AssetFontSelector
(
fxl
::
RefPtr
<
ZipAssetStore
>
asset_store
);
...
...
@@ -54,7 +54,7 @@ class AssetFontSelector : public FontSelector {
sk_sp
<
SkTypeface
>
getTypefaceAsset
(
const
FontDescription
&
font_description
,
const
AtomicString
&
family_name
);
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
_
;
fxl
::
RefPtr
<
AssetProvider
>
asset_provider
_
;
fxl
::
RefPtr
<
ZipAssetStore
>
asset_store_
;
...
...
shell/common/engine.cc
浏览文件 @
a00f8e8b
...
...
@@ -32,6 +32,7 @@
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/assets/unzipper_provider.h"
#include "flutter/assets/zip_asset_store.h"
#include "flutter/assets/asset_provider.h"
#include "flutter/common/settings.h"
#include "flutter/common/threads.h"
#include "flutter/glue/trace_event.h"
...
...
@@ -288,7 +289,6 @@ void Engine::Init(const std::string& bundle_path) {
#else
#error Unknown OS
#endif
blink
::
InitRuntime
(
vm_snapshot_data
,
vm_snapshot_instr
,
default_isolate_snapshot_data
,
default_isolate_snapshot_instr
,
bundle_path
);
...
...
@@ -302,7 +302,6 @@ void Engine::RunBundle(const std::string& bundle_path,
TRACE_EVENT0
(
"flutter"
,
"Engine::RunBundle"
);
ConfigureAssetBundle
(
bundle_path
);
ConfigureRuntime
(
GetScriptUriFromPath
(
bundle_path
),
reuse_runtime_controller
);
if
(
blink
::
IsRunningPrecompiledCode
())
{
runtime_
->
dart_controller
()
->
RunFromPrecompiledSnapshot
(
entrypoint
);
}
else
{
...
...
@@ -573,6 +572,12 @@ void Engine::SetSemanticsEnabled(bool enabled) {
}
void
Engine
::
ConfigureAssetBundle
(
const
std
::
string
&
path
)
{
auto
platform_view
=
platform_view_
.
lock
();
asset_provider_
=
platform_view
->
GetAssetProvider
();
if
(
!
asset_provider_
)
{
asset_provider_
=
fxl
::
MakeRefCounted
<
blink
::
DirectoryAssetBundle
>
(
path
);
}
struct
stat
stat_result
=
{};
// TODO(abarth): We should reset directory_asset_bundle_, but that might break
...
...
@@ -585,8 +590,6 @@ void Engine::ConfigureAssetBundle(const std::string& path) {
std
::
string
flx_path
;
if
(
S_ISDIR
(
stat_result
.
st_mode
))
{
directory_asset_bundle_
=
fxl
::
MakeRefCounted
<
blink
::
DirectoryAssetBundle
>
(
path
);
flx_path
=
files
::
GetDirectoryName
(
path
)
+
"/app.flx"
;
}
else
if
(
S_ISREG
(
stat_result
.
st_mode
))
{
flx_path
=
path
;
...
...
@@ -618,11 +621,11 @@ void Engine::DidCreateMainIsolate(Dart_Isolate isolate) {
blink
::
TestFontSelector
::
Install
();
if
(
!
blink
::
Settings
::
Get
().
using_blink
)
blink
::
FontCollection
::
ForProcess
().
RegisterTestFonts
();
}
else
if
(
directory_asset_bundle
_
)
{
blink
::
AssetFontSelector
::
Install
(
directory_asset_bundle
_
);
}
else
if
(
asset_provider
_
)
{
blink
::
AssetFontSelector
::
Install
(
asset_provider
_
);
if
(
!
blink
::
Settings
::
Get
().
using_blink
)
{
blink
::
FontCollection
::
ForProcess
().
RegisterFontsFrom
DirectoryAssetBundle
(
directory_asset_bundle
_
);
blink
::
FontCollection
::
ForProcess
().
RegisterFontsFrom
AssetProvider
(
asset_provider
_
);
}
}
}
...
...
@@ -693,7 +696,6 @@ void Engine::HandleAssetPlatformMessage(
const
auto
&
data
=
message
->
data
();
std
::
string
asset_name
(
reinterpret_cast
<
const
char
*>
(
data
.
data
()),
data
.
size
());
std
::
vector
<
uint8_t
>
asset_data
;
if
(
GetAssetAsBuffer
(
asset_name
,
&
asset_data
))
{
response
->
Complete
(
std
::
move
(
asset_data
));
...
...
@@ -704,9 +706,9 @@ void Engine::HandleAssetPlatformMessage(
bool
Engine
::
GetAssetAsBuffer
(
const
std
::
string
&
name
,
std
::
vector
<
uint8_t
>*
data
)
{
return
(
directory_asset_bundle
_
&&
directory_asset_bundle
_
->
GetAsBuffer
(
name
,
data
))
||
(
asset_store_
&&
asset_store_
->
GetAsBuffer
(
name
,
data
));
return
(
(
asset_provider
_
&&
asset_provider
_
->
GetAsBuffer
(
name
,
data
))
||
(
asset_store_
&&
asset_store_
->
GetAsBuffer
(
name
,
data
)
));
}
}
// namespace shell
shell/common/engine.h
浏览文件 @
a00f8e8b
...
...
@@ -6,6 +6,7 @@
#define SHELL_COMMON_ENGINE_H_
#include "flutter/assets/zip_asset_store.h"
#include "flutter/assets/asset_provider.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/runtime/runtime_controller.h"
...
...
@@ -109,6 +110,7 @@ class Engine : public blink::RuntimeDelegate {
static
const
std
::
string
main_entrypoint_
;
fxl
::
RefPtr
<
blink
::
AssetProvider
>
asset_provider_
;
std
::
weak_ptr
<
PlatformView
>
platform_view_
;
std
::
unique_ptr
<
Animator
>
animator_
;
std
::
unique_ptr
<
blink
::
RuntimeController
>
runtime_
;
...
...
shell/common/platform_view.cc
浏览文件 @
a00f8e8b
...
...
@@ -126,6 +126,10 @@ VsyncWaiter* PlatformView::GetVsyncWaiter() {
return
vsync_waiter_
.
get
();
}
fxl
::
RefPtr
<
blink
::
AssetProvider
>
PlatformView
::
GetAssetProvider
()
{
return
asset_provider_
;
}
void
PlatformView
::
UpdateSemantics
(
blink
::
SemanticsNodeUpdates
update
)
{}
void
PlatformView
::
HandlePlatformMessage
(
...
...
shell/common/platform_view.h
浏览文件 @
a00f8e8b
...
...
@@ -7,6 +7,7 @@
#include <memory>
#include "flutter/assets/asset_provider.h"
#include "flutter/flow/texture.h"
#include "flutter/lib/ui/semantics/semantics_node.h"
#include "flutter/shell/common/engine.h"
...
...
@@ -64,6 +65,8 @@ class PlatformView : public std::enable_shared_from_this<PlatformView> {
virtual
void
HandlePlatformMessage
(
fxl
::
RefPtr
<
blink
::
PlatformMessage
>
message
);
virtual
fxl
::
RefPtr
<
blink
::
AssetProvider
>
GetAssetProvider
();
// Called once per texture, on the platform thread.
void
RegisterTexture
(
std
::
shared_ptr
<
flow
::
Texture
>
texture
);
...
...
@@ -97,6 +100,8 @@ class PlatformView : public std::enable_shared_from_this<PlatformView> {
flow
::
TextureRegistry
texture_registry_
;
std
::
unique_ptr
<
Engine
>
engine_
;
std
::
unique_ptr
<
VsyncWaiter
>
vsync_waiter_
;
fxl
::
RefPtr
<
blink
::
AssetProvider
>
asset_provider_
;
SkISize
size_
;
private:
...
...
shell/platform/android/BUILD.gn
浏览文件 @
a00f8e8b
...
...
@@ -27,6 +27,8 @@ shared_library("flutter_shell_native") {
"android_surface_gl.h",
"android_surface_software.h",
"android_surface_software.cc",
"apk_asset_provider.h",
"apk_asset_provider.cc",
"flutter_main.cc",
"flutter_main.h",
"library_loader.cc",
...
...
@@ -42,6 +44,7 @@ shared_library("flutter_shell_native") {
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/assets",
"$flutter_root/lib/ui",
"$flutter_root/runtime",
"$flutter_root/shell/common",
...
...
shell/platform/android/apk_asset_provider.cc
0 → 100644
浏览文件 @
a00f8e8b
#include <unistd.h>
#include <algorithm>
#include <sstream>
#include "flutter/shell/platform/android/apk_asset_provider.h"
#include "lib/fxl/logging.h"
namespace
blink
{
bool
APKAssetProvider
::
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
)
{
std
::
stringstream
ss
;
ss
<<
directory_
.
c_str
()
<<
"/"
<<
asset_name
;
AAsset
*
asset
=
AAssetManager_open
(
assetManager_
,
ss
.
str
().
c_str
(),
AASSET_MODE_BUFFER
);
if
(
!
asset
)
{
return
false
;
}
uint8_t
*
buffer
=
(
uint8_t
*
)
AAsset_getBuffer
(
asset
);
if
(
!
buffer
)
{
FXL_LOG
(
ERROR
)
<<
"Got null trying to acquire buffer for asset:"
<<
asset
;
return
false
;
}
data
->
resize
(
AAsset_getLength
(
asset
));
std
::
copy
(
buffer
,
buffer
+
data
->
size
(),
data
->
begin
());
AAsset_close
(
asset
);
return
true
;
}
APKAssetProvider
::~
APKAssetProvider
()
{}
APKAssetProvider
::
APKAssetProvider
(
JNIEnv
*
env
,
jobject
jassetManager
,
std
::
string
directory
)
:
directory_
(
std
::
move
(
directory
))
{
assetManager_
=
AAssetManager_fromJava
(
env
,
jassetManager
);
}
}
// namespace blink
shell/platform/android/apk_asset_provider.h
0 → 100644
浏览文件 @
a00f8e8b
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_ASSETS_APK_ASSET_PROVIDER_H_
#define FLUTTER_ASSETS_APK_ASSET_PROVIDER_H_
#include <jni.h>
#include <android/asset_manager_jni.h>
#include "flutter/assets/asset_provider.h"
#include "lib/fxl/memory/ref_counted.h"
namespace
blink
{
class
APKAssetProvider
:
public
AssetProvider
{
public:
explicit
APKAssetProvider
(
JNIEnv
*
env
,
jobject
assetManager
,
std
::
string
directory
);
virtual
~
APKAssetProvider
();
virtual
bool
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
);
private:
AAssetManager
*
assetManager_
;
const
std
::
string
directory_
;
};
}
// namespace blink
#endif // FLUTTER_ASSETS_APK_ASSET_PROVIDER_H
\ No newline at end of file
shell/platform/android/io/flutter/view/FlutterMain.java
浏览文件 @
a00f8e8b
...
...
@@ -66,10 +66,16 @@ public class FlutterMain {
private
static
final
String
DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR
=
"isolate_snapshot_instr"
;
private
static
final
String
DEFAULT_FLX
=
"app.flx"
;
private
static
final
String
DEFAULT_SNAPSHOT_BLOB
=
"snapshot_blob.bin"
;
private
static
final
String
DEFAULT_KERNEL_BLOB
=
"kernel_blob.bin"
;
private
static
final
String
DEFAULT_PLATFORM_DILL
=
"platform.dill"
;
private
static
final
String
DEFAULT_FLUTTER_ASSETS_DIR
=
"flutter_assets"
;
private
static
final
String
MANIFEST
=
"flutter.yaml"
;
private
static
String
fromFlutterAssets
(
String
filePath
)
{
return
sFlutterAssetsDir
+
"/"
+
filePath
;
}
private
static
final
Set
<
String
>
SKY_RESOURCES
=
ImmutableSetBuilder
.<
String
>
newInstance
()
.
add
(
"icudtl.dat"
)
.
add
(
MANIFEST
)
...
...
@@ -244,8 +250,10 @@ public class FlutterMain {
new
ResourceCleaner
(
context
).
start
();
sResourceExtractor
=
new
ResourceExtractor
(
context
)
.
addResources
(
SKY_RESOURCES
)
.
addResource
(
sFlx
)
.
addResource
(
sFlutterAssetsDir
);
.
addResource
(
fromFlutterAssets
(
sFlx
))
.
addResource
(
fromFlutterAssets
(
sSnapshotBlob
))
.
addResource
(
fromFlutterAssets
(
DEFAULT_KERNEL_BLOB
))
.
addResource
(
fromFlutterAssets
(
DEFAULT_PLATFORM_DILL
));
if
(
sIsPrecompiledAsSharedLibrary
)
{
sResourceExtractor
.
addResource
(
sAotSharedLibraryPath
);
...
...
shell/platform/android/io/flutter/view/FlutterNativeView.java
浏览文件 @
a00f8e8b
...
...
@@ -13,6 +13,7 @@ import java.nio.ByteBuffer;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.HashMap
;
import
java.util.Map
;
import
android.content.res.AssetManager
;
public
class
FlutterNativeView
implements
BinaryMessenger
{
private
static
final
String
TAG
=
"FlutterNativeView"
;
...
...
@@ -24,8 +25,10 @@ public class FlutterNativeView implements BinaryMessenger {
private
final
FlutterPluginRegistry
mPluginRegistry
;
private
long
mNativePlatformView
;
private
FlutterView
mFlutterView
;
private
final
Context
mContext
;
public
FlutterNativeView
(
Context
context
)
{
mContext
=
context
;
mPluginRegistry
=
new
FlutterPluginRegistry
(
this
,
context
);
attach
(
this
);
assertAttached
();
...
...
@@ -68,7 +71,7 @@ public class FlutterNativeView implements BinaryMessenger {
public
void
runFromBundle
(
String
bundlePath
,
String
snapshotOverride
,
String
entrypoint
,
boolean
reuseRuntimeController
)
{
assertAttached
();
nativeRunBundleAndSnapshot
(
mNativePlatformView
,
bundlePath
,
snapshotOverride
,
entrypoint
,
reuseRuntimeController
);
nativeRunBundleAndSnapshot
(
mNativePlatformView
,
bundlePath
,
snapshotOverride
,
entrypoint
,
reuseRuntimeController
,
mContext
.
getResources
().
getAssets
()
);
}
public
void
runFromSource
(
final
String
assetsDirectory
,
final
String
main
,
final
String
packages
)
{
...
...
@@ -194,7 +197,8 @@ public class FlutterNativeView implements BinaryMessenger {
String
bundlePath
,
String
snapshotOverride
,
String
entrypoint
,
boolean
reuseRuntimeController
);
boolean
reuseRuntimeController
,
AssetManager
manager
);
private
static
native
void
nativeRunBundleAndSource
(
long
nativePlatformViewAndroid
,
String
bundlePath
,
...
...
shell/platform/android/io/flutter/view/ResourceExtractor.java
浏览文件 @
a00f8e8b
...
...
@@ -13,6 +13,7 @@ import android.util.Log;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -47,48 +48,39 @@ class ResourceExtractor {
}
final
AssetManager
manager
=
mContext
.
getResources
().
getAssets
();
try
{
byte
[]
buffer
=
null
;
final
String
[]
assets
=
manager
.
list
(
""
);
LinkedList
<
String
>
assetList
=
new
LinkedList
<>(
Arrays
.
asList
(
assets
));
while
(!
assetList
.
isEmpty
())
{
String
asset
=
assetList
.
pop
();
if
(!
mResources
.
contains
(
asset
))
continue
;
if
(
manager
.
list
(
asset
).
length
>
0
)
{
// The asset is a directory
for
(
String
a:
manager
.
list
(
asset
))
{
assetList
.
add
(
asset
+
File
.
separator
+
a
);
mResources
.
add
(
asset
+
File
.
separator
+
a
);
}
continue
;
}
byte
[]
buffer
=
null
;
for
(
String
asset
:
mResources
)
{
try
{
final
File
output
=
new
File
(
dataDir
,
asset
);
if
(
output
.
exists
())
if
(
output
.
exists
())
{
continue
;
}
if
(
output
.
getParentFile
()
!=
null
)
{
output
.
getParentFile
().
mkdirs
();
}
try
(
InputStream
is
=
manager
.
open
(
asset
))
{
try
(
OutputStream
os
=
new
FileOutputStream
(
output
))
{
if
(
buffer
==
null
)
{
buffer
=
new
byte
[
BUFFER_SIZE
];
}
}
int
count
=
0
;
while
((
count
=
is
.
read
(
buffer
,
0
,
BUFFER_SIZE
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
count
);
}
os
.
flush
();
}
}
}
}
}
catch
(
FileNotFoundException
fnfe
)
{
continue
;
}
catch
(
IOException
ioe
)
{
Log
.
w
(
TAG
,
"Exception unpacking resources: "
+
ioe
.
getMessage
());
deleteFiles
();
return
;
}
}
catch
(
IOException
e
)
{
Log
.
w
(
TAG
,
"Exception unpacking resources: "
+
e
.
getMessage
());
deleteFiles
();
return
;
}
if
(
timestamp
!=
null
)
{
...
...
@@ -184,18 +176,10 @@ class ResourceExtractor {
private
void
deleteFiles
()
{
final
File
dataDir
=
new
File
(
PathUtils
.
getDataDirectory
(
mContext
));
LinkedList
<
String
>
files
=
new
LinkedList
<>(
mResources
);
while
(!
files
.
isEmpty
())
{
String
resource
=
files
.
pop
();
for
(
String
resource
:
mResources
)
{
final
File
file
=
new
File
(
dataDir
,
resource
);
if
(
file
.
exists
())
{
if
(
file
.
isFile
())
{
file
.
delete
();
}
else
{
for
(
String
f
:
file
.
list
())
{
files
.
add
(
resource
+
File
.
separator
+
f
);
}
}
file
.
delete
();
}
}
for
(
String
timestamp
:
getExistingTimestamps
(
dataDir
))
{
...
...
shell/platform/android/platform_view_android.cc
浏览文件 @
a00f8e8b
...
...
@@ -21,6 +21,7 @@
#include "flutter/shell/platform/android/android_external_texture_gl.h"
#include "flutter/shell/platform/android/android_surface_gl.h"
#include "flutter/shell/platform/android/android_surface_software.h"
#include "flutter/shell/platform/android/apk_asset_provider.h"
#include "flutter/shell/platform/android/platform_view_android_jni.h"
#include "flutter/shell/platform/android/vsync_waiter_android.h"
#include "lib/fxl/functional/make_copyable.h"
...
...
@@ -207,10 +208,16 @@ void PlatformViewAndroid::SurfaceDestroyed() {
ReleaseSurface
();
}
void
PlatformViewAndroid
::
RunBundleAndSnapshot
(
std
::
string
bundle_path
,
void
PlatformViewAndroid
::
RunBundleAndSnapshot
(
JNIEnv
*
env
,
std
::
string
bundle_path
,
std
::
string
snapshot_override
,
std
::
string
entrypoint
,
bool
reuse_runtime_controller
)
{
bool
reuse_runtime_controller
,
jobject
assetManager
)
{
// The flutter assets directory name is the last directory of the bundle_path and the path into the APK
size_t
last_slash_idx
=
bundle_path
.
rfind
(
"/"
,
bundle_path
.
size
());
std
::
string
flutter_assets_dir
=
bundle_path
.
substr
(
last_slash_idx
+
1
,
bundle_path
.
size
()
-
last_slash_idx
);
asset_provider_
=
fxl
::
MakeRefCounted
<
blink
::
APKAssetProvider
>
(
env
,
assetManager
,
flutter_assets_dir
);
blink
::
Threads
::
UI
()
->
PostTask
([
engine
=
engine_
->
GetWeakPtr
(),
bundle_path
=
std
::
move
(
bundle_path
),
snapshot_override
=
std
::
move
(
snapshot_override
),
...
...
shell/platform/android/platform_view_android.h
浏览文件 @
a00f8e8b
...
...
@@ -38,10 +38,11 @@ class PlatformViewAndroid : public PlatformView {
void
SurfaceDestroyed
();
void
RunBundleAndSnapshot
(
std
::
string
bundle_path
,
void
RunBundleAndSnapshot
(
JNIEnv
*
env
,
std
::
string
bundle_path
,
std
::
string
snapshot_override
,
std
::
string
entrypoint
,
bool
reuse_isolate
);
bool
reuse_isolate
,
jobject
assetManager
);
void
RunBundleAndSource
(
std
::
string
bundle_path
,
std
::
string
main
,
...
...
shell/platform/android/platform_view_android_jni.cc
浏览文件 @
a00f8e8b
...
...
@@ -160,12 +160,15 @@ static void RunBundleAndSnapshot(JNIEnv* env,
jstring
bundlePath
,
jstring
snapshotOverride
,
jstring
entrypoint
,
jboolean
reuse_runtime_controller
)
{
jboolean
reuse_runtime_controller
,
jobject
assetManager
)
{
return
PLATFORM_VIEW
->
RunBundleAndSnapshot
(
env
,
fml
::
jni
::
JavaStringToString
(
env
,
bundlePath
),
//
fml
::
jni
::
JavaStringToString
(
env
,
snapshotOverride
),
//
fml
::
jni
::
JavaStringToString
(
env
,
entrypoint
),
//
reuse_runtime_controller
//
reuse_runtime_controller
,
//
assetManager
);
}
...
...
@@ -351,7 +354,7 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
{
.
name
=
"nativeRunBundleAndSnapshot"
,
.
signature
=
"(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V"
,
"(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z
Landroid/content/res/AssetManager;
)V"
,
.
fnPtr
=
reinterpret_cast
<
void
*>
(
&
shell
::
RunBundleAndSnapshot
),
},
{
...
...
travis/licenses_golden/licenses_flutter
浏览文件 @
a00f8e8b
...
...
@@ -1560,6 +1560,7 @@ FILE: ../../../flutter/lib/ui/natives.dart
FILE: ../../../flutter/lib/ui/window/window.h
FILE: ../../../flutter/runtime/platform_impl.h
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.cc
FILE: ../../../flutter/shell/platform/android/apk_asset_provider.cc
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/JSONUtil.java
FILE: ../../../flutter/shell/platform/darwin/desktop/Info.plist
FILE: ../../../flutter/shell/platform/darwin/desktop/flutter_mac.xib
...
...
@@ -1635,6 +1636,45 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../flutter/assets/asset_provider.h + ../../../LICENSE
TYPE: LicenseType.bsd
FILE: ../../../flutter/assets/asset_provider.h
FILE: ../../../flutter/flutter_kernel_transformers/lib/track_widget_constructor_locations.dart
FILE: ../../../flutter/shell/platform/android/apk_asset_provider.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm
----------------------------------------------------------------------------------------------------
Copyright 2018 The Chromium Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../flutter/assets/directory_asset_bundle.cc + ../../../LICENSE
...
...
@@ -1879,43 +1919,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../flutter/flutter_kernel_transformers/lib/track_widget_constructor_locations.dart + ../../../LICENSE
TYPE: LicenseType.bsd
FILE: ../../../flutter/flutter_kernel_transformers/lib/track_widget_constructor_locations.dart
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm
----------------------------------------------------------------------------------------------------
Copyright 2018 The Chromium Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_block.h + ../../../LICENSE
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录