Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
22436cca
Unverified
Commit
22436cca
authored
Aug 02, 2021
by
Angjie Li
Committed by
GitHub
Aug 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Avoid passive clipboard read on Android (#86791)" (#87375)
parent
962f57f8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
54 deletions
+23
-54
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+8
-16
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+7
-13
text_selection_test.dart
packages/flutter/test/material/text_selection_test.dart
+3
-7
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+1
-1
text_selection_test.dart
packages/flutter/test/widgets/text_selection_test.dart
+4
-17
No files found.
packages/flutter/lib/src/widgets/text_selection.dart
View file @
22436cca
...
...
@@ -1655,16 +1655,6 @@ class ClipboardStatusNotifier extends ValueNotifier<ClipboardStatus> with Widget
/// Check the [Clipboard] and update [value] if needed.
Future
<
void
>
update
()
async
{
switch
(
defaultTargetPlatform
)
{
// Android 12 introduces a toast message that appears when an app reads
// the content on the clipboard. To avoid unintended access, both the
// Flutter engine and the Flutter framework need to be updated to use the
// appropriate API to check whether the clipboard is empty.
// As a short-term workaround, always show the paste button.
// TODO(justinmc): Expose `hasStrings` in `Clipboard` and use that instead
// https://github.com/flutter/flutter/issues/74139
case
TargetPlatform
.
android
:
// Intentionally fall through.
// iOS 14 added a notification that appears when an app accesses the
// clipboard. To avoid the notification, don't access the clipboard on iOS,
// and instead always show the paste button, even when the clipboard is
...
...
@@ -1672,9 +1662,11 @@ class ClipboardStatusNotifier extends ValueNotifier<ClipboardStatus> with Widget
// TODO(justinmc): Use the new iOS 14 clipboard API method hasStrings that
// won't trigger the notification.
// https://github.com/flutter/flutter/issues/60145
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
value
=
ClipboardStatus
.
pasteable
;
return
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
...
...
packages/flutter/test/material/text_field_test.dart
View file @
22436cca
...
...
@@ -928,7 +928,7 @@ void main() {
),
);
focusNode
.
requestFocus
();
await
tester
.
pump
AndSettle
();
await
tester
.
pump
();
await
expectLater
(
find
.
byType
(
TextField
),
...
...
@@ -956,7 +956,7 @@ void main() {
),
);
focusNode
.
requestFocus
();
await
tester
.
pump
AndSettle
();
await
tester
.
pump
();
await
expectLater
(
find
.
byType
(
TextField
),
...
...
@@ -984,7 +984,7 @@ void main() {
),
);
focusNode
.
requestFocus
();
await
tester
.
pump
AndSettle
();
await
tester
.
pump
();
await
expectLater
(
find
.
byType
(
TextField
),
...
...
@@ -6223,13 +6223,10 @@ void main() {
semantics
.
dispose
();
// On web
, we don't check for pasteability because that triggers a
// permission dialog in the browser.
// On web
(just like iOS), we don't check for pasteability because that
//
triggers a
permission dialog in the browser.
// https://github.com/flutter/flutter/pull/57139#issuecomment-629048058
// TODO(justinmc): Remove TargetPlatform override when Android and iOS uses
// `hasStrings` to check for pasteability.
// https://github.com/flutter/flutter/issues/74139
},
skip:
isBrowser
,
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
linux
}));
},
skip:
isBrowser
);
testWidgets
(
'TextField throws when not descended from a Material widget'
,
(
WidgetTester
tester
)
async
{
const
Widget
textField
=
TextField
();
...
...
@@ -9591,10 +9588,7 @@ void main() {
// pasted.
expect
(
triedToReadClipboard
,
true
);
}
// TODO(justinmc): Eventually, all platform should call `hasStrings` instead.
// This entire test will become irrelevant after the fact.
// https://github.com/flutter/flutter/issues/74139
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
linux
}));
});
testWidgets
(
'TextField changes mouse cursor when hovered'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/material/text_selection_test.dart
View file @
22436cca
...
...
@@ -615,9 +615,7 @@ void main() {
});
});
// TODO(justinmc): Paste should only appears when the clipboard has contents.
// https://github.com/flutter/flutter/issues/74139
testWidgets
(
'Paste always appears regardless of clipboard content on Android'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Paste only appears when clipboard has contents'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'Atwater Peel Sherbrooke Bonaventure'
,
);
...
...
@@ -645,10 +643,8 @@ void main() {
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
index
));
await
tester
.
pumpAndSettle
();
// Paste is showing even though clipboard is empty.
// TODO(justinmc): Paste should not appears when the clipboard is empty.
// https://github.com/flutter/flutter/issues/74139
expect
(
find
.
text
(
'Paste'
),
findsOneWidget
);
// No Paste yet, because nothing has been copied.
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
expect
(
find
.
text
(
'Copy'
),
findsOneWidget
);
expect
(
find
.
text
(
'Cut'
),
findsOneWidget
);
expect
(
find
.
text
(
'Select all'
),
findsOneWidget
);
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
22436cca
...
...
@@ -2553,7 +2553,7 @@ void main() {
));
semanticsOwner
.
performAction
(
inputFieldId
,
SemanticsAction
.
longPress
);
await
tester
.
pump
AndSettle
();
await
tester
.
pump
();
expect
(
semantics
,
hasSemantics
(
TestSemantics
.
root
(
...
...
packages/flutter/test/widgets/text_selection_test.dart
View file @
22436cca
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
show
PointerDeviceKind
,
kSecondaryButton
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -766,19 +765,13 @@ void main() {
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
platform
,
null
);
});
// TODO(justinmc): See if `testWidgets` can be reverted to `test`.
testWidgets
(
'Clipboard API failure is gracefully recovered from'
,
(
WidgetTester
tester
)
async
{
test
(
'Clipboard API failure is gracefully recovered from'
,
()
async
{
final
ClipboardStatusNotifier
notifier
=
ClipboardStatusNotifier
();
expect
(
notifier
.
value
,
ClipboardStatus
.
unknown
);
await
expectLater
(
notifier
.
update
(),
completes
);
expect
(
notifier
.
value
,
ClipboardStatus
.
unknown
);
// TODO(justinmc): Currently on Android and iOS, ClipboardStatus.pasteable
// is always returned. Once both platforms properly use
// `hasStrings` to check whether the clipboard has any
// content, try to see if this override can be removed.
// https://github.com/flutter/flutter/issues/74139
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
linux
}));
});
});
group
(
'when Clipboard succeeds'
,
()
{
...
...
@@ -792,8 +785,7 @@ void main() {
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
platform
,
null
);
});
// TODO(justinmc): See if `testWidgets` can be reverted to `test`.
testWidgets
(
'update sets value based on clipboard contents'
,
(
WidgetTester
tester
)
async
{
test
(
'update sets value based on clipboard contents'
,
()
async
{
final
ClipboardStatusNotifier
notifier
=
ClipboardStatusNotifier
();
expect
(
notifier
.
value
,
ClipboardStatus
.
unknown
);
...
...
@@ -808,12 +800,7 @@ void main() {
));
await
expectLater
(
notifier
.
update
(),
completes
);
expect
(
notifier
.
value
,
ClipboardStatus
.
pasteable
);
// TODO(justinmc): Currently on Android and iOS, ClipboardStatus.pasteable
// is always returned. Once both platforms properly use
// `hasStrings` to check whether the clipboard has any
// content, try to see if this override can be removed.
// https://github.com/flutter/flutter/issues/74139
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
linux
}));
});
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment