Merge pull request #4933 from nextcloud/appLocking

Use SystemClock.elapsedRealtime() instead of System.currentTimeMillis()
This commit is contained in:
Tobias Kaminsky 2019-12-04 08:21:04 +01:00 committed by GitHub
commit dda56defb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View file

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.PowerManager;
import android.os.SystemClock;
import android.view.Window;
import android.view.WindowManager;
@ -102,7 +103,7 @@ public final class PassCodeManager {
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
} else {
if (!askedForPin && preferences.getLockTimestamp() != 0) {
preferences.setLockTimestamp(System.currentTimeMillis());
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
}
}

View file

@ -41,6 +41,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
@ -1437,7 +1438,7 @@ public abstract class DrawerActivity extends ToolbarActivity
@Override
protected void onStop() {
if (preferences.getLockTimestamp() != 0) {
preferences.setLockTimestamp(System.currentTimeMillis());
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
}
EventBus.getDefault().unregister(this);
super.onStop();

View file

@ -24,6 +24,7 @@ package com.owncloud.android.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -239,7 +240,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
if (ACTION_CHECK.equals(getIntent().getAction())) {
if (checkPassCode()) {
/// pass code accepted in request, user is allowed to access the app
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
hideSoftKeyboard();
finish();
@ -249,7 +250,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
} else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
if (checkPassCode()) {
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
Intent resultIntent = new Intent();
resultIntent.putExtra(KEY_CHECK_RESULT, true);
setResult(RESULT_OK, resultIntent);

View file

@ -25,6 +25,7 @@ import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.SystemClock;
import android.widget.Toast;
import com.nextcloud.client.preferences.AppPreferencesImpl;
@ -53,7 +54,7 @@ public class RequestCredentialsActivity extends Activity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
if (resultCode == Activity.RESULT_OK) {
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
finishWithResult(KEY_CHECK_RESULT_TRUE);
} else if (resultCode == Activity.RESULT_CANCELED) {
finishWithResult(KEY_CHECK_RESULT_CANCEL);