moved broadcast receiver for copy to clipboard outside of service. This allows to receive the broadcast even if the app was killed. We can display at a message then.

added permission for broadcast to prevent malicious apps from copying to clipboard without the user action
This commit is contained in:
Philipp Crocoll 2014-05-24 07:19:50 +02:00
parent 6f38305838
commit 5cf8b8450d
7 changed files with 279 additions and 209 deletions

View File

@ -17,6 +17,8 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Android.App; using Android.App;
using Android.Content.PM;
using keepass2android;
// Information about this assembly is defined by the following attributes. // Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project. // Change them to the values specific to your project.
@ -42,3 +44,5 @@ using Android.App;
//[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")] //[assembly: AssemblyKeyFile("")]
[assembly: Permission(Name = "keepass2android."+AppNames.PackagePart+".permission.CopyToClipboard", Label = "CopyToClipboard", ProtectionLevel=Protection.Signature)]
[assembly: UsesPermission(Name = "keepass2android." + AppNames.PackagePart + ".permission.CopyToClipboard")]

View File

@ -3431,59 +3431,59 @@ namespace keepass2android
// aapt resource value: 0x7f090271 // aapt resource value: 0x7f090271
public const int CannotMoveGroupHere = 2131296881; public const int CannotMoveGroupHere = 2131296881;
// aapt resource value: 0x7f0902b8
public const int CertificateFailure = 2131296952;
// aapt resource value: 0x7f0902b7
public const int CertificateWarning = 2131296951;
// aapt resource value: 0x7f0902c9
public const int ChangeLog = 2131296969;
// aapt resource value: 0x7f0902c8
public const int ChangeLog_0_7 = 2131296968;
// aapt resource value: 0x7f0902c6
public const int ChangeLog_0_8 = 2131296966;
// aapt resource value: 0x7f0902c5
public const int ChangeLog_0_8_1 = 2131296965;
// aapt resource value: 0x7f0902c4
public const int ChangeLog_0_8_2 = 2131296964;
// aapt resource value: 0x7f0902c3
public const int ChangeLog_0_8_3 = 2131296963;
// aapt resource value: 0x7f0902c2
public const int ChangeLog_0_8_4 = 2131296962;
// aapt resource value: 0x7f0902c1
public const int ChangeLog_0_8_5 = 2131296961;
// aapt resource value: 0x7f0902c0
public const int ChangeLog_0_8_6 = 2131296960;
// aapt resource value: 0x7f0902bf
public const int ChangeLog_0_9 = 2131296959;
// aapt resource value: 0x7f0902be
public const int ChangeLog_0_9_1 = 2131296958;
// aapt resource value: 0x7f0902bd // aapt resource value: 0x7f0902bd
public const int ChangeLog_0_9_2 = 2131296957; public const int CertificateFailure = 2131296957;
// aapt resource value: 0x7f0902bc // aapt resource value: 0x7f0902bc
public const int ChangeLog_0_9_3 = 2131296956; public const int CertificateWarning = 2131296956;
// aapt resource value: 0x7f0902bb // aapt resource value: 0x7f0902cf
public const int ChangeLog_0_9_3_r5 = 2131296955; public const int ChangeLog = 2131296975;
// aapt resource value: 0x7f0902ce
public const int ChangeLog_0_7 = 2131296974;
// aapt resource value: 0x7f0902cc
public const int ChangeLog_0_8 = 2131296972;
// aapt resource value: 0x7f0902cb
public const int ChangeLog_0_8_1 = 2131296971;
// aapt resource value: 0x7f0902ca
public const int ChangeLog_0_8_2 = 2131296970;
// aapt resource value: 0x7f0902c9
public const int ChangeLog_0_8_3 = 2131296969;
// aapt resource value: 0x7f0902c8
public const int ChangeLog_0_8_4 = 2131296968;
// aapt resource value: 0x7f0902c7 // aapt resource value: 0x7f0902c7
public const int ChangeLog_keptDonate = 2131296967; public const int ChangeLog_0_8_5 = 2131296967;
// aapt resource value: 0x7f0902ba // aapt resource value: 0x7f0902c6
public const int ChangeLog_title = 2131296954; public const int ChangeLog_0_8_6 = 2131296966;
// aapt resource value: 0x7f0902c5
public const int ChangeLog_0_9 = 2131296965;
// aapt resource value: 0x7f0902c4
public const int ChangeLog_0_9_1 = 2131296964;
// aapt resource value: 0x7f0902c3
public const int ChangeLog_0_9_2 = 2131296963;
// aapt resource value: 0x7f0902c2
public const int ChangeLog_0_9_3 = 2131296962;
// aapt resource value: 0x7f0902c1
public const int ChangeLog_0_9_3_r5 = 2131296961;
// aapt resource value: 0x7f0902cd
public const int ChangeLog_keptDonate = 2131296973;
// aapt resource value: 0x7f0902c0
public const int ChangeLog_title = 2131296960;
// aapt resource value: 0x7f090123 // aapt resource value: 0x7f090123
public const int CheckForFileChangesOnSave_key = 2131296547; public const int CheckForFileChangesOnSave_key = 2131296547;
@ -3518,14 +3518,20 @@ namespace keepass2android
// aapt resource value: 0x7f090263 // aapt resource value: 0x7f090263
public const int CouldNotSaveToRemote = 2131296867; public const int CouldNotSaveToRemote = 2131296867;
// aapt resource value: 0x7f090298 // aapt resource value: 0x7f0902a5
public const int CouldntLoadOtpAuxFile = 2131296920; public const int CouldntLoadChalAuxFile = 2131296933;
// aapt resource value: 0x7f0902a6
public const int CouldntLoadChalAuxFile_Hint = 2131296934;
// aapt resource value: 0x7f090299 // aapt resource value: 0x7f090299
public const int CouldntLoadOtpAuxFile_Hint = 2131296921; public const int CouldntLoadOtpAuxFile = 2131296921;
// aapt resource value: 0x7f09029f // aapt resource value: 0x7f09029a
public const int CouldntParseOtpSecret = 2131296927; public const int CouldntLoadOtpAuxFile_Hint = 2131296922;
// aapt resource value: 0x7f0902a0
public const int CouldntParseOtpSecret = 2131296928;
// aapt resource value: 0x7f090134 // aapt resource value: 0x7f090134
public const int CreditsText = 2131296564; public const int CreditsText = 2131296564;
@ -3548,8 +3554,11 @@ namespace keepass2android
// aapt resource value: 0x7f09026f // aapt resource value: 0x7f09026f
public const int ErrorOcurred = 2131296879; public const int ErrorOcurred = 2131296879;
// aapt resource value: 0x7f0902a1 // aapt resource value: 0x7f0902a7
public const int ErrorUpdatingOtpAuxFile = 2131296929; public const int ErrorUpdatingChalAuxFile = 2131296935;
// aapt resource value: 0x7f0902a2
public const int ErrorUpdatingOtpAuxFile = 2131296930;
// aapt resource value: 0x7f09014e // aapt resource value: 0x7f09014e
public const int FileHandling_prefs = 2131296590; public const int FileHandling_prefs = 2131296590;
@ -3626,8 +3635,8 @@ namespace keepass2android
// aapt resource value: 0x7f090235 // aapt resource value: 0x7f090235
public const int OpenKp2aKeyboardAutomatically_title = 2131296821; public const int OpenKp2aKeyboardAutomatically_title = 2131296821;
// aapt resource value: 0x7f0902a0 // aapt resource value: 0x7f0902a1
public const int OtpKeyError = 2131296928; public const int OtpKeyError = 2131296929;
// aapt resource value: 0x7f090255 // aapt resource value: 0x7f090255
public const int ParsingDatabase = 2131296853; public const int ParsingDatabase = 2131296853;
@ -3722,29 +3731,29 @@ namespace keepass2android
// aapt resource value: 0x7f09025f // aapt resource value: 0x7f09025f
public const int RestoringRemoteFile = 2131296863; public const int RestoringRemoteFile = 2131296863;
// aapt resource value: 0x7f0902b1 // aapt resource value: 0x7f0902b6
public const int SCOPE_CURRENT_ENTRY_explanation = 2131296945; public const int SCOPE_CURRENT_ENTRY_explanation = 2131296950;
// aapt resource value: 0x7f0902b0
public const int SCOPE_CURRENT_ENTRY_title = 2131296944;
// aapt resource value: 0x7f0902af
public const int SCOPE_DATABASE_ACTIONS_explanation = 2131296943;
// aapt resource value: 0x7f0902ae
public const int SCOPE_DATABASE_ACTIONS_title = 2131296942;
// aapt resource value: 0x7f0902b3
public const int SCOPE_QUERY_CREDENTIALS_FOR_OWN_PACKAGE_explanation = 2131296947;
// aapt resource value: 0x7f0902b2
public const int SCOPE_QUERY_CREDENTIALS_FOR_OWN_PACKAGE_title = 2131296946;
// aapt resource value: 0x7f0902b5 // aapt resource value: 0x7f0902b5
public const int SCOPE_QUERY_CREDENTIALS_explanation = 2131296949; public const int SCOPE_CURRENT_ENTRY_title = 2131296949;
// aapt resource value: 0x7f0902b4 // aapt resource value: 0x7f0902b4
public const int SCOPE_QUERY_CREDENTIALS_title = 2131296948; public const int SCOPE_DATABASE_ACTIONS_explanation = 2131296948;
// aapt resource value: 0x7f0902b3
public const int SCOPE_DATABASE_ACTIONS_title = 2131296947;
// aapt resource value: 0x7f0902b8
public const int SCOPE_QUERY_CREDENTIALS_FOR_OWN_PACKAGE_explanation = 2131296952;
// aapt resource value: 0x7f0902b7
public const int SCOPE_QUERY_CREDENTIALS_FOR_OWN_PACKAGE_title = 2131296951;
// aapt resource value: 0x7f0902ba
public const int SCOPE_QUERY_CREDENTIALS_explanation = 2131296954;
// aapt resource value: 0x7f0902b9
public const int SCOPE_QUERY_CREDENTIALS_title = 2131296953;
// aapt resource value: 0x7f090210 // aapt resource value: 0x7f090210
public const int SaveAttachmentDialog_open = 2131296784; public const int SaveAttachmentDialog_open = 2131296784;
@ -3764,8 +3773,8 @@ namespace keepass2android
// aapt resource value: 0x7f090211 // aapt resource value: 0x7f090211
public const int SaveAttachment_doneMessage = 2131296785; public const int SaveAttachment_doneMessage = 2131296785;
// aapt resource value: 0x7f0902a2 // aapt resource value: 0x7f0902a3
public const int SavingOtpAuxFile = 2131296930; public const int SavingOtpAuxFile = 2131296931;
// aapt resource value: 0x7f090251 // aapt resource value: 0x7f090251
public const int SettingPassword = 2131296849; public const int SettingPassword = 2131296849;
@ -3872,6 +3881,9 @@ namespace keepass2android
// aapt resource value: 0x7f09025a // aapt resource value: 0x7f09025a
public const int YesSynchronize = 2131296858; public const int YesSynchronize = 2131296858;
// aapt resource value: 0x7f090298
public const int YubiChallengeNotInstalled = 2131296920;
// aapt resource value: 0x7f090131 // aapt resource value: 0x7f090131
public const int about_feedback = 2131296561; public const int about_feedback = 2131296561;
@ -4250,6 +4262,9 @@ namespace keepass2android
// aapt resource value: 0x7f090157 // aapt resource value: 0x7f090157
public const int available_through_keyboard = 2131296599; public const int available_through_keyboard = 2131296599;
// aapt resource value: 0x7f0902a4
public const int bad_resp = 2131296932;
// aapt resource value: 0x7f090055 // aapt resource value: 0x7f090055
public const int bigram_suggestion = 2131296341; public const int bigram_suggestion = 2131296341;
@ -4259,11 +4274,11 @@ namespace keepass2android
// aapt resource value: 0x7f090151 // aapt resource value: 0x7f090151
public const int brackets = 2131296593; public const int brackets = 2131296593;
// aapt resource value: 0x7f0902ce // aapt resource value: 0x7f0902d4
public const int browser_intall_text = 2131296974; public const int browser_intall_text = 2131296980;
// aapt resource value: 0x7f0902cf // aapt resource value: 0x7f0902d5
public const int building_search_idx = 2131296975; public const int building_search_idx = 2131296981;
// aapt resource value: 0x7f09028c // aapt resource value: 0x7f09028c
public const int button_change_location = 2131296908; public const int button_change_location = 2131296908;
@ -4394,14 +4409,14 @@ namespace keepass2android
// aapt resource value: 0x7f090101 // aapt resource value: 0x7f090101
public const int db_key = 2131296513; public const int db_key = 2131296513;
// aapt resource value: 0x7f0902d0 // aapt resource value: 0x7f0902d6
public const int decrypting_db = 2131296976; public const int decrypting_db = 2131296982;
// aapt resource value: 0x7f0902d1 // aapt resource value: 0x7f0902d7
public const int decrypting_entry = 2131296977; public const int decrypting_entry = 2131296983;
// aapt resource value: 0x7f0902d2 // aapt resource value: 0x7f0902d8
public const int default_checkbox = 2131296978; public const int default_checkbox = 2131296984;
// aapt resource value: 0x7f0900f3 // aapt resource value: 0x7f0900f3
public const int default_file_path = 2131296499; public const int default_file_path = 2131296499;
@ -4424,8 +4439,8 @@ namespace keepass2android
// aapt resource value: 0x7f090108 // aapt resource value: 0x7f090108
public const int design_key = 2131296520; public const int design_key = 2131296520;
// aapt resource value: 0x7f0902ca // aapt resource value: 0x7f0902d0
public const int design_title = 2131296970; public const int design_title = 2131296976;
// aapt resource value: 0x7f09015e // aapt resource value: 0x7f09015e
public const int digits = 2131296606; public const int digits = 2131296606;
@ -4457,11 +4472,11 @@ namespace keepass2android
// aapt resource value: 0x7f090160 // aapt resource value: 0x7f090160
public const int ellipsis = 2131296608; public const int ellipsis = 2131296608;
// aapt resource value: 0x7f0902cc // aapt resource value: 0x7f0902d2
public const int enable_plugin_question = 2131296972; public const int enable_plugin_question = 2131296978;
// aapt resource value: 0x7f0902cb // aapt resource value: 0x7f0902d1
public const int enable_plugin_title = 2131296971; public const int enable_plugin_title = 2131296977;
// aapt resource value: 0x7f0901fe // aapt resource value: 0x7f0901fe
public const int enable_quickunlock = 2131296766; public const int enable_quickunlock = 2131296766;
@ -4493,8 +4508,8 @@ namespace keepass2android
// aapt resource value: 0x7f090162 // aapt resource value: 0x7f090162
public const int entry_accessed = 2131296610; public const int entry_accessed = 2131296610;
// aapt resource value: 0x7f0902d3 // aapt resource value: 0x7f0902d9
public const int entry_and_or = 2131296979; public const int entry_and_or = 2131296985;
// aapt resource value: 0x7f090172 // aapt resource value: 0x7f090172
public const int entry_binaries = 2131296626; public const int entry_binaries = 2131296626;
@ -4547,8 +4562,8 @@ namespace keepass2android
// aapt resource value: 0x7f090294 // aapt resource value: 0x7f090294
public const int error_adding_keyfile = 2131296916; public const int error_adding_keyfile = 2131296916;
// aapt resource value: 0x7f0902d4 // aapt resource value: 0x7f0902da
public const int error_arc4 = 2131296980; public const int error_arc4 = 2131296986;
// aapt resource value: 0x7f090173 // aapt resource value: 0x7f090173
public const int error_can_not_handle_uri = 2131296627; public const int error_can_not_handle_uri = 2131296627;
@ -4589,8 +4604,8 @@ namespace keepass2android
// aapt resource value: 0x7f09017e // aapt resource value: 0x7f09017e
public const int error_nopass = 2131296638; public const int error_nopass = 2131296638;
// aapt resource value: 0x7f0902d5 // aapt resource value: 0x7f0902db
public const int error_out_of_memory = 2131296981; public const int error_out_of_memory = 2131296987;
// aapt resource value: 0x7f09017f // aapt resource value: 0x7f09017f
public const int error_pass_gen_type = 2131296639; public const int error_pass_gen_type = 2131296639;
@ -4601,8 +4616,8 @@ namespace keepass2android
// aapt resource value: 0x7f090181 // aapt resource value: 0x7f090181
public const int error_rounds_not_number = 2131296641; public const int error_rounds_not_number = 2131296641;
// aapt resource value: 0x7f0902d6 // aapt resource value: 0x7f0902dc
public const int error_rounds_too_large = 2131296982; public const int error_rounds_too_large = 2131296988;
// aapt resource value: 0x7f090216 // aapt resource value: 0x7f090216
public const int error_string_key = 2131296790; public const int error_string_key = 2131296790;
@ -4619,8 +4634,8 @@ namespace keepass2android
// aapt resource value: 0x7f0901d1 // aapt resource value: 0x7f0901d1
public const int export_database_successful = 2131296721; public const int export_database_successful = 2131296721;
// aapt resource value: 0x7f0902b9 // aapt resource value: 0x7f0902be
public const int export_fileformats_title = 2131296953; public const int export_fileformats_title = 2131296958;
// aapt resource value: 0x7f090150 // aapt resource value: 0x7f090150
public const int export_prefs = 2131296592; public const int export_prefs = 2131296592;
@ -4685,8 +4700,8 @@ namespace keepass2android
// aapt resource value: 0x7f090186 // aapt resource value: 0x7f090186
public const int generate_password = 2131296646; public const int generate_password = 2131296646;
// aapt resource value: 0x7f0902b6 // aapt resource value: 0x7f0902bb
public const int get_regular_version = 2131296950; public const int get_regular_version = 2131296955;
// aapt resource value: 0x7f090187 // aapt resource value: 0x7f090187
public const int group = 2131296647; public const int group = 2131296647;
@ -4790,11 +4805,11 @@ namespace keepass2android
// aapt resource value: 0x7f0901dd // aapt resource value: 0x7f0901dd
public const int insert_element_here = 2131296733; public const int insert_element_here = 2131296733;
// aapt resource value: 0x7f0902d7 // aapt resource value: 0x7f0902dd
public const int install_from_market = 2131296983; public const int install_from_market = 2131296989;
// aapt resource value: 0x7f0902d8 // aapt resource value: 0x7f0902de
public const int install_from_website = 2131296984; public const int install_from_website = 2131296990;
// aapt resource value: 0x7f090196 // aapt resource value: 0x7f090196
public const int invalid_algorithm = 2131296662; public const int invalid_algorithm = 2131296662;
@ -4829,6 +4844,9 @@ namespace keepass2android
// aapt resource value: 0x7f090145 // aapt resource value: 0x7f090145
public const int kill_app_label = 2131296581; public const int kill_app_label = 2131296581;
// aapt resource value: 0x7f0902bf
public const int killed_by_os = 2131296959;
// aapt resource value: 0x7f0900ab // aapt resource value: 0x7f0900ab
public const int kp2a_auto_fill = 2131296427; public const int kp2a_auto_fill = 2131296427;
@ -4940,8 +4958,8 @@ namespace keepass2android
// aapt resource value: 0x7f09019b // aapt resource value: 0x7f09019b
public const int list_size_title = 2131296667; public const int list_size_title = 2131296667;
// aapt resource value: 0x7f0902a3 // aapt resource value: 0x7f0902a8
public const int loading = 2131296931; public const int loading = 2131296936;
// aapt resource value: 0x7f09019d // aapt resource value: 0x7f09019d
public const int loading_database = 2131296669; public const int loading_database = 2131296669;
@ -5003,8 +5021,8 @@ namespace keepass2android
// aapt resource value: 0x7f0901ad // aapt resource value: 0x7f0901ad
public const int menu_hide_password = 2131296685; public const int menu_hide_password = 2131296685;
// aapt resource value: 0x7f0902d9 // aapt resource value: 0x7f0902df
public const int menu_homepage = 2131296985; public const int menu_homepage = 2131296991;
// aapt resource value: 0x7f0901ae // aapt resource value: 0x7f0901ae
public const int menu_lock = 2131296686; public const int menu_lock = 2131296686;
@ -5087,14 +5105,14 @@ namespace keepass2android
// aapt resource value: 0x7f09026e // aapt resource value: 0x7f09026e
public const int otp_aux_file = 2131296878; public const int otp_aux_file = 2131296878;
// aapt resource value: 0x7f09029c // aapt resource value: 0x7f09029d
public const int otp_discarded_because_db_open = 2131296924; public const int otp_discarded_because_db_open = 2131296925;
// aapt resource value: 0x7f09029a
public const int otp_discarded_because_no_db = 2131296922;
// aapt resource value: 0x7f09029b // aapt resource value: 0x7f09029b
public const int otp_discarded_no_space = 2131296923; public const int otp_discarded_because_no_db = 2131296923;
// aapt resource value: 0x7f09029c
public const int otp_discarded_no_space = 2131296924;
// aapt resource value: 0x7f090296 // aapt resource value: 0x7f090296
public const int otp_explanation = 2131296918; public const int otp_explanation = 2131296918;
@ -5102,11 +5120,11 @@ namespace keepass2android
// aapt resource value: 0x7f090297 // aapt resource value: 0x7f090297
public const int otp_hint = 2131296919; public const int otp_hint = 2131296919;
// aapt resource value: 0x7f09029d
public const int otps_pending = 2131296925;
// aapt resource value: 0x7f09029e // aapt resource value: 0x7f09029e
public const int otpsecret_hint = 2131296926; public const int otps_pending = 2131296926;
// aapt resource value: 0x7f09029f
public const int otpsecret_hint = 2131296927;
// aapt resource value: 0x7f0901bf // aapt resource value: 0x7f0901bf
public const int pass_filename = 2131296703; public const int pass_filename = 2131296703;
@ -5129,32 +5147,32 @@ namespace keepass2android
// aapt resource value: 0x7f0901eb // aapt resource value: 0x7f0901eb
public const int please_note = 2131296747; public const int please_note = 2131296747;
// aapt resource value: 0x7f0902a7 // aapt resource value: 0x7f0902ac
public const int plugin_author = 2131296935; public const int plugin_author = 2131296940;
// aapt resource value: 0x7f0902a6 // aapt resource value: 0x7f0902ab
public const int plugin_description = 2131296934; public const int plugin_description = 2131296939;
// aapt resource value: 0x7f0902a9 // aapt resource value: 0x7f0902ae
public const int plugin_disabled = 2131296937; public const int plugin_disabled = 2131296942;
// aapt resource value: 0x7f0902a8
public const int plugin_enabled = 2131296936;
// aapt resource value: 0x7f0902ad // aapt resource value: 0x7f0902ad
public const int plugin_enabled_checkbox = 2131296941; public const int plugin_enabled = 2131296941;
// aapt resource value: 0x7f0902a5 // aapt resource value: 0x7f0902b2
public const int plugin_packagename = 2131296933; public const int plugin_enabled_checkbox = 2131296946;
// aapt resource value: 0x7f0902aa // aapt resource value: 0x7f0902aa
public const int plugin_web = 2131296938; public const int plugin_packagename = 2131296938;
// aapt resource value: 0x7f0902a4 // aapt resource value: 0x7f0902af
public const int plugins = 2131296932; public const int plugin_web = 2131296943;
// aapt resource value: 0x7f0902cd // aapt resource value: 0x7f0902a9
public const int plugins_text = 2131296973; public const int plugins = 2131296937;
// aapt resource value: 0x7f0902d3
public const int plugins_text = 2131296979;
// aapt resource value: 0x7f09008d // aapt resource value: 0x7f09008d
public const int popular_domain_0 = 2131296397; public const int popular_domain_0 = 2131296397;
@ -5225,11 +5243,11 @@ namespace keepass2android
// aapt resource value: 0x7f090219 // aapt resource value: 0x7f090219
public const int protection = 2131296793; public const int protection = 2131296793;
// aapt resource value: 0x7f0902ac // aapt resource value: 0x7f0902b1
public const int query_credentials = 2131296940; public const int query_credentials = 2131296945;
// aapt resource value: 0x7f0902ab // aapt resource value: 0x7f0902b0
public const int query_credentials_for_url = 2131296939; public const int query_credentials_for_url = 2131296944;
// aapt resource value: 0x7f09004b // aapt resource value: 0x7f09004b
public const int quick_fixes = 2131296331; public const int quick_fixes = 2131296331;

