mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 14:45:47 +03:00
PassCodeManager: don't count passcode/credentials activity towards activity counter
This prevents repetition attacks Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
fa73725815
commit
579af4ab30
2 changed files with 10 additions and 12 deletions
|
@ -324,7 +324,6 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||||
@Override
|
@Override
|
||||||
public void onActivityPaused(@NonNull Activity activity) {
|
public void onActivityPaused(@NonNull Activity activity) {
|
||||||
Log_OC.d(activity.getClass().getSimpleName(), "onPause() ending");
|
Log_OC.d(activity.getClass().getSimpleName(), "onPause() ending");
|
||||||
passCodeManager.onActivityPaused(activity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,7 +30,6 @@ import android.view.WindowManager;
|
||||||
import com.nextcloud.client.preferences.AppPreferences;
|
import com.nextcloud.client.preferences.AppPreferences;
|
||||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||||
import com.owncloud.android.MainApp;
|
import com.owncloud.android.MainApp;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import com.owncloud.android.ui.activity.PassCodeActivity;
|
import com.owncloud.android.ui.activity.PassCodeActivity;
|
||||||
import com.owncloud.android.ui.activity.RequestCredentialsActivity;
|
import com.owncloud.android.ui.activity.RequestCredentialsActivity;
|
||||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||||
|
@ -66,6 +65,10 @@ public final class PassCodeManager {
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isExemptActivity(final Activity activity) {
|
||||||
|
return exemptOfPasscodeActivities.contains(activity.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
private void setSecureFlag(Activity activity) {
|
private void setSecureFlag(Activity activity) {
|
||||||
Window window = activity.getWindow();
|
Window window = activity.getWindow();
|
||||||
if (window != null) {
|
if (window != null) {
|
||||||
|
@ -83,7 +86,7 @@ public final class PassCodeManager {
|
||||||
|
|
||||||
setSecureFlag(activity);
|
setSecureFlag(activity);
|
||||||
|
|
||||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested(timestamp)) {
|
if (!isExemptActivity(activity) && passCodeShouldBeRequested(timestamp)) {
|
||||||
askedForPin = true;
|
askedForPin = true;
|
||||||
|
|
||||||
preferences.setLockTimestamp(0);
|
preferences.setLockTimestamp(0);
|
||||||
|
@ -94,7 +97,7 @@ public final class PassCodeManager {
|
||||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) &&
|
if (!isExemptActivity(activity) &&
|
||||||
deviceCredentialsShouldBeRequested(timestamp, activity)) {
|
deviceCredentialsShouldBeRequested(timestamp, activity)) {
|
||||||
askedForPin = true;
|
askedForPin = true;
|
||||||
|
|
||||||
|
@ -109,20 +112,16 @@ public final class PassCodeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visibleActivitiesCounter++; // keep it AFTER passCodeShouldBeRequested was checked
|
if (!isExemptActivity(activity)) {
|
||||||
|
visibleActivitiesCounter++; // keep it AFTER passCodeShouldBeRequested was checked
|
||||||
|
}
|
||||||
|
|
||||||
return askedForPin;
|
return askedForPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onActivityPaused(Activity activity) {
|
|
||||||
if (visibleActivitiesCounter > 0) {
|
|
||||||
visibleActivitiesCounter--;
|
|
||||||
Log_OC.d("Timestamp", "counter: " + visibleActivitiesCounter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onActivityStopped(Activity activity) {
|
public void onActivityStopped(Activity activity) {
|
||||||
if (visibleActivitiesCounter > 0) {
|
if (visibleActivitiesCounter > 0 && !isExemptActivity(activity)) {
|
||||||
visibleActivitiesCounter--;
|
visibleActivitiesCounter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue