PassCodeActivity: update lock timestamp when lock has just been set

Prevents asking for pass immediately after setting it

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-02-15 10:24:24 +01:00
parent 8b03556f71
commit aafa7780f6
No known key found for this signature in database
GPG key ID: 2585783189A62105
2 changed files with 11 additions and 3 deletions

View file

@ -74,7 +74,7 @@ class PassCodeManager(private val preferences: AppPreferences) {
}
if (!askedForPin && preferences.lockTimestamp != 0L) {
preferences.lockTimestamp = SystemClock.elapsedRealtime()
updateLockTimestamp()
}
if (!isExemptActivity(activity)) {
@ -117,6 +117,10 @@ class PassCodeManager(private val preferences: AppPreferences) {
}
}
fun updateLockTimestamp() {
preferences.lockTimestamp = SystemClock.elapsedRealtime()
}
/**
* `true` if the time elapsed since last unlock is longer than [PASS_CODE_TIMEOUT] and no activities are visible
*/

View file

@ -41,6 +41,7 @@ import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.R;
import com.owncloud.android.authentication.PassCodeManager;
import com.owncloud.android.databinding.PasscodelockBinding;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
@ -74,6 +75,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
public final static String PREFERENCE_PASSCODE_D4 = "PrefPinCode4";
@Inject AppPreferences preferences;
@Inject PassCodeManager passCodeManager;
private PasscodelockBinding binding;
private final EditText[] passCodeEditTexts = new EditText[4];
private String [] passCodeDigits = {"","","",""};
@ -242,7 +244,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
preferences.resetPinWrongAttempts();
/// pass code accepted in request, user is allowed to access the app
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
passCodeManager.updateLockTimestamp();
hideSoftKeyboard();
finish();
@ -254,7 +256,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
} else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
if (checkPassCode()) {
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
passCodeManager.updateLockTimestamp();
Intent resultIntent = new Intent();
resultIntent.putExtra(KEY_CHECK_RESULT, true);
setResult(RESULT_OK, resultIntent);
@ -392,6 +394,8 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
setResult(RESULT_OK, resultIntent);
passCodeManager.updateLockTimestamp();
finish();
}