-
-
Notifications
You must be signed in to change notification settings - Fork 469
Avoid StrictMode warnings (followup) #4809
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
Changes from 3 commits
646940c
bfd80cc
4a910a4
98151e2
77ebaa6
f741885
a404646
32755ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,18 +227,24 @@ private void setDeviceIO(final @NotNull Device device, final boolean includeDyna | |
| // this way of getting the size of storage might be problematic for storages bigger than 2GB | ||
| // check the use of | ||
| // https://developer.android.com/reference/java/io/File.html#getFreeSpace%28%29 | ||
| final @Nullable File internalStorageFile = context.getExternalFilesDir(null); | ||
| if (internalStorageFile != null) { | ||
| StatFs internalStorageStat = new StatFs(internalStorageFile.getPath()); | ||
| device.setStorageSize(getTotalInternalStorage(internalStorageStat)); | ||
| device.setFreeStorage(getUnusedInternalStorage(internalStorageStat)); | ||
| } | ||
|
|
||
| final @Nullable StatFs externalStorageStat = getExternalStorageStat(internalStorageFile); | ||
| if (externalStorageStat != null) { | ||
| device.setExternalStorageSize(getTotalExternalStorage(externalStorageStat)); | ||
| device.setExternalFreeStorage(getUnusedExternalStorage(externalStorageStat)); | ||
| } | ||
| options | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do this to have a base of 0 strictmode warnings, right? I'm just wondering if we should keep this as-is, as the collection of these attributes can be turned off via settings anyway.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, but the default is enabled, so i guess it makes more sense for the user to have no strictMode warnings "by default" |
||
| .getRuntimeManager() | ||
| .runWithRelaxedPolicy( | ||
| () -> { | ||
| final @Nullable File internalStorageFile = context.getExternalFilesDir(null); | ||
| if (internalStorageFile != null) { | ||
| StatFs internalStorageStat = new StatFs(internalStorageFile.getPath()); | ||
| device.setStorageSize(getTotalInternalStorage(internalStorageStat)); | ||
| device.setFreeStorage(getUnusedInternalStorage(internalStorageStat)); | ||
| } | ||
|
|
||
| final @Nullable StatFs externalStorageStat = | ||
| getExternalStorageStat(internalStorageFile); | ||
| if (externalStorageStat != null) { | ||
| device.setExternalStorageSize(getTotalExternalStorage(externalStorageStat)); | ||
| device.setExternalFreeStorage(getUnusedExternalStorage(externalStorageStat)); | ||
| } | ||
| }); | ||
|
|
||
| if (device.getConnectionType() == null) { | ||
| // wifi, ethernet or cellular, null if none | ||
|
|
@@ -479,7 +485,7 @@ private Long getUnusedExternalStorage(final @NotNull StatFs stat) { | |
| @Nullable | ||
| private String getDeviceId() { | ||
| try { | ||
| return Installation.id(context); | ||
| return options.getRuntimeManager().runWithRelaxedPolicy(() -> Installation.id(context)); | ||
| } catch (Throwable e) { | ||
| options.getLogger().log(SentryLevel.ERROR, "Error getting installationId.", e); | ||
| } | ||
|
|
||
|
stefanosiano marked this conversation as resolved.
|
Uh oh!
There was an error while loading. Please reload this page.