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

Prevent unnecessary free disk calculations on initialisation #409

Merged
merged 2 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 4.X.X (TBD)

### Bug fixes

* Prevent unnecessary free disk calculations on initialisation
[#409](https://github.com/bugsnag/bugsnag-android/pull/409)

## 4.10.0 (2019-01-07)

* Improve kotlin support by allowing property access
Expand Down
23 changes: 14 additions & 9 deletions ndk/src/main/java/com/bugsnag/android/ndk/NativeBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,26 @@ private void handleInstallMessage(Object arg) {
return;
}
String reportPath = reportDirectory + UUID.randomUUID().toString() + ".crash";
String[] abis = (String[])NativeInterface.getDeviceData().get("cpuAbi");
boolean is32bit = true;
for (String abi : abis) {
if (abi.contains("64")) {
is32bit = false;
break;
}
}
install(reportPath, true, Build.VERSION.SDK_INT, is32bit);
install(reportPath, true, Build.VERSION.SDK_INT, is32bit());
installed.set(true);
} finally {
lock.unlock();
}
}

private boolean is32bit() {
String[] abis = NativeInterface.getCpuAbi();

boolean is32bit = true;
for (String abi : abis) {
if (abi.contains("64")) {
is32bit = false;
break;
}
}
return is32bit;
}

private void handleAddBreadcrumb(Object arg) {
if (arg instanceof Breadcrumb) {
Breadcrumb crumb = (Breadcrumb) arg;
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/com/bugsnag/android/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Client(@NonNull Context androidContext, @NonNull Configuration configurat
// Set sensible defaults
setProjectPackages(appContext.getPackageName());

String deviceId = getStringFromMap("id", deviceData.getDeviceData());
String deviceId = deviceData.getId();

if (config.getPersistUserBetweenSessions()) {
// Check to see if a user was stored in the SharedPreferences
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/main/java/com/bugsnag/android/DeviceData.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Map<String, Object> getDeviceMetaData() {
return map;
}

String getId() {
return id;
}

/**
* Check if the current Android device is rooted
*/
Expand Down
9 changes: 9 additions & 0 deletions sdk/src/main/java/com/bugsnag/android/NativeInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Used as the entry point for native code to allow proguard to obfuscate other areas if needed
*/
public class NativeInterface {

public enum MessageType {
/**
* Add a breadcrumb. The Message object should be the breadcrumb
Expand Down Expand Up @@ -233,6 +234,14 @@ public static Map<String,Object> getDeviceData() {
return deviceData;
}

/**
* Retrieve the CPU ABI(s) for the current device
*/
@NonNull
public static String[] getCpuAbi() {
return getClient().deviceData.cpuAbi;
}

/**
* Retrieves global metadata from the static Client instance as a Map
*/
Expand Down