From ada6c57f4336786b00a21f2ddd92f27b1fd738eb Mon Sep 17 00:00:00 2001 From: David Kunzler Date: Wed, 28 Dec 2022 23:22:05 +0100 Subject: [PATCH] flag clipboard content as sensitive for password. should fix #37 --- .../de/devland/masterpassword/ui/EditFragment.java | 14 ++++++++++---- .../masterpassword/ui/passwordlist/SiteCard.java | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/devland/masterpassword/ui/EditFragment.java b/app/src/main/java/de/devland/masterpassword/ui/EditFragment.java index 2dfb0c4..f9ce232 100644 --- a/app/src/main/java/de/devland/masterpassword/ui/EditFragment.java +++ b/app/src/main/java/de/devland/masterpassword/ui/EditFragment.java @@ -2,12 +2,11 @@ import android.app.Activity; -import android.content.ClipData; -import android.content.ClipboardManager; -import android.content.Context; -import android.content.Intent; +import android.content.*; import android.graphics.Typeface; +import android.os.Build; import android.os.Bundle; +import android.os.PersistableBundle; import androidx.fragment.app.Fragment; import androidx.core.app.NavUtils; import androidx.appcompat.app.ActionBar; @@ -286,6 +285,13 @@ void copyPasswordToClipboard() { final ClipboardManager clipboard = (ClipboardManager) App.get() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("password", password.getText()); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + PersistableBundle extras = new PersistableBundle(); + extras.putBoolean("android.content.extra.IS_SENSITIVE", true); + clip.getDescription().setExtras(extras); + } + clipboard.setPrimaryClip(clip); Intent service = new Intent(App.get(), ClearClipboardService.class); diff --git a/app/src/main/java/de/devland/masterpassword/ui/passwordlist/SiteCard.java b/app/src/main/java/de/devland/masterpassword/ui/passwordlist/SiteCard.java index d349fc0..7447070 100644 --- a/app/src/main/java/de/devland/masterpassword/ui/passwordlist/SiteCard.java +++ b/app/src/main/java/de/devland/masterpassword/ui/passwordlist/SiteCard.java @@ -5,6 +5,8 @@ import android.content.Context; import android.content.Intent; import android.graphics.Typeface; +import android.os.Build; +import android.os.PersistableBundle; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.appcompat.widget.PopupMenu; @@ -137,6 +139,11 @@ void copyPasswordToClipboard() { final ClipboardManager clipboard = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("password", generatedPassword); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + PersistableBundle extras = new PersistableBundle(); + extras.putBoolean("android.content.extra.IS_SENSITIVE", true); + clip.getDescription().setExtras(extras); + } clipboard.setPrimaryClip(clip); Intent service = new Intent(context, ClearClipboardService.class);