View File

@ -398,6 +398,7 @@
<string name="init_otp">Load auxiliary file…</string> <string name="init_otp">Load auxiliary file…</string>
<string name="otp_explanation">Enter the next One-time-passwords (OTPs). Swipe your Yubikey NEO at the back of your device to enter via NFC.</string> <string name="otp_explanation">Enter the next One-time-passwords (OTPs). Swipe your Yubikey NEO at the back of your device to enter via NFC.</string>
<string name="otp_hint">OTP %1$d</string> <string name="otp_hint">OTP %1$d</string>
<string name="YubiChallengeNotInstalled">Could not find an app that can handle the challenge. Please install Yubichallenge from Google Play.</string>
<string name="CouldntLoadOtpAuxFile">Could not load auxiliary OTP file!</string> <string name="CouldntLoadOtpAuxFile">Could not load auxiliary OTP file!</string>
<string name="CouldntLoadOtpAuxFile_Hint">Please use the OtpKeyProv plugin in KeePass 2.x (PC) to configure your database for use with OTPs!</string> <string name="CouldntLoadOtpAuxFile_Hint">Please use the OtpKeyProv plugin in KeePass 2.x (PC) to configure your database for use with OTPs!</string>
<string name="otp_discarded_because_no_db">Please select database first. OTP is discarded for security reasons.</string> <string name="otp_discarded_because_no_db">Please select database first. OTP is discarded for security reasons.</string>
@ -449,6 +450,8 @@
<string name="CertificateFailure">Error: Server certificate validation failed! Install appropriate root certificate on your device or see settings!</string> <string name="CertificateFailure">Error: Server certificate validation failed! Install appropriate root certificate on your device or see settings!</string>
<string name="export_fileformats_title">Select file format</string> <string name="export_fileformats_title">Select file format</string>
<string name="killed_by_os">Sorry! Keepass2Android was killed by the Android OS! For security reasons, Keepass2Android did not persist your selected credentials on disk, so you need to re-open your database. Note: This should happen only very rarely. If it does, please drop me a message at crocoapps@gmail.com.</string>
<string name="ChangeLog_title">Change log</string> <string name="ChangeLog_title">Change log</string>

