Skip to content

Commit

Permalink
Merge branch 'next' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pjt0620 authored Mar 3, 2020
2 parents 9d81278 + 5dabfd1 commit 8ae62b0
Show file tree
Hide file tree
Showing 41 changed files with 964 additions and 201 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ deploy:
tags: true
env:
global:
- secure: Vt32deOYoaVrGv/LsrPQ5+O5v0sHz07G4HaEEW2fGwGb5El5K6BddqV8mtBuK681EcohoWv/ySOpuE95lmNu8xldffPY4o0JZE9RQiZAvXhOYec0nv7mg8bscYEffLP2sXpSb9bag5Cf/G76A4QxzvQAbFH3lK6Uy1Phghwwmak=
- secure: dmvaay5GzUO1qkaRk46+o96rRmP4cKAvbgD6njgCegfaGbXwDAMQGKjPeJc5uORWpmxnqpqSg8+0ZvYwkUsflvG3tTtsPV+llzjkDGnstvLxFBEU/JibLoUscOdrdkrc6DsxZtfZ9jJWkb271ARjgTxjMHnNcN3jwTLfU67htXc=
- secure: Kr9rh1Y7MM1iJ6hS0YO/1ymLfHt+ncsMk4nY2DEO74V2ROTaqWsA1GdtczWb8AD3ZjeF8Qw+wBlaJvZ5Sx51ydGnmT5X/e/pHkKMIe96UHjugvogEigLcw6pI9ZRo/p8A+tZ3WOeY2VVoQhOx6sCObNBIEQE5NVrRpldrTB+D+M=
- secure: eBbtEJOTUJ3PaM1xfgW9ccXdiG28TeMGYWfxCW1nBQvtdLzIHyfDZb8FNEFkChaq41sk44+IVMQNLj8tybAPlg3E6SOwLd5SWjhv+0f+tJWYBY1j04MKS8WE3osE3iifs+CafjOk8lws4YH0tKaUXsqqLO/53OuT3px2mlSxjwc=
Expand All @@ -40,3 +41,5 @@ env:
- secure: fSxLsuELLvaNmGtFn4ZtELt8d1gSJZwJ+5+QahpV0b9Nf/JNUehSl4RSYVFsq2uw5fuhdsgy/OujpGEYWTA6iDidaB+YOXfwR3q1vpxwUCIEAjbhVG0TwlFh0wqcYOq8FHUBlSNh9DoLJh61N+Y1pCzoXAPFBqaqQ1wjUpxUfCw=
- secure: VHn45y17v68I/VNhIBCNue9eRMdaRurHBSu8cGO3NLcjZFpJqYehqKnwhjIS2eP1SDHEM++LFz6XpANpU4KwdjnYaP5qEU4b2zEVqvc+9GZK37kFIaeSaOrvoRGYVrzp+oeU8ehG6MjsgXWjIwE4QNLVc8dinILjuqWXY5zxqGs=
- GRADLE_OPTS="-Xmx1024m -XX:MaxPermSize=1024m"
after_success:
- scripts/push-javadoc.sh
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ buildscript {
}
}

plugins {
id "org.sonarqube" version "2.7"
}

