Skip to content

Commit

Permalink
flag clipboard content as sensitive for password. should fix #37
Browse files Browse the repository at this point in the history
  • Loading branch information
dkunzler committed Dec 28, 2022
1 parent dce6b99 commit ada6c57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/de/devland/masterpassword/ui/EditFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ada6c57

Please sign in to comment.