Skip to content

Commit

Permalink
Merge pull request #413 from bugsnag/strictmode-fixes
Browse files Browse the repository at this point in the history
Strictmode fixes
  • Loading branch information
fractalwrench committed Jan 14, 2019
2 parents 7165f80 + 3836b0f commit bf32e3e
Show file tree
Hide file tree
Showing 33 changed files with 61 additions and 124 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 4.X.X (TBD)

### Bug fixes

* Cache result of device root check
[#411](https://github.com/bugsnag/bugsnag-android/pull/411)

* 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
8 changes: 8 additions & 0 deletions sdk/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@

<application android:label="Bugsnag Android Tests"></application>

<instrumentation
android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.bugsnag.android">
<meta-data
android:name="listener"
android:value="com.bugsnag.android.TestRunListener" />
</instrumentation>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public void setUp() throws Exception {
this.appData = appData.getAppDataSummary();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testVersionCode() {
assertEquals(1, appData.get("versionCode"));
Expand Down
5 changes: 0 additions & 5 deletions sdk/src/androidTest/java/com/bugsnag/android/AppDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public void setUp() throws Exception {
appData = new AppData(client).getAppData();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testPackageName() {
assertEquals("com.bugsnag.android.test", appData.get("packageName"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public void setUp() throws Exception {
assertEquals(0, client.breadcrumbs.store.size());
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void noCallback() throws Exception {
client.leaveBreadcrumb("Hello");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void deliver(Report report,
@After
public void tearDown() throws Exception {
lastReport = null;
Async.cancelTasks();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public void setUp() throws Exception {
sessionTracker = new SessionTracker(configuration, null, sessionStore);
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testLifecycleBreadcrumbCrash() {
// should not crash with a null client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class BreadcrumbsTest {
breadcrumbs = Breadcrumbs(config)
}

@After
fun tearDown() {
Async.cancelTasks()
}

/**
* Verifies that the breadcrumb message is truncated after the max limit is reached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void setUp() throws Exception {
client = new Client(context, config);
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testSetReleaseStage() throws Exception {
client.setReleaseStage("beta");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public void setUp() throws Exception {
client.setErrorReportApiClient(apiClient);
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testNotifyBlockingDefaultSeverity() {
client.notifyBlocking(new RuntimeException("Testing"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void setUp() throws Exception {
@After
public void tearDown() throws Exception {
clearSharedPrefs();
Async.cancelTasks();
}

private void clearSharedPrefs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public void setUp() throws Exception {
client = BugsnagTestUtils.generateClient();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testClientNotifyModification() throws Exception {
final Collection<BeforeNotify> beforeNotifyTasks = client.config.getBeforeNotifyTasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public void setUp() throws Exception {
config = new Configuration("api-key");
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testEndpoints() {
String notify = "https://notify.myexample.com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public void setUp() throws Exception {
deliveryCompat = new DeliveryCompat();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@SuppressWarnings("deprecation")
@Test
public void deliverReport() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void setUp() throws Exception {
this.deviceData = deviceData.getDeviceDataSummary();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testManufacturer() {
assertNotNull(deviceData.get("manufacturer"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void setUp() throws Exception {
this.deviceData = deviceData.getDeviceData();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testId() {
assertNotNull(deviceData.get("id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public void setUp() throws Exception {
Bugsnag.init(InstrumentationRegistry.getContext(), "123");
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@SuppressWarnings("deprecation")
@Test(expected = IllegalArgumentException.class)
public void testApiClientNullValidation() {
Expand Down
5 changes: 0 additions & 5 deletions sdk/src/androidTest/java/com/bugsnag/android/ErrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public void setUp() throws Exception {
error = new Error.Builder(config, exception, null, Thread.currentThread(), false).build();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testShouldIgnoreClass() {
config.setIgnoreClasses(new String[]{"java.io.IOException"});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void setUp() throws Exception {
Thread.setDefaultUncaughtExceptionHandler(null);
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testEnableDisable() {
Client client = new Client(context, "api-key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public void setUp() throws Exception {
config = new Configuration("api-key");
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testBasicException() throws JSONException, IOException {
Exceptions exceptions = new Exceptions(config, new RuntimeException("oops"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public void setUp() throws Exception {
file.delete();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testSaneValues() throws JSONException, IOException {
final Long nullLong = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public void setUp() throws Exception {
client = BugsnagTestUtils.generateClient();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testBasicSerialization() throws JSONException, IOException {
MetaData metaData = new MetaData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public void setUp() throws Exception {
throwable = new RuntimeException("Test");
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testErrorDefaultMetaData() throws Exception {
Error error = new Error.Builder(config, throwable, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public void setUp() throws Exception {
client.addObserver(observer);
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testUpdateMetadataFromClientSendsMessage() {
MetaData metadata = new MetaData(new HashMap<String, Object>());
Expand Down
5 changes: 0 additions & 5 deletions sdk/src/androidTest/java/com/bugsnag/android/ReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public void setUp() throws Exception {
report = new Report("api-key", error);
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void testInMemoryError() throws JSONException, IOException {
JSONObject reportJson = streamableToJson(report);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void setUp() throws Exception {
*/
@After
public void tearDown() throws Exception {
Async.cancelTasks();
FileUtils.clearFilesInDir(storageDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public void setUp() throws Exception {
user = new User();
}

@After
public void tearDown() throws Exception {
Async.cancelTasks();
}

@Test
public void startNewSession() throws Exception {
assertNotNull(sessionTracker);
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/androidTest/java/com/bugsnag/android/TestRunListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.bugsnag.android

import org.junit.runner.Description
import org.junit.runner.notification.RunListener

class TestRunListener : RunListener() {

override fun testFinished(description: Description) {
super.testFinished(description)
Async.cancelTasks()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public void setUp() throws Exception {
@After
public void tearDown() throws Exception {
callbackCount = 0;
Async.cancelTasks();
}

@Test
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

0 comments on commit bf32e3e

Please sign in to comment.