Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into nonet
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippC committed Nov 16, 2020
2 parents f2ca846 + 90ae1bd commit 1ecfe83
Show file tree
Hide file tree
Showing 276 changed files with 22,829 additions and 12,327 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ src/java/Keepass2AndroidPluginSDK2/build/generated/mockable-Google-Inc.-Google-A
/src/java/KP2AKdbLibrary/app/build
/src/java/KP2ASoftkeyboard_AS/app/.cxx
/src/java/KP2ASoftkeyboard_AS/app/src/main/libs
/src/java/KP2AKdbLibrary/app/.cxx
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "src/SamsungPass"]
path = src/SamsungPass
url = https://github.com/PhilippC/Xamarin-Samsung-Pass.git
[submodule "src/netftpandroid"]
path = src/netftpandroid
url = https://github.com/PhilippC/netftpandroid.git
[submodule "src/java/argon2/phc-winner-argon2"]
path = src/java/argon2/phc-winner-argon2
url = https://github.com/P-H-C/phc-winner-argon2
24 changes: 24 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,27 @@ files:
two_letters_code:
zh-CN: zh
zh-TW: zh-rTW
pt-PT: pt
pt-BR: pt-rBR
- source: src/java/android-filechooser-AS/app/src/main/res/values/strings.xml
translation: >-
/src/java/android-filechooser-AS/app/src/main/res/values-%two_letters_code%/%original_file_name%
translate_attributes: '0'
content_segmentation: '0'
languages_mapping:
two_letters_code:
zh-CN: zh
zh-TW: zh-rTW
pt-PT: pt
pt-BR: pt-rBR
- source: src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/strings.xml
translation: >-
/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values-%two_letters_code%/%original_file_name%
translate_attributes: '0'
content_segmentation: '0'
languages_mapping:
two_letters_code:
zh-CN: zh
zh-TW: zh-rTW
pt-PT: pt
pt-BR: pt-rBR
21 changes: 21 additions & 0 deletions docs/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The KP2A keyboard is meant to quickly "paste" or "type" values from your databas
## Is it safe to store my kdbx file in the cloud?
While it may happen that someone gets access to your kdbx file in the cloud, there is still no need to worry: the purpose of encryption is to protect the data even in case someone gets the kdbx file! As long as you are using a safe master key, you're safe! [Key files](https://keepass.info/help/base/keys.html#keyfiles) can help with securing the database even more.

## Doesn't Keepass2Android create automatic backups?
Yes and no. Yes: Keepass2Android stores the last successfully opened file as a read-only backup locally on the phone (unless you disable this is in the settings). This should make sure that even if the file gets destroyed during a save operation or gets deleted by accident, you should always have a version that can be opened. (Don't mix this up with the internal file cache which is not meant as a backup and can easily be overwritten even with a corrupt file. This internal file cache is meant for providing writable access even when the original file is not reachable, e.g. when you're offline.)
No: The local backup has two shortcomings: It is only one backup and does not allow to revert to older versions. So if you deleted an entry from the database, it might be deleted in the local backup soon as well. The even more important shortcoming is that it is just a local backup. It won't help when your phone gets lost or broken. Please create additional backups on seperate storage!

## How do I backup the database?
If you have stored your database on the cloud, you might rely on your cloud storage providers backups. Make sure they allow you to revert to older revisions in case the file gets corrupted for some reason.
If you are working with a local database file, make sure you create regular backups. I suggest you have an aumotated mechanism, e.g. with FolderSync (Lite) which can copy local files from your device to other locations, e.g. your PC in a local network. You can also use USB or tools like MyPhoneExploror to transfer data to your PC. Or, you use a removable storage like an SD card which you keep in a safe place after making the backup.
Expand All @@ -94,6 +98,23 @@ It's time for action! As soon as possible, select Settings - Database - Export a
## Why is Keepass2Android's apk so big?
Please see [Keepass2Android Apk](Keepass2Android-Apk.md) for more information.

## I get a message "File is trashed" when reading or writing a file on Google Drive
This happens because ocaml-fuse (I guess you are on Linux  and use that) moves files to trash and then creates a new one instead of correctly updating the file on Google Drive (each file has a unique ID which Keepass2Android uses). Fortunately, this was fixed: https://github.com/astrada/google-drive-ocamlfuse/issues/494After activating this option, please select "Change database" in KP2A, tap ,"Open file" and browse to the file on Google Drive again. After that, the message should no longer pop up.

## I get a message "The name must not be empty: null" when opening from Google Drive
Please follow these steps:

* select "Change database" on the password screen, then "Open database" and browse to your file again
* go to Android app settings and disable all permissions for the KP2A app. Then try again to open the database file.
* reboot the device

