1
mirror of https://github.com/topjohnwu/Magisk synced 2024-11-16 00:13:57 +01:00

Skip getSessionInfo

This commit is contained in:
vvb2060 2023-04-05 16:00:02 +08:00 committed by John Wu
parent 637a8af234
commit f827755aaf

View File

@ -101,30 +101,25 @@ public final class APKInstall {
} else if (sessionId.equals(intent.getAction())) { } else if (sessionId.equals(intent.getAction())) {
int status = intent.getIntExtra(EXTRA_STATUS, STATUS_FAILURE_INVALID); int status = intent.getIntExtra(EXTRA_STATUS, STATUS_FAILURE_INVALID);
switch (status) { switch (status) {
case STATUS_PENDING_USER_ACTION: case STATUS_PENDING_USER_ACTION ->
userAction = intent.getParcelableExtra(Intent.EXTRA_INTENT); userAction = intent.getParcelableExtra(Intent.EXTRA_INTENT);
break; case STATUS_SUCCESS -> {
case STATUS_SUCCESS:
if (packageName == null) { if (packageName == null) {
onSuccess(context); onSuccess(context);
} }
break; }
default: default -> {
int id = intent.getIntExtra(EXTRA_SESSION_ID, 0); int id = intent.getIntExtra(EXTRA_SESSION_ID, 0);
if (id > 0) { var installer = context.getPackageManager().getPackageInstaller();
var installer = context.getPackageManager().getPackageInstaller(); try {
var info = installer.getSessionInfo(id); installer.abandonSession(id);
if (info != null) { } catch (SecurityException ignored) {
try {
installer.abandonSession(info.getSessionId());
} catch (Throwable ignored) {
}
}
} }
if (onFailure != null) { if (onFailure != null) {
onFailure.run(); onFailure.run();
} }
context.getApplicationContext().unregisterReceiver(this); context.getApplicationContext().unregisterReceiver(this);
}
} }
latch.countDown(); latch.countDown();
} }