Fix some rare crashes when restoring the app after termination

Also fixes an issue where the app shortcuts would not work for unencrypted vaults
This commit is contained in:
Alexander Bakker 2019-04-08 23:13:11 +02:00
parent 6d93b78f9a
commit 0563ac917a
5 changed files with 25 additions and 20 deletions

View file

@ -41,7 +41,7 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.getbase:floatingactionbutton:1.10.1' implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.github.apl-devs:appintro:v4.2.2' implementation 'com.github.apl-devs:appintro:v4.2.2'
implementation 'com.github.avito-tech:krop:3e65e12' implementation 'com.github.avito-tech:krop:0.43'
implementation 'com.madgag.spongycastle:core:1.58.0.0' implementation 'com.madgag.spongycastle:core:1.58.0.0'
implementation 'com.mattprecious.swirl:swirl:1.0.0' implementation 'com.mattprecious.swirl:swirl:1.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0' implementation 'de.hdodenhof:circleimageview:2.2.0'

View file

@ -15,11 +15,11 @@
android:label="Aegis" android:label="Aegis"
android:supportsRtl="true" android:supportsRtl="true"
tools:replace="android:theme" tools:replace="android:theme"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar"
tools:ignore="GoogleAppIndexingWarning">
<activity <activity
android:name="com.beemdevelopment.aegis.ui.MainActivity" android:name="com.beemdevelopment.aegis.ui.MainActivity"
android:label="${title}" android:label="${title}"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"> android:launchMode="singleTask">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
@ -40,12 +40,9 @@
</activity> </activity>
<activity <activity
android:name="com.beemdevelopment.aegis.ui.IntroActivity" android:name="com.beemdevelopment.aegis.ui.IntroActivity"
android:theme="@style/Theme.Intro" android:theme="@style/Theme.Intro">
android:launchMode="singleTop">
</activity> </activity>
<activity <activity android:name="com.beemdevelopment.aegis.ui.AuthActivity">
android:name="com.beemdevelopment.aegis.ui.AuthActivity"
android:launchMode="singleTop">
</activity> </activity>
<activity android:name="com.beemdevelopment.aegis.ui.PreferencesActivity"> <activity android:name="com.beemdevelopment.aegis.ui.PreferencesActivity">
</activity> </activity>

View file

@ -1,5 +1,6 @@
package com.beemdevelopment.aegis.ui; package com.beemdevelopment.aegis.ui;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.WindowManager; import android.view.WindowManager;
@ -18,6 +19,15 @@ public abstract class AegisActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
_app = (AegisApplication) getApplication(); _app = (AegisApplication) getApplication();
// if the app was killed, relaunch MainActivity and close everything else
if (!(this instanceof MainActivity) && !(this instanceof AuthActivity) && _app.getDatabaseManager().isLocked()) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
return;
}
// set FLAG_SECURE on the window of every AegisActivity // set FLAG_SECURE on the window of every AegisActivity
if (getPreferences().isSecureScreenEnabled()) { if (getPreferences().isSecureScreenEnabled()) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);

View file

@ -114,9 +114,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
super.onNewIntent(intent); super.onNewIntent(intent);
setIntent(intent); setIntent(intent);
if (!doShortcutActions() || _db.isLocked()) { doShortcutActions();
unlockDatabase(null);
}
} }
@Override @Override
@ -305,15 +303,11 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
startActivityForResult(scannerActivity, CODE_SCAN); startActivityForResult(scannerActivity, CODE_SCAN);
} }
private boolean doShortcutActions() { private void doShortcutActions() {
// return false if an action was blocked by a locked database
// otherwise, always return true
Intent intent = getIntent(); Intent intent = getIntent();
String action = intent.getStringExtra("action"); String action = intent.getStringExtra("action");
if (action == null) { if (action == null || _db.isLocked()) {
return true; return;
} else if (_db.isLocked()) {
return false;
} }
switch (action) { switch (action) {
@ -323,11 +317,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
intent.removeExtra("action"); intent.removeExtra("action");
return true;
} }
public void startActivityForResult(Intent intent, int requestCode) { public void startActivityForResult(Intent intent, int requestCode) {
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
super.startActivityForResult(intent, requestCode); super.startActivityForResult(intent, requestCode);
} }
@ -361,6 +353,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
updateLockIcon(); updateLockIcon();
doShortcutActions();
} }
private BottomSheetDialog createBottomSheet(final DatabaseEntry entry) { private BottomSheetDialog createBottomSheet(final DatabaseEntry entry) {

View file

@ -339,6 +339,11 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
return true; return true;
} }
}); });
}
@Override
public void onActivityCreated (Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
updateEncryptionPreferences(); updateEncryptionPreferences();
} }