Clipboard Protection¶
Preventing the ability to copy or paste content may be required for applications that handle confidential or sensitive data, where it is therefore important to prevent data from crossing the application boundary through user actions or via a clipboard. Also, even when malware is not able to penetrate an application, it could still possibly read the contents of the clipboard to potentially steal the data.
The mobile services has integrated the ClipboardManager
API to access and manage the system clipboard. After clipboard protection is enabled on the server, the developer can add the ClipboardProtectionService
instance to the SDKInitializer.start
method. Then, it will handle the primary clip data stored in the clipboard to ensure that the data copied or cut from outside will not be pasted inside a protected application and vice-versa.
ClipboardProtectionService
takes one optional argument in the constructor to indicate whether to enable protection before retrieving the signal from the server. By default, it will be disabled.
val services = mutableListOf<MobileService>()
services.add(ClipboardProtectionService(initClipboardProtectionEnabled = true))
SDKInitializer.start(this, * services.toTypedArray())
Note
For Samsung devices with an Android version lower than 12, when entering the app from outside, it will paste " " when protection enabled.
When Gboard's clipboard
is turned on in Pixels (or something similar on other devices), recently copied or cut content will be displayed in the clipboard and protection will be bypassed.