View File

@ -376,7 +376,11 @@ namespace keepass2android
{ {
//show the notifications //show the notifications
activity.StartNotificationsService(CloseAfterCreate); activity.StartNotificationsService(CloseAfterCreate);
}
else
{
//to avoid getting into inconsistent state (LastOpenedEntry and Notifications): clear notifications:
CopyToClipboardService.CancelNotifications(activity);
} }
if (CloseAfterCreate) if (CloseAfterCreate)
{ {

View File

@ -54,6 +54,7 @@ namespace keepass2android
public const String UpdateKeyboard = "keepass2android.update_keyboard"; public const String UpdateKeyboard = "keepass2android.update_keyboard";
public const String CopyStringToClipboard = "keepass2android.copy_string_to_clipboard"; public const String CopyStringToClipboard = "keepass2android.copy_string_to_clipboard";
public const String ActivateKeyboard = "keepass2android.activate_keyboard"; public const String ActivateKeyboard = "keepass2android.activate_keyboard";
public const String ClearNotificationsAndData = "keepass2android.ClearNotificationsAndData";
} }
} }

View File

@ -95,6 +95,7 @@
<Compile Include="addons\OtpKeyProv\OtpAuxCachingFileStorage.cs" /> <Compile Include="addons\OtpKeyProv\OtpAuxCachingFileStorage.cs" />
<Compile Include="addons\OtpKeyProv\OtpInfo.cs" /> <Compile Include="addons\OtpKeyProv\OtpInfo.cs" />
<Compile Include="addons\OtpKeyProv\OtpUtil.cs" /> <Compile Include="addons\OtpKeyProv\OtpUtil.cs" />
<Compile Include="AppKilledInfo.cs" />
<Compile Include="app\NoFileStorageFoundException.cs" /> <Compile Include="app\NoFileStorageFoundException.cs" />
<Compile Include="app\OtpAuxCacheSupervisor.cs" /> <Compile Include="app\OtpAuxCacheSupervisor.cs" />
<Compile Include="AboutActivity.cs" /> <Compile Include="AboutActivity.cs" />

