disable password-based QuickUnlock when device is not protected by screen lock
This commit is contained in:
@@ -1423,6 +1423,8 @@ namespace keepass2android
|
||||
if (cbQuickUnlock == null)
|
||||
throw new NullPointerException("cpQuickUnlock");
|
||||
App.Kp2a.SetQuickUnlockEnabled(cbQuickUnlock.Checked);
|
||||
App.Kp2a.ScreenLockWasEnabledWhenOpeningDatabase =
|
||||
(((KeyguardManager)GetSystemService(Context.KeyguardService)!)!).IsDeviceSecure;
|
||||
|
||||
if ((_loadDbFileTask != null) && (App.Kp2a.OfflineMode != _loadDbTaskOffline))
|
||||
{
|
||||
|
@@ -25,6 +25,7 @@ using Android.Widget;
|
||||
using Android.Content.PM;
|
||||
using KeePassLib.Keys;
|
||||
using Android.Preferences;
|
||||
using Android.Provider;
|
||||
using Android.Runtime;
|
||||
|
||||
using Android.Views.InputMethods;
|
||||
@@ -162,6 +163,29 @@ namespace keepass2android
|
||||
if (bundle != null)
|
||||
numFailedAttempts = bundle.GetInt(NumFailedAttemptsKey, 0);
|
||||
|
||||
FindViewById(Resource.Id.QuickUnlock_buttonEnableLock).Click += (object sender, EventArgs e) =>
|
||||
{
|
||||
Intent intent = new Intent(Settings.ActionSecuritySettings);
|
||||
StartActivity(intent);
|
||||
|
||||
};
|
||||
|
||||
FindViewById(Resource.Id.QuickUnlock_buttonCloseDb).Click += (object sender, EventArgs e) =>
|
||||
{
|
||||
App.Kp2a.Lock(false);
|
||||
};
|
||||
|
||||
if (App.Kp2a.ScreenLockWasEnabledWhenOpeningDatabase == false)
|
||||
{
|
||||
FindViewById(Resource.Id.QuickUnlockForm).Visibility = ViewStates.Gone;
|
||||
FindViewById(Resource.Id.QuickUnlockBlocked).Visibility = ViewStates.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
FindViewById(Resource.Id.QuickUnlockForm).Visibility = ViewStates.Visible;
|
||||
FindViewById(Resource.Id.QuickUnlockBlocked).Visibility = ViewStates.Gone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -79,6 +79,12 @@ android:paddingRight="16dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/QuickUnlockForm">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/QuickUnlock_label"
|
||||
android:text="@string/QuickUnlock_label"
|
||||
@@ -88,11 +94,6 @@ android:paddingRight="16dp"
|
||||
android:textSize="14sp"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:inputType="textPassword"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -121,6 +122,60 @@ android:paddingRight="16dp"
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/md_theme_secondaryContainer"
|
||||
android:id="@+id/QuickUnlockBlocked"
|
||||
android:padding="16dp"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/quick_unlock_blocked_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/password_based_quick_unlock_not_available"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alert_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/password_based_quick_unlock_not_available_text"
|
||||
android:textSize="16sp"
|
||||
android:paddingBottom="8dp"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<Button
|
||||
android:id="@+id/QuickUnlock_buttonEnableLock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:backgroundTint="@color/md_theme_secondary"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/enable_screen_lock"
|
||||
android:fontFamily="sans-serif-medium" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/QuickUnlock_buttonCloseDb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:backgroundTint="@color/md_theme_secondary"
|
||||
android:textColor="@android:color/white"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:text="@string/QuickUnlock_lockButton" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/spacing"
|
||||
|
@@ -93,6 +93,8 @@
|
||||
<string name="disable_fingerprint_unlock">Disable Biometric Unlock</string>
|
||||
<string name="enable_fingerprint_unlock">Enable full Biometric Unlock</string>
|
||||
<string name="enable_fingerprint_quickunlock">Enable Biometric Unlock for QuickUnlock</string>
|
||||
<string name="password_based_quick_unlock_not_available">Password-based QuickUnlock not available</string>
|
||||
<string name="password_based_quick_unlock_not_available_text">QuickUnlock using a part of your password is blocked because screen lock is not activated on your device. This behavior is to protect you in case somebody watched you entering your QuickUnlock key.</string>
|
||||
<string name="fingerprint_unlock_failed">Biometric Unlock failed. Decryption key was invalidated by Android OS. This usually happens if a biometric authentication or security settings were changed. </string>
|
||||
<string name="fingerprint_disabled_wrong_masterkey">Unlocking the database failed: Invalid composite key. Biometric Unlock was disabled because apparently the stored master password is no longer valid. </string>
|
||||
<string name="fingerprint_reenable">Please re-enable Biometric Unlock for the new master password.</string>
|
||||
@@ -319,6 +321,7 @@
|
||||
<string name="QuickUnlock_label_secure">Enter QuickUnlock code:</string>
|
||||
<string name="QuickUnlock_button">QuickUnlock!</string>
|
||||
<string name="QuickUnlock_lockButton">Close database</string>
|
||||
<string name="enable_screen_lock">Enable screen lock</string>
|
||||
<string name="QuickUnlockDefaultEnabled_title">Enable QuickUnlock by default</string>
|
||||
<string name="QuickUnlockDefaultEnabled_summary">Defines whether QuickUnlock is enabled by default or not.</string>
|
||||
<string name="ViewDatabaseSecure_title">Protect database display</string>
|
||||
|
@@ -351,6 +351,9 @@ namespace keepass2android
|
||||
QuickUnlockEnabled = enabled;
|
||||
}
|
||||
|
||||
public bool ScreenLockWasEnabledWhenOpeningDatabase { get; set; }
|
||||
|
||||
|
||||
public bool QuickUnlockEnabled { get; private set; }
|
||||
|
||||
public int QuickUnlockKeyLength { get; private set; }
|
||||
@@ -833,8 +836,8 @@ namespace keepass2android
|
||||
new AndroidContentStorage(LocaleManager.LocalizedAppContext),
|
||||
#if !EXCLUDE_JAVAFILESTORAGE
|
||||
#if !NoNet
|
||||
new DropboxFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new DropboxAppFolderFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
/*TODO new DropboxFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new DropboxAppFolderFileStorage(LocaleManager.LocalizedAppContext, this),*/
|
||||
GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(LocaleManager.LocalizedAppContext)==ConnectionResult.Success ? new GoogleDriveFileStorage(LocaleManager.LocalizedAppContext, this) : null,
|
||||
GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(LocaleManager.LocalizedAppContext)==ConnectionResult.Success ? new GoogleDriveAppDataFileStorage(LocaleManager.LocalizedAppContext, this) : null,
|
||||
new OneDriveFileStorage(this),
|
||||
|
Reference in New Issue
Block a user