Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
3dc81635
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,发现更多精彩内容 >>
未验证
提交
3dc81635
编写于
7月 09, 2020
作者:
K
Kaushik Iska
提交者:
GitHub
7月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[android] Pass synthesized eventType to VirtualDisplay platform views and fix memory leak (#19620)
上级
69fdf6d1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
119 addition
and
6 deletion
+119
-6
shell/platform/android/BUILD.gn
shell/platform/android/BUILD.gn
+1
-0
shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java
...d/io/flutter/embedding/android/AndroidTouchProcessor.java
+3
-2
shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java
...embedding/engine/systemchannels/PlatformViewsChannel.java
+1
-1
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
...d/io/flutter/plugin/platform/PlatformViewsController.java
+6
-3
shell/platform/android/test/io/flutter/FlutterTestSuite.java
shell/platform/android/test/io/flutter/FlutterTestSuite.java
+2
-0
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
.../flutter/plugin/platform/PlatformViewsControllerTest.java
+106
-0
未找到文件。
shell/platform/android/BUILD.gn
浏览文件 @
3dc81635
...
...
@@ -456,6 +456,7 @@ action("robolectric_tests") {
"test/io/flutter/plugin/localization/LocalizationPluginTest.java",
"test/io/flutter/plugin/mouse/MouseCursorPluginTest.java",
"test/io/flutter/plugin/platform/PlatformPluginTest.java",
"test/io/flutter/plugin/platform/PlatformViewsControllerTest.java",
"test/io/flutter/plugin/platform/SingleViewPresentationTest.java",
"test/io/flutter/plugins/GeneratedPluginRegistrant.java",
"test/io/flutter/util/FakeKeyEvent.java",
...
...
shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java
浏览文件 @
3dc81635
...
...
@@ -176,7 +176,8 @@ public class AndroidTouchProcessor {
return
;
}
MotionEventTracker
.
MotionEventId
motionEventId
=
motionEventTracker
.
track
(
event
);
// TODO (kaushikiska) : pass this in when we have a way to evict framework only events.
// MotionEventTracker.MotionEventId motionEventId = motionEventTracker.track(event);
int
pointerKind
=
getPointerDeviceTypeForToolType
(
event
.
getToolType
(
pointerIndex
));
...
...
@@ -187,7 +188,7 @@ public class AndroidTouchProcessor {
long
timeStamp
=
event
.
getEventTime
()
*
1000
;
// Convert from milliseconds to microseconds.
packet
.
putLong
(
motionEventId
.
getId
());
packet
.
putLong
(
0
);
// motionEventId
packet
.
putLong
(
timeStamp
);
// time_stamp
packet
.
putLong
(
pointerChange
);
// change
packet
.
putLong
(
pointerKind
);
// kind
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java
浏览文件 @
3dc81635
...
...
@@ -384,7 +384,7 @@ public class PlatformViewsChannel {
/** TODO(iskakaushik): javadoc */
public
final
long
motionEventId
;
PlatformViewTouch
(
public
PlatformViewTouch
(
int
viewId
,
@NonNull
Number
downTime
,
@NonNull
Number
eventTime
,
...
...
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
浏览文件 @
3dc81635
...
...
@@ -254,10 +254,11 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
final
int
viewId
=
touch
.
viewId
;
float
density
=
context
.
getResources
().
getDisplayMetrics
().
density
;
ensureValidAndroidVersion
(
Build
.
VERSION_CODES
.
KITKAT_WATCH
);
final
MotionEvent
event
=
toMotionEvent
(
density
,
touch
);
if
(
vdControllers
.
containsKey
(
viewId
))
{
final
MotionEvent
event
=
toMotionEvent
(
density
,
touch
,
/*usingVirtualDiplays=*/
true
);
vdControllers
.
get
(
touch
.
viewId
).
dispatchTouchEvent
(
event
);
}
else
if
(
platformViews
.
get
(
viewId
)
!=
null
)
{
final
MotionEvent
event
=
toMotionEvent
(
density
,
touch
,
/*usingVirtualDiplays=*/
false
);
View
view
=
platformViews
.
get
(
touch
.
viewId
);
view
.
dispatchTouchEvent
(
event
);
}
else
{
...
...
@@ -305,7 +306,9 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
}
};
private
MotionEvent
toMotionEvent
(
float
density
,
PlatformViewsChannel
.
PlatformViewTouch
touch
)
{
@VisibleForTesting
public
MotionEvent
toMotionEvent
(
float
density
,
PlatformViewsChannel
.
PlatformViewTouch
touch
,
boolean
usingVirtualDiplays
)
{
MotionEventTracker
.
MotionEventId
motionEventId
=
MotionEventTracker
.
MotionEventId
.
from
(
touch
.
motionEventId
);
MotionEvent
trackedEvent
=
motionEventTracker
.
pop
(
motionEventId
);
...
...
@@ -321,7 +324,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
parsePointerCoordsList
(
touch
.
rawPointerCoords
,
density
)
.
toArray
(
new
PointerCoords
[
touch
.
pointerCount
]);
if
(
trackedEvent
!=
null
)
{
if
(
!
usingVirtualDiplays
&&
trackedEvent
!=
null
)
{
return
MotionEvent
.
obtain
(
trackedEvent
.
getDownTime
(),
trackedEvent
.
getEventTime
(),
...
...
shell/platform/android/test/io/flutter/FlutterTestSuite.java
浏览文件 @
3dc81635
...
...
@@ -25,6 +25,7 @@ import io.flutter.plugin.editing.InputConnectionAdaptorTest;
import
io.flutter.plugin.editing.TextInputPluginTest
;
import
io.flutter.plugin.mouse.MouseCursorPluginTest
;
import
io.flutter.plugin.platform.PlatformPluginTest
;
import
io.flutter.plugin.platform.PlatformViewsControllerTest
;
import
io.flutter.plugin.platform.SingleViewPresentationTest
;
import
io.flutter.util.PreconditionsTest
;
import
io.flutter.view.AccessibilityBridgeTest
;
...
...
@@ -55,6 +56,7 @@ import test.io.flutter.embedding.engine.dart.DartExecutorTest;
InputConnectionAdaptorTest
.
class
,
LocalizationPluginTest
.
class
,
PlatformPluginTest
.
class
,
PlatformViewsControllerTest
.
class
,
PluginComponentTest
.
class
,
PreconditionsTest
.
class
,
RenderingComponentTest
.
class
,
...
...
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
浏览文件 @
3dc81635
package
io.flutter.plugin.platform
;
import
static
io
.
flutter
.
embedding
.
engine
.
systemchannels
.
PlatformViewsChannel
.
PlatformViewTouch
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotEquals
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
io.flutter.embedding.android.MotionEventTracker
;
import
java.util.Arrays
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
...
...
@@ -16,6 +23,8 @@ import org.robolectric.annotation.Config;
@Config
(
manifest
=
Config
.
NONE
)
@RunWith
(
RobolectricTestRunner
.
class
)
public
class
PlatformViewsControllerTest
{
@Ignore
@Test
public
void
itNotifiesVirtualDisplayControllersOfViewAttachmentAndDetachment
()
{
// Setup test structure.
...
...
@@ -58,6 +67,7 @@ public class PlatformViewsControllerTest {
verify
(
fakeVdController2
,
times
(
1
)).
onFlutterViewDetached
();
}
@Ignore
@Test
public
void
itCancelsOldPresentationOnResize
()
{
// Setup test structure.
...
...
@@ -79,4 +89,100 @@ public class PlatformViewsControllerTest {
assertEquals
(
fakeVdController1
.
presentation
!=
presentation
,
true
);
assertEquals
(
presentation
.
isShowing
(),
false
);
}
@Test
public
void
itUsesActionEventTypeFromFrameworkEventForVirtualDisplays
()
{
MotionEventTracker
motionEventTracker
=
MotionEventTracker
.
getInstance
();
PlatformViewsController
platformViewsController
=
new
PlatformViewsController
();
MotionEvent
original
=
MotionEvent
.
obtain
(
100
,
// downTime
100
,
// eventTime
1
,
// action
0
,
// x
0
,
// y
0
// metaState
);
// track an event that will later get passed to us from framework
MotionEventTracker
.
MotionEventId
motionEventId
=
motionEventTracker
.
track
(
original
);
PlatformViewTouch
frameWorkTouch
=
new
PlatformViewTouch
(
0
,
// viewId
original
.
getDownTime
(),
original
.
getEventTime
(),
2
,
// action
1
,
// pointerCount
Arrays
.
asList
(
Arrays
.
asList
(
0
,
0
)),
// pointer properties
Arrays
.
asList
(
Arrays
.
asList
(
0
.,
1
.,
2
.,
3
.,
4
.,
5
.,
6
.,
7
.,
8
.)),
// pointer coords
original
.
getMetaState
(),
original
.
getButtonState
(),
original
.
getXPrecision
(),
original
.
getYPrecision
(),
original
.
getDeviceId
(),
original
.
getEdgeFlags
(),
original
.
getSource
(),
original
.
getFlags
(),
motionEventId
.
getId
());
MotionEvent
resolvedEvent
=
platformViewsController
.
toMotionEvent
(
1
,
// density
frameWorkTouch
,
true
// usingVirtualDisplays
);
assertEquals
(
resolvedEvent
.
getAction
(),
frameWorkTouch
.
action
);
assertNotEquals
(
resolvedEvent
.
getAction
(),
original
.
getAction
());
}
@Test
public
void
itUsesActionEventTypeFromMotionEventForHybridPlatformViews
()
{
MotionEventTracker
motionEventTracker
=
MotionEventTracker
.
getInstance
();
PlatformViewsController
platformViewsController
=
new
PlatformViewsController
();
MotionEvent
original
=
MotionEvent
.
obtain
(
100
,
// downTime
100
,
// eventTime
1
,
// action
0
,
// x
0
,
// y
0
// metaState
);
// track an event that will later get passed to us from framework
MotionEventTracker
.
MotionEventId
motionEventId
=
motionEventTracker
.
track
(
original
);
PlatformViewTouch
frameWorkTouch
=
new
PlatformViewTouch
(
0
,
// viewId
original
.
getDownTime
(),
original
.
getEventTime
(),
2
,
// action
1
,
// pointerCount
Arrays
.
asList
(
Arrays
.
asList
(
0
,
0
)),
// pointer properties
Arrays
.
asList
(
Arrays
.
asList
(
0
.,
1
.,
2
.,
3
.,
4
.,
5
.,
6
.,
7
.,
8
.)),
// pointer coords
original
.
getMetaState
(),
original
.
getButtonState
(),
original
.
getXPrecision
(),
original
.
getYPrecision
(),
original
.
getDeviceId
(),
original
.
getEdgeFlags
(),
original
.
getSource
(),
original
.
getFlags
(),
motionEventId
.
getId
());
MotionEvent
resolvedEvent
=
platformViewsController
.
toMotionEvent
(
1
,
// density
frameWorkTouch
,
false
// usingVirtualDisplays
);
assertNotEquals
(
resolvedEvent
.
getAction
(),
frameWorkTouch
.
action
);
assertEquals
(
resolvedEvent
.
getAction
(),
original
.
getAction
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录