View File

@ -57,12 +57,26 @@ namespace keepass2android
ctx.StartService(i); ctx.StartService(i);
} }
static public void ActivateKeyboard(Context ctx)
{
Intent i = new Intent(ctx, typeof(CopyToClipboardService));
i.SetAction(Intents.ActivateKeyboard);
ctx.StartService(i);
}
public static void CancelNotifications(Context ctx)
{
Intent i = new Intent(ctx, typeof(CopyToClipboardService));
i.SetAction(Intents.ClearNotificationsAndData);
ctx.StartService(i);
}
public CopyToClipboardService (IntPtr javaReference, JniHandleOwnership transfer) public CopyToClipboardService (IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer) : base(javaReference, transfer)
{ {
} }
CopyToClipboardBroadcastReceiver _copyToClipBroadcastReceiver;
NotificationDeletedBroadcastReceiver _notificationDeletedBroadcastReceiver; NotificationDeletedBroadcastReceiver _notificationDeletedBroadcastReceiver;
StopOnLockBroadcastReceiver _stopOnLockBroadcastReceiver; StopOnLockBroadcastReceiver _stopOnLockBroadcastReceiver;
@ -121,7 +135,7 @@ namespace keepass2android
bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KeyCloseAfterCreate, false); bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KeyCloseAfterCreate, false);
DisplayAccessNotifications(entry, closeAfterCreate); DisplayAccessNotifications(entry, closeAfterCreate);
} }
else else //UpdateKeyboard
{ {
//this action is received when the data in the entry has changed (e.g. by plugins) //this action is received when the data in the entry has changed (e.g. by plugins)
//update the keyboard data. //update the keyboard data.
@ -135,6 +149,15 @@ namespace keepass2android
TimeoutCopyToClipboard(intent.GetStringExtra(_stringtocopy)); TimeoutCopyToClipboard(intent.GetStringExtra(_stringtocopy));
} }
if (intent.Action == Intents.ActivateKeyboard)
{
ActivateKp2aKeyboard();
}
if (intent.Action == Intents.ClearNotificationsAndData)
{
ClearNotifications();
}
return StartCommandResult.RedeliverIntent; return StartCommandResult.RedeliverIntent;
} }
@ -158,10 +181,6 @@ namespace keepass2android
{ {
UnregisterReceiver(_stopOnLockBroadcastReceiver); UnregisterReceiver(_stopOnLockBroadcastReceiver);
} }
if (_copyToClipBroadcastReceiver != null)
{
UnregisterReceiver(_copyToClipBroadcastReceiver);
}
if (_notificationDeletedBroadcastReceiver != null) if (_notificationDeletedBroadcastReceiver != null)
{ {
UnregisterReceiver(_notificationDeletedBroadcastReceiver); UnregisterReceiver(_notificationDeletedBroadcastReceiver);
@ -201,14 +220,7 @@ namespace keepass2android
public void DisplayAccessNotifications(PwEntryOutput entry, bool closeAfterCreate) public void DisplayAccessNotifications(PwEntryOutput entry, bool closeAfterCreate)
{ {
// Notification Manager var hadKeyboardData = ClearNotifications();
_notificationManager = (NotificationManager)GetSystemService(NotificationService);
_notificationManager.Cancel(NotifyPassword);
_notificationManager.Cancel(NotifyUsername);
_notificationManager.Cancel(NotifyKeyboard);
_numElementsToWaitFor = 0;
bool hadKeyboardData = ClearKeyboard(false); //do not broadcast if the keyboard was changed
String entryName = entry.OutputStrings.ReadSafe(PwDefs.TitleField); String entryName = entry.OutputStrings.ReadSafe(PwDefs.TitleField);
@ -255,7 +267,7 @@ namespace keepass2android
// automatically bring up the Keyboard selection dialog // automatically bring up the Keyboard selection dialog
if ((closeAfterCreate) && prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomatically_key), Resources.GetBoolean(Resource.Boolean.OpenKp2aKeyboardAutomatically_default))) if ((closeAfterCreate) && prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomatically_key), Resources.GetBoolean(Resource.Boolean.OpenKp2aKeyboardAutomatically_default)))
{ {
ActivateKp2aKeyboard(this); ActivateKp2aKeyboard();
} }
} }
@ -272,13 +284,10 @@ namespace keepass2android
return; return;
} }
_copyToClipBroadcastReceiver = new CopyToClipboardBroadcastReceiver(entry, this);
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.CopyUsername); filter.AddAction(Intents.CopyUsername);
filter.AddAction(Intents.CopyPassword); filter.AddAction(Intents.CopyPassword);
filter.AddAction(Intents.CheckKeyboard); filter.AddAction(Intents.CheckKeyboard);
RegisterReceiver(_copyToClipBroadcastReceiver, filter);
//register receiver to get notified when notifications are discarded in which case we can shutdown the service //register receiver to get notified when notifications are discarded in which case we can shutdown the service
_notificationDeletedBroadcastReceiver = new NotificationDeletedBroadcastReceiver(this); _notificationDeletedBroadcastReceiver = new NotificationDeletedBroadcastReceiver(this);
@ -287,6 +296,19 @@ namespace keepass2android
RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter); RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter);
} }
private bool ClearNotifications()
{
// Notification Manager
_notificationManager = (NotificationManager) GetSystemService(NotificationService);
_notificationManager.Cancel(NotifyPassword);
_notificationManager.Cancel(NotifyUsername);
_notificationManager.Cancel(NotifyKeyboard);
_numElementsToWaitFor = 0;
bool hadKeyboardData = ClearKeyboard(false); //do not broadcast if the keyboard was changed
return hadKeyboardData;
}
bool MakeAccessibleForKeyboard(PwEntryOutput entry) bool MakeAccessibleForKeyboard(PwEntryOutput entry)
{ {
#if EXCLUDE_KEYBOARD #if EXCLUDE_KEYBOARD
@ -434,6 +456,7 @@ namespace keepass2android
Notification notify = new Notification(drawableResId, desc, Java.Lang.JavaSystem.CurrentTimeMillis()); Notification notify = new Notification(drawableResId, desc, Java.Lang.JavaSystem.CurrentTimeMillis());
Intent intent = new Intent(intentText); Intent intent = new Intent(intentText);
intent.SetPackage(PackageName);
PendingIntent pending = PendingIntent.GetBroadcast(this, descResId, intent, PendingIntentFlags.CancelCurrent); PendingIntent pending = PendingIntent.GetBroadcast(this, descResId, intent, PendingIntentFlags.CancelCurrent);
notify.SetLatestEventInfo(this, title, desc, pending); notify.SetLatestEventInfo(this, title, desc, pending);
@ -460,43 +483,7 @@ namespace keepass2android
} }
} }
class CopyToClipboardBroadcastReceiver: BroadcastReceiver
{
readonly CopyToClipboardService _service;
readonly PwEntryOutput _entry;
public CopyToClipboardBroadcastReceiver(PwEntryOutput entry, CopyToClipboardService service)
{
_entry = entry;
_service = service;
}
public override void OnReceive(Context context, Intent intent)
{
String action = intent.Action;
if (action.Equals(Intents.CopyUsername))
{
String username = _entry.OutputStrings.ReadSafe(PwDefs.UserNameField);
if (username.Length > 0)
{
_service.TimeoutCopyToClipboard(username);
}
} else if (action.Equals(Intents.CopyPassword))
{
String password = _entry.OutputStrings.ReadSafe(PwDefs.PasswordField);
if (password.Length > 0)
{
_service.TimeoutCopyToClipboard(password);
}
} else if (action.Equals(Intents.CheckKeyboard))
{
ActivateKp2aKeyboard(_service);
}
}
};
class NotificationDeletedBroadcastReceiver: BroadcastReceiver class NotificationDeletedBroadcastReceiver: BroadcastReceiver
{ {
@ -517,18 +504,18 @@ namespace keepass2android
#endregion #endregion
} }
internal static void ActivateKp2aKeyboard(CopyToClipboardService service) internal void ActivateKp2aKeyboard()
{ {
string currentIme = Android.Provider.Settings.Secure.GetString( string currentIme = Android.Provider.Settings.Secure.GetString(
service.ContentResolver, ContentResolver,
Android.Provider.Settings.Secure.DefaultInputMethod); Android.Provider.Settings.Secure.DefaultInputMethod);
string kp2aIme = service.PackageName + "/keepass2android.softkeyboard.KP2AKeyboard"; string kp2aIme = PackageName + "/keepass2android.softkeyboard.KP2AKeyboard";
InputMethodManager imeManager = (InputMethodManager)service.ApplicationContext.GetSystemService(InputMethodService); InputMethodManager imeManager = (InputMethodManager)ApplicationContext.GetSystemService(InputMethodService);
if (imeManager == null) if (imeManager == null)
{ {
Toast.MakeText(service, Resource.String.not_possible_im_picker, ToastLength.Long).Show(); Toast.MakeText(this, Resource.String.not_possible_im_picker, ToastLength.Long).Show();
return; return;
} }
@ -543,20 +530,72 @@ namespace keepass2android
if (!inputMethodProperties.Any(imi => imi.Id.Equals(kp2aIme))) if (!inputMethodProperties.Any(imi => imi.Id.Equals(kp2aIme)))
{ {
Toast.MakeText(service, Resource.String.please_activate_keyboard, ToastLength.Long).Show(); Toast.MakeText(this, Resource.String.please_activate_keyboard, ToastLength.Long).Show();
Intent settingsIntent = new Intent(Android.Provider.Settings.ActionInputMethodSettings); Intent settingsIntent = new Intent(Android.Provider.Settings.ActionInputMethodSettings);
settingsIntent.SetFlags(ActivityFlags.NewTask); settingsIntent.SetFlags(ActivityFlags.NewTask);
service.StartActivity(settingsIntent); StartActivity(settingsIntent);
} }
else else
{ {
#if !EXCLUDE_KEYBOARD #if !EXCLUDE_KEYBOARD
Keepass2android.Kbbridge.ImeSwitcher.SwitchToKeyboard(service, kp2aIme, false); Keepass2android.Kbbridge.ImeSwitcher.SwitchToKeyboard(this, kp2aIme, false);
#endif #endif
} }
} }
} }
}
}
[BroadcastReceiver(Permission = "keepass2android." + AppNames.PackagePart + ".permission.CopyToClipboard")]
[IntentFilter(new[] { Intents.CopyUsername, Intents.CopyPassword, Intents.CheckKeyboard })]
class CopyToClipboardBroadcastReceiver : BroadcastReceiver
{
public CopyToClipboardBroadcastReceiver(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}
public CopyToClipboardBroadcastReceiver()
{
}
public override void OnReceive(Context context, Intent intent)
{
String action = intent.Action;
//check if we have a last opened entry
//this should always be non-null, but if the OS has killed the app, it might occur.
if (App.Kp2a.GetDb().LastOpenedEntry == null)
{
Intent i = new Intent(context, typeof (AppKilledInfo));
i.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);
context.StartActivity(i);
return;
}
if (action.Equals(Intents.CopyUsername))
{
String username = App.Kp2a.GetDb().LastOpenedEntry.OutputStrings.ReadSafe(PwDefs.UserNameField);
if (username.Length > 0)
{
CopyToClipboardService.CopyValueToClipboardWithTimeout(context, username);
}
}
else if (action.Equals(Intents.CopyPassword))
{
String password = App.Kp2a.GetDb().LastOpenedEntry.OutputStrings.ReadSafe(PwDefs.PasswordField);
if (password.Length > 0)
{
CopyToClipboardService.CopyValueToClipboardWithTimeout(context, password);
}
}
else if (action.Equals(Intents.CheckKeyboard))
{
CopyToClipboardService.ActivateKeyboard(context);
}
}
};
} }