Skip to content

set clipboard data crashed on few phones #102300

@wangying3426

Description

@wangying3426

setPrimaryClip crashed on a few phones. The stack trace is:

PlatformException(error, Package com.miHoYo.Yuanshen does not belong to 10359, null, {}, java.lang.SecurityException: Package com.miHoYo.Yuanshen does not belong to 10359
	at android.os.Parcel.createExceptionOrNull(Parcel.java:2425)
	at android.os.Parcel.createException(Parcel.java:2409)
	at android.os.Parcel.readException(Parcel.java:2392)
	at android.os.Parcel.readException(Parcel.java:2334)
	at android.content.IClipboard$Stub$Proxy.setPrimaryClip(IClipboard.java:430)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.bytedance.privacy.toolkit.service.core.IServiceHookBase.intercept(Unknown Source:9)
	at com.bytedance.privacy.toolkit.service.sys.Clipboard.invoke(Unknown Source:113)
	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
	at $Proxy34.setPrimaryClip(Unknown Source)
	at android.content.ClipboardManager.setPrimaryClip(ClipboardManager.java:133)
	at io.flutter.plugin.platform.PlatformPlugin.setClipboardData(Unknown Source:16)
	at io.flutter.plugin.platform.PlatformPlugin.access$800(Unknown Source:0)
	at io.flutter.plugin.platform.PlatformPlugin$1.setClipboardData(Unknown Source:2)
	at io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(Unknown Source:210)
	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17)
	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(Unknown Source:54)
	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:337)
	at android.os.Looper.loopOnce(Looper.java:168)
	at android.os.Looper.loop(Looper.java:299)
	at android.app.ActivityThread.main(ActivityThread.java:8085)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: android.os.RemoteException: Remote stack trace:
	at android.app.AppOpsManager.checkPackage(AppOpsManager.java:8739)
	at com.android.server.clipboard.ClipboardService.clipboardAccessAllowed(ClipboardService.java:989)
	at com.android.server.clipboard.ClipboardService.sendClipChangedBroadcast(ClipboardService.java:704)
	at com.android.server.clipboard.ClipboardService.setPrimaryClipInternalLocked(ClipboardService.java:692)
	at com.android.server.clipboard.ClipboardService.setPrimaryClipInternalLocked(ClipboardService.java:618)
)
#0      JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:158)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:306)
<asynchronous suspension>
#2      _getZoneSpecification.<anonymous closure>.<anonymous closure> (package:bd_vessel/extension/errortrace/internal/error_trace_utils.dart:89)
<asynchronous suspension>

There are some discussion of similar issues on stackoverflow site, such as SecurityException: <<other_package>> from uid xxx not allowed to perform READ_CLIPBOARD when calling setPrimaryClip

Unfortunately, this exception is only reproduce in production, I have not reproduce it locally.
Then I fixed it by adding a try catch block, see flutter/engine#32832.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: productionIssues experienced in live production appsc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions