plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: Sharing file loses attachment when passing through security lockscreen

Open britohyago opened this issue 1 year ago • 2 comments

Platform

Poco X3 Pro (Android 12, MIUI 13.0.3)

Plugin

share_plus

Version

9.0.0

Flutter SDK

3.22.2

Steps to reproduce

  1. Click button to share a file
  2. Select Gmail

My code generates an image that can be shared through other apps normally (WhatsApp, Instagram, Outlook), but with Gmail, when the share action passes through the lockscreen (native MIUI app for locking apps, or other types of authenticators) (pattern/fingerprint) it loses the file and do not attach it. When I remove the lockscreen of gmail, it works well.

PS: No error logs are displayed.

PS: WhatsApp, Instagram and Outlook have the same lockscreen as well and works fine.

Code Sample

final picture = recorder.endRecording();
final img = await picture.toImage(imageWidth.toInt(), imageHeight.toInt());
final byteData = await img.toByteData(format: ui.ImageByteFormat.png);

if (byteData != null) {
   final buffer = byteData.buffer.asUint8List();

   final tempDir = await getTemporaryDirectory();
   final file =
          await File('${tempDir.path}/custom_image.png').writeAsBytes(buffer);

   await Share.shareXFiles([XFile(file.path)]);
}

Logs

D/DecorView[](21998): onWindowFocusChanged hasWindowFocus false
I/FA      (21998): Application backgrounded at: timestamp_millis: 1728572292234
D/AppScoutStateMachine(21998): 21998-ScoutStateMachinecreated
D/SurfaceView(21998): UPDATE Surface(name=SurfaceView[com.garen_installer_app/com.garen_installer_app.MainActivity])/@0x58974bf, mIsProjectionMode = false
3
D/SurfaceControl(21998): nativeSetScreenProjection ===> setScreenProjection
I/OpenGLRenderer(21998): Davey! duration=41249ms; Flags=1, FrameTimelineVsyncId=38648698, IntendedVsync=768137994690308, Vsync=768137994690308, InputEventId=741240109, HandleInputStart=768137997221399, AnimationStart=768137997223170, PerformTraversalsStart=768137997224212, DrawStart=768138024604316, FrameDeadline=768138028023640, FrameInterval=768137997214212, FrameStartTime=16666666, SyncQueued=768138024864108, SyncStart=768138024989264, IssueDrawCommandsStart=768138025155305, SwapBuffers=768138027755358, FrameCompleted=768179244523415, DequeueBufferDuration=1549844, QueueBufferDuration=1035938, GpuCompleted=768179244523415, SwapBuffersCompleted=768138029437024, DisplayPresentTime=0,

Flutter Doctor

[✓] Flutter (Channel stable, 3.22.2, on Ubuntu 22.04.4 LTS 6.8.0-45-generic, locale pt_BR.UTF-8)
    • Flutter version 3.22.2 on channel stable at /home/hyago/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (4 months ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/hyago/Android/Sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2023.1)
    • Android Studio at /home/hyago/Documentos/AndroidStudio/android-studio-2023.1.1.27-linux/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.94.1)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.98.0

[✓] Connected device (3 available)
    • M2102J20SG (mobile) • 440524eb • android-arm64  • Android 12 (API 31)
    • Linux (desktop)     • linux    • linux-x64      • Ubuntu 22.04.4 LTS 6.8.0-45-generic
    • Chrome (web)        • chrome   • web-javascript • Google Chrome 127.0.6533.88

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Checklist before submitting a bug

  • [X] I searched issues in this repository and couldn't find such bug/problem
  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I'm using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

britohyago avatar Oct 10 '24 15:10 britohyago

Sounds like an OS/Gmail bug. The plugin launches the native share mechanism, what happens after is not controlled by it.

miquelbeltran avatar Oct 10 '24 18:10 miquelbeltran

I understand, but when I share a picture from my gallery for example, to Gmail, it works well, maybe it is related to Flutter as well? Or even Android version? since on Android 13 and 14 it shares normally even with lockscreen before gmail

britohyago avatar Oct 11 '24 11:10 britohyago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Jan 10 '25 00:01 github-actions[bot]