mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 22:39:12 +00:00
Lock on minimize in case ALWAYS_FINISH_ACTIVITIES is enabled
This commit is contained in:
parent
920df1d9be
commit
4b29b94b6e
1 changed files with 11 additions and 12 deletions
|
@ -9,6 +9,7 @@ import android.content.pm.ShortcutInfo;
|
||||||
import android.content.pm.ShortcutManager;
|
import android.content.pm.ShortcutManager;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
@ -17,23 +18,14 @@ import androidx.lifecycle.Lifecycle;
|
||||||
import androidx.lifecycle.LifecycleEventObserver;
|
import androidx.lifecycle.LifecycleEventObserver;
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||||
import androidx.room.Room;
|
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.database.AppDatabase;
|
|
||||||
import com.beemdevelopment.aegis.database.AuditLogEntry;
|
|
||||||
import com.beemdevelopment.aegis.database.AuditLogRepository;
|
|
||||||
import com.beemdevelopment.aegis.receivers.VaultLockReceiver;
|
import com.beemdevelopment.aegis.receivers.VaultLockReceiver;
|
||||||
import com.beemdevelopment.aegis.ui.MainActivity;
|
import com.beemdevelopment.aegis.ui.MainActivity;
|
||||||
import com.beemdevelopment.aegis.util.IOUtils;
|
import com.beemdevelopment.aegis.util.IOUtils;
|
||||||
import com.beemdevelopment.aegis.vault.VaultManager;
|
import com.beemdevelopment.aegis.vault.VaultManager;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
import org.checkerframework.checker.units.qual.A;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import dagger.hilt.InstallIn;
|
import dagger.hilt.InstallIn;
|
||||||
import dagger.hilt.android.EarlyEntryPoint;
|
import dagger.hilt.android.EarlyEntryPoint;
|
||||||
|
@ -114,9 +106,16 @@ public abstract class AegisApplicationBase extends Application {
|
||||||
private class AppLifecycleObserver implements LifecycleEventObserver {
|
private class AppLifecycleObserver implements LifecycleEventObserver {
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {
|
public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {
|
||||||
if (event == Lifecycle.Event.ON_STOP
|
if (event != Lifecycle.Event.ON_STOP ) {
|
||||||
&& _vaultManager.isAutoLockEnabled(Preferences.AUTO_LOCK_ON_MINIMIZE)
|
return;
|
||||||
&& !_vaultManager.isAutoLockBlocked()) {
|
}
|
||||||
|
|
||||||
|
// Immediately lock if "Don't keep activities" is enabled to work around an issue where
|
||||||
|
// MainActivity is destroyed before the ACTION_SCREEN_OFF intent is received
|
||||||
|
boolean lockOnMinimize = _vaultManager.isAutoLockEnabled(Preferences.AUTO_LOCK_ON_MINIMIZE)
|
||||||
|
|| Settings.Global.getInt(getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0) != 0;
|
||||||
|
|
||||||
|
if (lockOnMinimize && !_vaultManager.isAutoLockBlocked()) {
|
||||||
_vaultManager.lock(false);
|
_vaultManager.lock(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue