背景
最近突然收到安全部门的消息,说有些页面在获取剪切板内容。我当时很确性的说,我压根没去获取剪切板内容啊。
但是他给出了具体的调用堆栈,这一看果然是真的。
at android.content.ClipboardManager.getPrimaryClip(Native Method) at
io.flutter.plugin.platform.PlatformPlugin.getClipboardData(PlatformPlugin.java:332) at
io.flutter.plugin.platform.PlatformPlugin.access$700(PlatformPlugin.java:28) at
io.flutter.plugin.platform.PlatformPlugin$1.getClipboardData(PlatformPlugin.java:107) at
io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:141) at
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) at
io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) at
io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) at
android.os.MessageQueue.nativePollOnce(Native Method) at
android.os.MessageQueue.next(MessageQueue.java:325) at
android.os.Looper.loop(Looper.java:142) at
android.app.ActivityThread.main(ActivityThread.java:6549) at java.lang.reflect.Method.invoke(Native
Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
找出问题
1.确定是什么原因导致的
根据截图的几个页面,当然他当时截图的页面是不对的,但是这个页面的后一个页面。
我是根据断点原生代码去确定范围的。
发现出现在了地址编辑页,根据经验判断问题出现在了输入框上。
然后我在flutter项目中搜索 Clipboard.getData

为什么搜索这个也是根据上面的堆栈那确定的
io

本文探讨了一次剪贴板监控引发的误触发事件,通过追踪代码发现EditableText组件与ClipboardStatusNotifier的关联,最终定位到初始化问题。作者提供了两种解决方法:修改原生代码或在Flutter插件层面进行干预。
最低0.47元/天 解锁文章
4839





