mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Merge pull request #4933 from nextcloud/appLocking
Use SystemClock.elapsedRealtime() instead of System.currentTimeMillis()
This commit is contained in:
commit
dda56defb4
4 changed files with 9 additions and 5 deletions
|
@ -24,6 +24,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ public final class PassCodeManager {
|
||||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
||||||
} else {
|
} else {
|
||||||
if (!askedForPin && preferences.getLockTimestamp() != 0) {
|
if (!askedForPin && preferences.getLockTimestamp() != 0) {
|
||||||
preferences.setLockTimestamp(System.currentTimeMillis());
|
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -1437,7 +1438,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
if (preferences.getLockTimestamp() != 0) {
|
if (preferences.getLockTimestamp() != 0) {
|
||||||
preferences.setLockTimestamp(System.currentTimeMillis());
|
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
|
||||||
}
|
}
|
||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
|
@ -24,6 +24,7 @@ package com.owncloud.android.ui.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -239,7 +240,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
||||||
if (ACTION_CHECK.equals(getIntent().getAction())) {
|
if (ACTION_CHECK.equals(getIntent().getAction())) {
|
||||||
if (checkPassCode()) {
|
if (checkPassCode()) {
|
||||||
/// pass code accepted in request, user is allowed to access the app
|
/// 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();
|
hideSoftKeyboard();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
|
@ -249,7 +250,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
||||||
|
|
||||||
} else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
|
} else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
|
||||||
if (checkPassCode()) {
|
if (checkPassCode()) {
|
||||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
|
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
|
||||||
Intent resultIntent = new Intent();
|
Intent resultIntent = new Intent();
|
||||||
resultIntent.putExtra(KEY_CHECK_RESULT, true);
|
resultIntent.putExtra(KEY_CHECK_RESULT, true);
|
||||||
setResult(RESULT_OK, resultIntent);
|
setResult(RESULT_OK, resultIntent);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.app.KeyguardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||||
|
@ -53,7 +54,7 @@ public class RequestCredentialsActivity extends Activity {
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
|
if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
|
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
|
||||||
finishWithResult(KEY_CHECK_RESULT_TRUE);
|
finishWithResult(KEY_CHECK_RESULT_TRUE);
|
||||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
} else if (resultCode == Activity.RESULT_CANCELED) {
|
||||||
finishWithResult(KEY_CHECK_RESULT_CANCEL);
|
finishWithResult(KEY_CHECK_RESULT_CANCEL);
|
||||||
|
|
Loading…
Reference in a new issue