react-native-clipboard / clipboard

React Native Clipboard API for both iOS and Android.
MIT License
698 stars 145 forks source link

Fatal Exception: ClipboardModule.java line 9 #54

Open fonov opened 4 years ago

fonov commented 4 years ago
Screenshot 2020-06-23 at 14 33 17
Environment System: OS: macOS 10.15.5 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 234.47 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.14.0 - ~/.nvm/versions/node/v13.14.0/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - ~/.nvm/versions/node/v13.14.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: API Levels: 23, 24, 25, 27, 28, 29 Build Tools: 28.0.3, 29.0.1, 29.0.2 System Images: android-16 | Google APIs Intel x86 Atom, android-22 | Google APIs ARM EABI v7a, android-22 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom Android NDK: 17.2.4988734 IDEs: Android Studio: Not Found Xcode: 11.5/11E608c - /usr/bin/xcodebuild Languages: Java: 1.8.0_222 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: 0.62.2 => 0.62.2 npmGlobalPackages: *react-native*: Not Found
Platforms Android
Versions Device Brand: Realme Model: realme C2 Orientation: Portrait RAM free: 676.65 MB Disk free: 10.74 GB Operating System Version: 9 Orientation: Portrait Rooted: No

Description

last version

"@react-native-community/clipboard": "^1.2.2",

Got error from Crashlytics

ClipboardModule.java line 9
com.reactnativecommunity.clipboard.ClipboardModule.setString

Fatal Exception: java.lang.SecurityException
com.mbmobile from uid 10184 not allowed to perform READ_CLIPBOARD
com.reactnativecommunity.clipboard.ClipboardModule.setString
Naturalclar commented 4 years ago

@fonov thanks for raising the issue! the issue seems to be related to the privacy change in Android 10 https://developer.android.com/about/versions/10/privacy/changes#clipboard-data I'll look further into a possible workaround on this

joelfernandes19 commented 4 years ago

@Naturalclar Facing the same issue, and it's throwing security exception on another app that is trying to read clipboard data when my app (which is in focus) is calling setPrimaryClip. Unable to reproduce the issue though. Is there any workaround you found for this?

outofmemory commented 3 years ago

APP A: foreground app APP B: background app which setup 'addPrimaryClipChangedListener'

  1. APP A calls setPrimaryClipboard.
  2. then ClipboardService will broadcast the event to PrimaryClipChangedListener (e.g. APP B) and will also make a call to AppOpsManager.noteOp to inform about READ_CLIPBOARD operation.
  3. If the listener(APP B) is not allowed to READ_CLIPBOARD, AppOpsManager.noteOp will throw a SecurityException and will crash the foreground app(APP A).
  4. and the clipboard is set successful

HOW TO REPRODUCE: we can disable READ_CLIPBOARD permission manually for reproducing

HOW TO DISABLE READ_CLIPBOARD: step 1: connect adb step 2: adb shell step 3: cmd appops set app.package.name READ_CLIPBOARD deny