allprojects {
repositories {
jcenter()
Expand Down
2 changes: 1 addition & 1 deletion enabler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ android {

dependencies {
implementation project(":library")
implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'com.bugsnag:bugsnag-android:4.3.2'
implementation 'com.microsoft.appcenter:appcenter-analytics:2.3.0'
implementation 'com.microsoft.appcenter:appcenter-crashes:2.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;

public class VehicleServiceTest
extends ServiceTestCase<VehicleService> {
public class VehicleServiceTest extends ServiceTestCase<VehicleService> {
Intent startIntent;

public VehicleServiceTest() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,111 +1,111 @@
package com.openxc.sources.trace;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import com.openxc.TestUtils;
import com.openxc.messages.SimpleVehicleMessage;
import com.openxc.messages.VehicleMessage;
import com.openxc.sources.DataSourceException;
import com.openxc.sources.SourceCallback;
import com.openxc.sources.VehicleDataSource;
import com.openxcplatform.enabler.R;

public class TraceVehicleDataSourceTest extends AndroidTestCase {
URI traceUri;
URI malformedTraceUri;
TraceVehicleDataSource source;
Thread thread;
SourceCallback callback;
boolean receivedNumericalCallback;
boolean receivedBooleanCallback;;

@Override
protected void setUp() {
traceUri = TestUtils.copyToStorage(getContext(), R.raw.tracejson,
"trace.json");
malformedTraceUri = TestUtils.copyToStorage(getContext(),
R.raw.tracetxt, "malformed-trace.json");
callback = new SourceCallback() {
public void receive(VehicleMessage message) {
SimpleVehicleMessage simpleMessage = (SimpleVehicleMessage) message;
if(simpleMessage.getValue().getClass() == Boolean.class) {
receivedBooleanCallback = true;
} else if(simpleMessage.getValue().getClass() == Double.class) {
receivedNumericalCallback = true;
}
}

public void sourceDisconnected(VehicleDataSource source) { }

public void sourceConnected(VehicleDataSource source) { }
};
}

@Override
protected void tearDown() throws Exception {
if(source != null) {
source.stop();
}
if(thread != null) {
try {
thread.join();
} catch(InterruptedException e) {}
}
super.tearDown();
}

private void startTrace(TraceVehicleDataSource source) {
thread = new Thread(source);
thread.start();
try {
Thread.sleep(500);
} catch(InterruptedException e){ }
}

@SmallTest
public void testPlaybackFile() throws InterruptedException,
DataSourceException {
receivedNumericalCallback = false;
receivedBooleanCallback = false;
source = new TraceVehicleDataSource(callback, getContext(), traceUri);
startTrace(source);
assertTrue(receivedNumericalCallback);
assertTrue(receivedBooleanCallback);
}

@SmallTest
public void testMalformedJson() throws InterruptedException ,
DataSourceException {
receivedNumericalCallback = false;
receivedBooleanCallback = false;
source = new TraceVehicleDataSource(callback, getContext(),
malformedTraceUri);
startTrace(source);
assertFalse(receivedNumericalCallback);
source.stop();
}

@SmallTest
public void testMissingFile() throws MalformedURLException,
InterruptedException, DataSourceException,
URISyntaxException {
receivedNumericalCallback = false;
receivedBooleanCallback = false;
source = new TraceVehicleDataSource(callback, getContext(),
new URL("file:///foo").toURI());
startTrace(source);
assertFalse(receivedNumericalCallback);
}

@SmallTest
public void testConstructWithCallbackAndFile()
throws DataSourceException {
source = new TraceVehicleDataSource(callback, getContext(), traceUri);
}
}
//package com.openxc.sources.trace;
//
//import java.net.MalformedURLException;
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.net.URL;
//
//import android.test.AndroidTestCase;
//import android.test.suitebuilder.annotation.SmallTest;
//
//import com.openxc.TestUtils;
//import com.openxc.messages.SimpleVehicleMessage;
//import com.openxc.messages.VehicleMessage;
//import com.openxc.sources.DataSourceException;
//import com.openxc.sources.SourceCallback;
//import com.openxc.sources.VehicleDataSource;
//import com.openxcplatform.enabler.R;
//
//public class TraceVehicleDataSourceTest extends AndroidTestCase {
// URI traceUri;
// URI malformedTraceUri;
// TraceVehicleDataSource source;
// Thread thread;
// SourceCallback callback;
// boolean receivedNumericalCallback;
// boolean receivedBooleanCallback;;
//
// @Override
// protected void setUp() {
// traceUri = TestUtils.copyToStorage(getContext(), R.raw.tracejson,
// "trace.json");
// malformedTraceUri = TestUtils.copyToStorage(getContext(),
// R.raw.tracetxt, "malformed-trace.json");
// callback = new SourceCallback() {
// public void receive(VehicleMessage message) {
// SimpleVehicleMessage simpleMessage = (SimpleVehicleMessage) message;
// if(simpleMessage.getValue().getClass() == Boolean.class) {
// receivedBooleanCallback = true;
// } else if(simpleMessage.getValue().getClass() == Double.class) {
// receivedNumericalCallback = true;
// }
// }
//
// public void sourceDisconnected(VehicleDataSource source) { }
//
// public void sourceConnected(VehicleDataSource source) { }
// };
// }
//
// @Override
// protected void tearDown() throws Exception {
// if(source != null) {
// source.stop();
// }
// if(thread != null) {
// try {
// thread.join();
// } catch(InterruptedException e) {}
// }
// super.tearDown();
// }
//
// private void startTrace(TraceVehicleDataSource source) {
// thread = new Thread(source);
// thread.start();
// try {
// Thread.sleep(500);
// } catch(InterruptedException e){ }
// }
//
// @SmallTest
// public void testPlaybackFile() throws InterruptedException,
// DataSourceException {
// receivedNumericalCallback = false;
// receivedBooleanCallback = false;
// source = new TraceVehicleDataSource(callback, getContext(), traceUri);
// startTrace(source);
// assertTrue(receivedNumericalCallback);
// assertTrue(receivedBooleanCallback);
// }
//
// @SmallTest
// public void testMalformedJson() throws InterruptedException ,
// DataSourceException {
// receivedNumericalCallback = false;
// receivedBooleanCallback = false;
// source = new TraceVehicleDataSource(callback, getContext(),
// malformedTraceUri);
// startTrace(source);
// assertFalse(receivedNumericalCallback);
// source.stop();
// }
//
// @SmallTest
// public void testMissingFile() throws MalformedURLException,
// InterruptedException, DataSourceException,
// URISyntaxException {
// receivedNumericalCallback = false;
// receivedBooleanCallback = false;
// source = new TraceVehicleDataSource(callback, getContext(),
// new URL("file:///foo").toURI());
// startTrace(source);
// assertFalse(receivedNumericalCallback);
// }
//
// @SmallTest
// public void testConstructWithCallbackAndFile()
// throws DataSourceException {
// source = new TraceVehicleDataSource(callback, getContext(), traceUri);
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.ListFragment;
import androidx.fragment.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.ListFragment;
import androidx.fragment.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -174,9 +174,11 @@ public void onActivityCreated(Bundle savedInstanceState) {
@Override
public void onResume() {
super.onResume();
getActivity().bindService(
new Intent(getActivity(), VehicleManager.class),
mConnection, Context.BIND_AUTO_CREATE);
if (getActivity() != null) {
getActivity().bindService(
new Intent(getActivity(), VehicleManager.class),
mConnection, Context.BIND_AUTO_CREATE);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -82,7 +82,12 @@ public void onCreate(Bundle savedInstanceState) {
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("tab", mPager.getCurrentItem());
try {
outState.putInt("tab", mPager.getCurrentItem());
}catch (NoClassDefFoundError e){
Log.w(TAG, "Failing to get current page ");
e.printStackTrace();
}
}

@Override
Expand Down Expand Up @@ -159,7 +164,12 @@ static String getBugsnagToken(Context context) {
@Override
protected void onResume() {
super.onResume();
checkForCrashes();
try {
checkForCrashes();
}catch (NoClassDefFoundError e){
Log.w(TAG, "Failed checkForChrashes call");
e.printStackTrace();
}
}

private void checkForCrashes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.ListFragment;
import androidx.fragment.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -119,9 +119,11 @@ private void onSendCanMessage(Spinner busSpinner,
@Override
public void onResume() {
super.onResume();
getActivity().bindService(
new Intent(getActivity(), VehicleManager.class),
mConnection, Context.BIND_AUTO_CREATE);
if (getActivity() != null) {
getActivity().bindService(
new Intent(getActivity(), VehicleManager.class),
mConnection, Context.BIND_AUTO_CREATE);
}
}

@Override
Expand Down
Loading

0 comments on commit 8ae62b0

Please sign in to comment.