(Before running the following steps, make sure you don't have local changes in your database which have not been synchronized with Google Drive (this can happen if you worked offline). If you have, please open the database from the local cache and go to settings - database settings - export database and make a backup copy of the data.)

* clear KP2A's app cache in the Android settings
* uninstall & reinstall

One of these has helped all users so far, but unfortunately it's not totally clear to me why different steps are required (or nothing for most users).

# For developers
If you are interested in adding new features, you have two options:
Either your features can be implemented as a plug-in. Please see [How to create a plug-in?](How-to-create-a-plug-in_.md) for more information. Or you add the features directly in the source code of the projects and create a pull request.
2 changes: 1 addition & 1 deletion docs/How-to-create-a-plug-in_.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Please also add a few strings in your resource files (e.g. strings.xml) with the
These strings will be displayed to the user when KP2A asks if access should be granted.

## Modifying the entry view
You can add menu options for the full entry or for individual fields of the entry when displayed to the user. This is done, for example, by the QR plugin ([https://play.google.com/store/apps/details?id=keepass2android.plugin.qr](https___play.google.com_store_apps_details_id=keepass2android.plugin.qr)).
You can add menu options for the full entry or for individual fields of the entry when displayed to the user. This is done, for example, by the QR plugin ([https://play.google.com/store/apps/details?id=keepass2android.plugin.qr](https://play.google.com/store/apps/details?id=keepass2android.plugin.qr)).
In addition, it is even possible to add new fields or modify existing fields. Please see the sample plugin "PluginA" in the KP2A repository for a simple example on how to do this:
[https://keepass2android.codeplex.com/SourceControl/latest#src/java/PluginA/src/keepass2android/plugina/PluginAActionReceiver.java](https://keepass2android.codeplex.com/SourceControl/latest#src/java/PluginA/src/keepass2android/plugina/PluginAActionReceiver.java)

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Beta-releases can be obtained by opting in to the [Beta testing channel](https:/
# How can I contribute?
* Help to translate Keepass2Android into your language or improve translations at [our Crowdin page](http://crowdin.net/project/keepass2android)
* Add features by [creating a plugin](How-to-create-a-plug-in_.md) or creating a pull request. You might want to contact me before you start working so I can coordinate efforts.
* [Become a GitHub sponsor to boost 🚀 development](https://github.com/sponsors/PhilippC)
* [Make a donation](http://philipp.crocoll.net/donate.php)

# How do I learn more?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Binary file removed src/JavaFileStorageBindings/Jars/okhttp-3.9.0.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/JavaFileStorageBindings/Jars/okio-1.13.0.jar
Binary file not shown.
Binary file added src/JavaFileStorageBindings/Jars/okio-2.9.0.jar
Binary file not shown.
15 changes: 8 additions & 7 deletions src/JavaFileStorageBindings/JavaFileStorageBindings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<AndroidClassParser>class-parse</AndroidClassParser>
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -84,9 +85,6 @@
<ItemGroup>
<ProjectReference Include="..\PCloudBindings\PCloudBindings.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedReferenceJar Include="Jars\okhttp-digest-1.7.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedReferenceJar Include="Jars\msa-auth-0.8.6\classes-msa-auth.jar" />
</ItemGroup>
Expand Down Expand Up @@ -142,15 +140,18 @@
<EmbeddedReferenceJar Include="Jars\jackson-core-2.7.4.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedReferenceJar Include="Jars\okhttp-3.9.0.jar" />
<EmbeddedJar Include="Jars\dropbox-core-sdk-3.1.1.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedReferenceJar Include="Jars\gson-2.8.1.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedReferenceJar Include="Jars\okio-1.13.0.jar" />
<EmbeddedReferenceJar Include="Jars\okhttp-digest-2.5.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedJar Include="Jars\dropbox-core-sdk-3.1.1.jar" />
<EmbeddedReferenceJar Include="Jars\okio-2.9.0.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedReferenceJar Include="Jars\gson-2.8.1.jar" />
<EmbeddedReferenceJar Include="Jars\okhttp-4.10.0-RC1.jar" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/KP2AKdbLibraryBinding/KP2AKdbLibraryBinding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
4 changes: 2 additions & 2 deletions src/KeePass.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
# Visual Studio Version 16
VisualStudioVersion = 16.0.29418.71
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeePassLib2Android", "KeePassLib2Android\KeePassLib2Android.csproj", "{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}"
EndProject
Expand Down
15 changes: 12 additions & 3 deletions src/KeePassLib2Android/Serialization/KdbxFile.Read.Streamed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You should have received a copy of the GNU General Public License
using System.IO;
using System.Text;
using System.Xml;

using keepass2android;
#if !KeePassUAP
using System.Drawing;
#endif
Expand Down Expand Up @@ -872,8 +872,17 @@ private DateTime ReadTime(XmlReader xr)
pb = pb8;
}
long lSec = MemUtil.BytesToInt64(pb);
return new DateTime(lSec * TimeSpan.TicksPerSecond, DateTimeKind.Utc);
}
try
{
return new DateTime(lSec * TimeSpan.TicksPerSecond, DateTimeKind.Utc);
}
catch (System.ArgumentOutOfRangeException e)
{
//files might contain bad data, e.g. see #868. Fall back to MinValue
Kp2aLog.Log("Failed to read date from file.");
return DateTime.MinValue;
}
}
else
{
string str = ReadString(xr);
Expand Down
13 changes: 8 additions & 5 deletions src/KeePassLib2Android/Serialization/KdbxFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,16 @@ private uint GetMinKdbxVersion()

// See also KeePassKdb2x3.Export (KDBX 3.1 export module)
uint minVersionForKeys = m_pwDatabase.MasterKey.UserKeys.Select(key => key.GetMinKdbxVersion()).Max();


uint minRequiredVersion = Math.Max(minVersionForKeys, m_uFileVersion); //don't save a version lower than what we read


AesKdf kdfAes = new AesKdf();
if(!kdfAes.Uuid.Equals(m_pwDatabase.KdfParameters.KdfUuid))
return Math.Max(FileVersion32, minVersionForKeys);
return Math.Max(FileVersion32, minRequiredVersion);

if(m_pwDatabase.PublicCustomData.Count > 0)
return Math.Max(FileVersion32, minVersionForKeys);
return Math.Max(FileVersion32, minRequiredVersion);



Expand All @@ -401,9 +404,9 @@ private uint GetMinKdbxVersion()
gh(m_pwDatabase.RootGroup);
m_pwDatabase.RootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh);
if(bCustomData)
return Math.Max(FileVersion32, minVersionForKeys);
return Math.Max(FileVersion32, minRequiredVersion);

return Math.Max(FileVersion32_3, minVersionForKeys); ; // KDBX 3.1 is sufficient
return Math.Max(FileVersion32_3, minRequiredVersion); ; // KDBX 3.1 is sufficient
}

private void ComputeKeys(out byte[] pbCipherKey, int cbCipherKey,
Expand Down
6 changes: 3 additions & 3 deletions src/KeePassLib2Android/Serialization/ProtoBuf/KdbpFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public static void PrepareSerializer()
/// </summary>
public static KdbxFormat GetFormatToUse(string fileExt)
{
// If the filename ends in .kdbp, use ProtocolBuffers format.
return fileExt.Equals(KdbpFile.FileNameExtension, StringComparison.OrdinalIgnoreCase) ? KdbxFormat.ProtocolBuffers : KdbxFormat.Default;
}
return fileExt.Equals(KdbpFile.FileNameExtension, StringComparison.OrdinalIgnoreCase) ? KdbxFormat.ProtocolBuffers :
(fileExt.Equals("xml", StringComparison.OrdinalIgnoreCase) ? KdbxFormat.PlainXml : KdbxFormat.Default);
}

public static void WriteDocument(PwDatabase database, Stream stream, byte[] protectedStreamKey, byte[] hashOfHeader)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Kp2aBusinessLogic/IKp2aApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using KeePassLib.Serialization;
using keepass2android.Io;
using KeePassLib.Interfaces;
#if !NoNet
#if !NoNet && !EXCLUDE_JAVAFILESTORAGE
using Keepass2android.Javafilestorage;
#endif

Expand All @@ -29,7 +29,7 @@ public interface ICertificateValidationHandler

}

/// <summary>
/// <summary>
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
/// </summary>
/// This also contains methods which are UI specific and should be replacable for testing.
Expand All @@ -38,7 +38,7 @@ public interface IKp2aApp : ICertificateValidationHandler
/// <summary>
/// Locks all currently open databases, quicklocking if available (unless false is passed for allowQuickUnlock)
/// </summary>
void Lock(bool allowQuickUnlock);
void Lock(bool allowQuickUnlock, bool lockWasTriggeredByTimeout);


/// <summary>
Expand Down Expand Up @@ -123,7 +123,7 @@ void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey,


bool CheckForDuplicateUuids { get; }
#if !NoNet
#if !NoNet && !EXCLUDE_JAVAFILESTORAGE
ICertificateErrorHandler CertificateErrorHandler { get; }


Expand Down
7 changes: 4 additions & 3 deletions src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut<UiStringKey> reason = n
}
else return false;
}
else throw new Exception("couldn't move to first result element: " + (cursor == null) + uri.ToString());
else return false;
}
catch (Exception e)
{
Expand Down Expand Up @@ -333,12 +333,13 @@ public Stream OpenFile()

public void CommitWrite()
{
ParcelFileDescriptor fileDescriptor = _ctx.ContentResolver.OpenFileDescriptor(Android.Net.Uri.Parse(_path), "w");
ParcelFileDescriptor fileDescriptor = _ctx.ContentResolver.OpenFileDescriptor(Android.Net.Uri.Parse(_path), "rwt");

using (var outputStream = new FileOutputStream(fileDescriptor.FileDescriptor))
{
byte[] data = _memoryStream.ToArray();
outputStream.Write(data, 0, data.Length);

outputStream.Write(data);
outputStream.Close();
}
fileDescriptor.Close();
Expand Down
Loading

0 comments on commit 1ecfe83

Please sign in to comment.