mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-16 15:02:54 +00:00
Do not print a trace when calling the private finish() overload fails
This commit is contained in:
parent
715c5112ab
commit
9f55d4f659
1 changed files with 6 additions and 1 deletions
|
@ -74,15 +74,20 @@ public abstract class AegisActivity extends AppCompatActivity implements VaultMa
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SoonBlockedPrivateApi")
|
@SuppressLint("SoonBlockedPrivateApi")
|
||||||
|
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||||
@Override
|
@Override
|
||||||
public void onLocked(boolean userInitiated) {
|
public void onLocked(boolean userInitiated) {
|
||||||
setResult(RESULT_CANCELED, null);
|
setResult(RESULT_CANCELED, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Call a private overload of the finish() method to prevent the app
|
||||||
|
// from disappearing from the recent apps menu
|
||||||
Method method = Activity.class.getDeclaredMethod("finish", int.class);
|
Method method = Activity.class.getDeclaredMethod("finish", int.class);
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(this, 2); // FINISH_TASK_WITH_ACTIVITY = 2
|
method.invoke(this, 2); // FINISH_TASK_WITH_ACTIVITY = 2
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
// On recent Android versions, the overload of the finish() method
|
||||||
|
// used above is no longer accessible
|
||||||
finishAndRemoveTask();
|
finishAndRemoveTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue