Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
16870408
E
engine
项目概览
qq_34031325
/
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,发现更多精彩内容 >>
未验证
提交
16870408
编写于
2月 16, 2021
作者:
L
LongCatIsLooong
提交者:
GitHub
2月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Android Text Input] Remove Samsung restart input workaround for newer Samsung keyboards (#24288)
上级
e1f03cda
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
92 addition
and
8 deletion
+92
-8
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
...rm/android/io/flutter/plugin/editing/TextInputPlugin.java
+22
-1
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
...d/test/io/flutter/plugin/editing/TextInputPluginTest.java
+70
-7
未找到文件。
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
浏览文件 @
16870408
...
...
@@ -6,6 +6,7 @@ package io.flutter.plugin.editing;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.graphics.Rect
;
import
android.os.Build
;
import
android.os.Bundle
;
...
...
@@ -497,7 +498,27 @@ public class TextInputPlugin implements ListenableEditingState.EditingStateWatch
mView
.
getContext
().
getContentResolver
(),
Settings
.
Secure
.
DEFAULT_INPUT_METHOD
);
// The Samsung keyboard is called "com.sec.android.inputmethod/.SamsungKeypad" but look
// for "Samsung" just in case Samsung changes the name of the keyboard.
return
keyboardName
.
contains
(
"Samsung"
);
if
(!
keyboardName
.
contains
(
"Samsung"
))
{
return
false
;
}
final
long
versionCode
;
try
{
versionCode
=
mView
.
getContext
()
.
getPackageManager
()
.
getPackageInfo
(
"com.sec.android.inputmethod"
,
0
)
.
getLongVersionCode
();
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
Log
.
w
(
TAG
,
"com.sec.android.inputmethod is not installed."
);
return
false
;
}
// 3.3.23.33 is a known version that's free of the aforementioned bug.
// 3.0.24.96 still has this bug.
// TODO(LongCatIsLooong): Find the minimum version that has the fix.
return
versionCode
<
332333999
;
}
@VisibleForTesting
...
...
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
浏览文件 @
16870408
...
...
@@ -18,6 +18,7 @@ import static org.mockito.Mockito.when;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.res.AssetManager
;
import
android.graphics.Insets
;
import
android.graphics.Rect
;
...
...
@@ -64,6 +65,7 @@ import org.mockito.ArgumentCaptor;
import
org.mockito.Mock
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.RuntimeEnvironment
;
import
org.robolectric.Shadows
;
import
org.robolectric.annotation.Config
;
import
org.robolectric.annotation.Implementation
;
import
org.robolectric.annotation.Implements
;
...
...
@@ -71,6 +73,7 @@ import org.robolectric.shadow.api.Shadow;
import
org.robolectric.shadows.ShadowAutofillManager
;
import
org.robolectric.shadows.ShadowBuild
;
import
org.robolectric.shadows.ShadowInputMethodManager
;
import
org.robolectric.shadows.ShadowPackageManager
;
@Config
(
manifest
=
Config
.
NONE
,
...
...
@@ -339,14 +342,21 @@ public class TextInputPluginTest {
assertTrue
(
textInputPlugin
.
getEditable
().
toString
().
equals
(
"Shibuyawoo"
));
}
// See https://github.com/flutter/flutter/issues/29341 and
// https://github.com/flutter/flutter/issues/31512
//
All modern Samsung keybords are affected including non-korean languages and thus
//
ne
ed the restart.
// See
also:
https://github.com/flutter/flutter/issues/29341 and
// https://github.com/flutter/flutter/issues/31512
.
//
Some recent versions of Samsung keybords are affected including non-korean
//
languages and thus need
ed the restart.
@Test
public
void
setTextInputEditingState_alwaysRestartsOnAffectedDevices
2
()
{
// Initialize a TextInputPlugin
that needs to be always restarte
d.
public
void
setTextInputEditingState_alwaysRestartsOnAffectedDevices
()
{
// Initialize a TextInputPlugin
with a Samsung keypa
d.
ShadowBuild
.
setManufacturer
(
"samsung"
);
final
ShadowPackageManager
packageManager
=
Shadows
.
shadowOf
(
RuntimeEnvironment
.
application
.
getApplicationContext
().
getPackageManager
());
final
PackageInfo
info
=
new
PackageInfo
();
info
.
packageName
=
"com.sec.android.inputmethod"
;
info
.
versionCode
=
200000000
;
packageManager
.
addPackage
(
info
);
InputMethodSubtype
inputMethodSubtype
=
new
InputMethodSubtype
(
0
,
0
,
/*locale=*/
"en"
,
""
,
""
,
false
,
false
);
Settings
.
Secure
.
putString
(
...
...
@@ -386,6 +396,59 @@ public class TextInputPluginTest {
assertEquals
(
2
,
testImm
.
getRestartCount
(
testView
));
}
// Regression test for https://github.com/flutter/flutter/issues/73433.
// The restart workaround seems to have caused #73433 and it's no longer
// needed on newer versions of Samsung keyboard.
@Test
public
void
setTextInputEditingState_DontForceRestartOnNewSamsungKeyboard
()
{
// Initialize a TextInputPlugin with a Samsung keypad.
ShadowBuild
.
setManufacturer
(
"samsung"
);
final
ShadowPackageManager
packageManager
=
Shadows
.
shadowOf
(
RuntimeEnvironment
.
application
.
getApplicationContext
().
getPackageManager
());
final
PackageInfo
info
=
new
PackageInfo
();
info
.
packageName
=
"com.sec.android.inputmethod"
;
info
.
versionCode
=
333183070
;
packageManager
.
addPackage
(
info
);
InputMethodSubtype
inputMethodSubtype
=
new
InputMethodSubtype
(
0
,
0
,
/*locale=*/
"en"
,
""
,
""
,
false
,
false
);
Settings
.
Secure
.
putString
(
RuntimeEnvironment
.
application
.
getContentResolver
(),
Settings
.
Secure
.
DEFAULT_INPUT_METHOD
,
"com.sec.android.inputmethod/.SamsungKeypad"
);
TestImm
testImm
=
Shadow
.
extract
(
RuntimeEnvironment
.
application
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
));
testImm
.
setCurrentInputMethodSubtype
(
inputMethodSubtype
);
View
testView
=
new
View
(
RuntimeEnvironment
.
application
);
TextInputChannel
textInputChannel
=
new
TextInputChannel
(
mock
(
DartExecutor
.
class
));
TextInputPlugin
textInputPlugin
=
new
TextInputPlugin
(
testView
,
textInputChannel
,
mock
(
PlatformViewsController
.
class
));
textInputPlugin
.
setTextInputClient
(
0
,
new
TextInputChannel
.
Configuration
(
false
,
false
,
true
,
TextInputChannel
.
TextCapitalization
.
NONE
,
null
,
null
,
null
,
null
,
null
));
// There's a pending restart since we initialized the text input client. Flush that now.
textInputPlugin
.
setTextInputEditingState
(
testView
,
new
TextInputChannel
.
TextEditState
(
""
,
0
,
0
,
-
1
,
-
1
));
// Move the cursor.
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
textInputPlugin
.
setTextInputEditingState
(
testView
,
new
TextInputChannel
.
TextEditState
(
""
,
0
,
0
,
-
1
,
-
1
));
// Verify that we've NOT restarted the input.
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
}
@Test
public
void
setTextInputEditingState_doesNotRestartOnUnaffectedDevices
()
{
// Initialize a TextInputPlugin that needs to be always restarted.
...
...
@@ -425,7 +488,7 @@ public class TextInputPluginTest {
textInputPlugin
.
setTextInputEditingState
(
testView
,
new
TextInputChannel
.
TextEditState
(
""
,
0
,
0
,
-
1
,
-
1
));
// Verify that we've restarted the input.
// Verify that we've
NOT
restarted the input.
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录