|
49 | 49 | import java.util.zip.ZipFile; |
50 | 50 | import java.util.zip.ZipInputStream; |
51 | 51 |
|
| 52 | +import io.sentry.Breadcrumb; |
| 53 | +import io.sentry.Sentry; |
| 54 | +import io.sentry.SentryLevel; |
| 55 | + |
52 | 56 | public class InstallerActivity extends FoxActivity { |
53 | 57 | private static final String TAG = "InstallerActivity"; |
54 | 58 | public LinearProgressIndicator progressIndicator; |
@@ -99,6 +103,17 @@ protected void onCreate(Bundle savedInstanceState) { |
99 | 103 | return; |
100 | 104 | } |
101 | 105 | Log.i(TAG, "Install link: " + target); |
| 106 | + // Note: Sentry only send this info on crash. |
| 107 | + if (MainApplication.isCrashReportingEnabled()) { |
| 108 | + Breadcrumb breadcrumb = new Breadcrumb(); |
| 109 | + breadcrumb.setType("install"); |
| 110 | + breadcrumb.setData("target", target); |
| 111 | + breadcrumb.setData("name", name); |
| 112 | + breadcrumb.setData("checksum", checksum); |
| 113 | + breadcrumb.setCategory("app.action.preinstall"); |
| 114 | + breadcrumb.setLevel(SentryLevel.INFO); |
| 115 | + Sentry.addBreadcrumb(breadcrumb); |
| 116 | + } |
102 | 117 | boolean urlMode = target.startsWith("http://") || target.startsWith("https://"); |
103 | 118 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
104 | 119 | setTitle(name); |
@@ -138,9 +153,10 @@ protected void onCreate(Bundle savedInstanceState) { |
138 | 153 | !new SuFile(moduleCache.getAbsolutePath()).delete()) |
139 | 154 | Log.e(TAG, "Failed to delete module cache"); |
140 | 155 | String errMessage = "Failed to download module zip"; |
| 156 | + byte[] rawModule; |
141 | 157 | try { |
142 | 158 | Log.i(TAG, (urlMode ? "Downloading: " : "Loading: ") + target); |
143 | | - byte[] rawModule = urlMode ? Http.doHttpGet(target, (progress, max, done) -> { |
| 159 | + rawModule = urlMode ? Http.doHttpGet(target, (progress, max, done) -> { |
144 | 160 | if (max <= 0 && this.progressIndicator.isIndeterminate()) |
145 | 161 | return; |
146 | 162 | this.runOnUiThread(() -> { |
@@ -227,6 +243,14 @@ protected void onCreate(Bundle savedInstanceState) { |
227 | 243 | Log.e(TAG, errMessage, e); |
228 | 244 | this.setInstallStateFinished(false, |
229 | 245 | "! " + errMessage, ""); |
| 246 | + } catch (OutOfMemoryError e) { |
| 247 | + //noinspection UnusedAssignment (Important to avoid OutOfMemoryError) |
| 248 | + rawModule = null; // Because reference is kept when calling setInstallStateFinished |
| 249 | + if ("Failed to install module zip".equals(errMessage)) |
| 250 | + throw e; // Ignore if in installation state. |
| 251 | + Log.e(TAG, "Module too large", e); |
| 252 | + this.setInstallStateFinished(false, |
| 253 | + "! Module is too large to be loaded on this device", ""); |
230 | 254 | } |
231 | 255 | }, "Module install Thread").start(); |
232 | 256 | } |
@@ -416,6 +440,19 @@ private void doInstall(File file, boolean noExtensions, boolean rootless) { |
416 | 440 | "cd \"" + this.moduleCache.getAbsolutePath() + "\"", |
417 | 441 | installCommand).to(installerController, installerMonitor); |
418 | 442 | } |
| 443 | + // Note: Sentry only send this info on crash. |
| 444 | + if (MainApplication.isCrashReportingEnabled()) { |
| 445 | + Breadcrumb breadcrumb = new Breadcrumb(); |
| 446 | + breadcrumb.setType("install"); |
| 447 | + breadcrumb.setData("moduleId", moduleId == null ? "<null>" : moduleId); |
| 448 | + breadcrumb.setData("isAnyKernel3", anyKernel3 ? "true" : "false"); |
| 449 | + breadcrumb.setData("noExtensions", noExtensions ? "true" : "false"); |
| 450 | + breadcrumb.setData("ansi", this.installerTerminal |
| 451 | + .isAnsiEnabled() ? "enabled" : "disabled"); |
| 452 | + breadcrumb.setCategory("app.action.install"); |
| 453 | + breadcrumb.setLevel(SentryLevel.INFO); |
| 454 | + Sentry.addBreadcrumb(breadcrumb); |
| 455 | + } |
419 | 456 | } |
420 | 457 | boolean success = installJob.exec().isSuccess(); |
421 | 458 | // Wait one UI cycle before disabling controller or processing results |
|
0 commit comments