Bug 417419 - Support 'send text' while android 10 prevent global clipboard.
Summary: Support 'send text' while android 10 prevent global clipboard.
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (show other bugs)
Version: unspecified
Platform: Android Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-11 12:39 UTC by wowlinux
Modified: 2020-03-12 03:56 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wowlinux 2020-02-11 12:39:58 UTC
SUMMARY
Android 10 disable global clipboard reading, so the 'share clipboard' plugin doesn't function.

EXPECTED RESULT
Able to send text from phone to PC.

SOFTWARE/OS VERSIONS
App Version: 1.13
Comment 1 Gerd 2020-02-24 20:23:07 UTC
There is maybe a workaround for the clipboartd reading:

I am using a multi clipboard manager called "Clip Stack", which is also
affected by this Google limitation, but its developer has found a
workaround which might also work for KDE Connect in a similar way.

See
https://play.google.com/store/apps/details?id=com.catchingnow.tinyclipboardmanager,
where the developer also has described who to make it work by simply
applying some ADB commands from a PC:

  adb -d shell appops set com.catchingnow.tinyclipboardmanager
SYSTEM_ALERT_WINDOW allow;
  adb -d shell pm grant com.catchingnow.tinyclipboardmanager
android.permission.READ_LOGS;
  adb -d shell am force-stop com.catchingnow.tinyclipboardmanager;
Comment 2 Simon Redman 2020-03-12 03:56:39 UTC
Git commit b81d3a82e5a71757388fffb4a3b3486aea74d1aa by Simon Redman, on behalf of Anjani Kumar.
Committed on 12/03/2020 at 03:56.
Pushed by sredman into branch 'master'.

Make Clipboard plugin work in Android X

## Summary

Fixes #5

This patch introduces a workaround to access the restricted clipboard in Android X.
Clipboard synchronisation in KDE Connect was one of the killer features before Android X. An action button is added in the persistent foreground notification **Send Clipboard** which adds the ability to send the clipboard using a small workaround. Clipboard Synchronisation works as usual in lower Android Versions.

This is a very convenient workaround for sending clipboard quickly as it does not requires to open the app. Floating Activity is quite handy for quick actions.

## Details of the workaround

### ClipboardFloatingActivity

* This activity is only executed in Android X.
* This is transparent, accesses the clipboard when in focus.
* Sends a `NetworkPacket` containing *text* and *timestamp*.
* When the packet has been sent, it pops up a toast with a success message.
* Automatically closes after the showing the Toast.

### Reverted changes for Android X.

* Changes done in commits 54be4a1a997e14516353f5104ef1619f98ba99ec and 9f3b75b7483fe79527d635ad10a2bb7cf6496d8c have been reverted.
* These changes are not required anymore as the workaround for clipboard sync works.

The action button in the notification for **Send Clipboard** is not added in the lower versions of Android. **It is only added in Android X**.

**Two way sync is working in Android X with this patch. Sync works normally in lower Android versions.**

## Test Plan

### Before:

Clipboard from PC to Phones were synchronised but Clipboard of phones didn't get synchronised with the PC.

### After:

The action button is up in Android X while using other apps.

![Screenshot_20200227-150435_Chrome](/uploads/201960e1577321c8a77c9945bd2b5e76/Screenshot_20200227-150435_Chrome.png)

After clicking the button, a cute Toast appears with the message *Clipboard sent*

![Screenshot_20200228-233701_Chrome](/uploads/8da58b1006b95ce82c7cec2c91f32878/Screenshot_20200228-233701_Chrome.png)

I think this is one of the best workarounds available to make this awesome plugin work.

M  +3    -0    AndroidManifest.xml
M  +2    -0    res/values/strings.xml
M  +8    -0    res/values/styles.xml
M  +9    -0    src/org/kde/kdeconnect/BackgroundService.java
A  +50   -0    src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardFloatingActivity.java
M  +1    -24   src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardPlugin.java
M  +0    -6    src/org/kde/kdeconnect/UserInterface/MainActivity.java
D  +0    -68   src/org/kde/kdeconnect/UserInterface/NoticeAlertDialogFragment.java

https://invent.kde.org/kde/kdeconnect-android/commit/b81d3a82e5a71757388fffb4a3b3486aea74d1aa
Comment 3 Simon Redman 2020-03-12 03:56:39 UTC
Git commit b81d3a82e5a71757388fffb4a3b3486aea74d1aa by Simon Redman, on behalf of Anjani Kumar.
Committed on 12/03/2020 at 03:56.
Pushed by sredman into branch 'master'.

Make Clipboard plugin work in Android X

## Summary

Fixes #5

This patch introduces a workaround to access the restricted clipboard in Android X.
Clipboard synchronisation in KDE Connect was one of the killer features before Android X. An action button is added in the persistent foreground notification **Send Clipboard** which adds the ability to send the clipboard using a small workaround. Clipboard Synchronisation works as usual in lower Android Versions.

This is a very convenient workaround for sending clipboard quickly as it does not requires to open the app. Floating Activity is quite handy for quick actions.

## Details of the workaround

### ClipboardFloatingActivity

* This activity is only executed in Android X.
* This is transparent, accesses the clipboard when in focus.
* Sends a `NetworkPacket` containing *text* and *timestamp*.
* When the packet has been sent, it pops up a toast with a success message.
* Automatically closes after the showing the Toast.

### Reverted changes for Android X.

* Changes done in commits 54be4a1a997e14516353f5104ef1619f98ba99ec and 9f3b75b7483fe79527d635ad10a2bb7cf6496d8c have been reverted.
* These changes are not required anymore as the workaround for clipboard sync works.

The action button in the notification for **Send Clipboard** is not added in the lower versions of Android. **It is only added in Android X**.

**Two way sync is working in Android X with this patch. Sync works normally in lower Android versions.**

## Test Plan

### Before:

Clipboard from PC to Phones were synchronised but Clipboard of phones didn't get synchronised with the PC.

### After:

The action button is up in Android X while using other apps.

![Screenshot_20200227-150435_Chrome](/uploads/201960e1577321c8a77c9945bd2b5e76/Screenshot_20200227-150435_Chrome.png)

After clicking the button, a cute Toast appears with the message *Clipboard sent*

![Screenshot_20200228-233701_Chrome](/uploads/8da58b1006b95ce82c7cec2c91f32878/Screenshot_20200228-233701_Chrome.png)

I think this is one of the best workarounds available to make this awesome plugin work.

M  +3    -0    AndroidManifest.xml
M  +2    -0    res/values/strings.xml
M  +8    -0    res/values/styles.xml
M  +9    -0    src/org/kde/kdeconnect/BackgroundService.java
A  +50   -0    src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardFloatingActivity.java
M  +1    -24   src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardPlugin.java
M  +0    -6    src/org/kde/kdeconnect/UserInterface/MainActivity.java
D  +0    -68   src/org/kde/kdeconnect/UserInterface/NoticeAlertDialogFragment.java

https://invent.kde.org/kde/kdeconnect-android/commit/b81d3a82e5a71757388fffb4a3b3486aea74d1aa