Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Stop patch when signing fails #1553

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,7 @@ class MainActivity : FlutterActivity() {

updateProgress(0.9, "Signing...", "Signing APK")

try {
Signer("ReVanced", keystorePassword)
.signApk(patchedFile, outFile, keyStoreFile)
} catch (e: Exception) {
print("Error signing APK: ${e.message}")
e.printStackTrace()
}
Signer("ReVanced", keystorePassword).signApk(patchedFile, outFile, keyStoreFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not instead simply return after the stack trace is printed? Also when would you expect an error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not instead simply return after the stack trace is printed?

But I think, if an exception is occurred, the exception should be handled at this catch block:

} catch (ex: Throwable) {
if (!cancel) {
val stack = ex.stackTraceToString()
updateProgress(
-100.0,
"Failed",
"An error occurred:\n$stack"
)
}
}

Looking at other parts of the method, I don't see any exception handling code.

Also when would you expect an error here?

If user entered an incorrect password

Screenshot

Screenshot_20231205-164905

If user imported a keystore generated by Android Studio

Screenshot

Screenshot_20231205-182526

(These screenshots are from this PR code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the stack trace is printed using print(), but this only outputs to stdout and does not appear on the screen.
So user can't see the error.
This problem can be seen in the screen recording at #1253.


updateProgress(1.0, "Patched", "Patched")
} catch (ex: Throwable) {
Expand Down