Skip to content

Commit 264e234

Browse files
committed
Merge pull request #287 from dronekit/release-1.4.2_bug_fixes
Release 1.4.2 bug fixes
2 parents 454cb0d + 8122114 commit 264e234

File tree

10 files changed

+69
-43
lines changed

10 files changed

+69
-43
lines changed

ServiceApp/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
android:allowBackup="true"
4040
android:theme="@style/AppTheme"
4141
android:icon="@drawable/ic_launcher"
42+
android:largeHeap="true"
4243
android:label="@string/app_title">
4344

4445
<meta-data

ServiceApp/build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ android {
7070
//Write logs to file preferences
7171
buildConfigField "boolean", "WRITE_LOG_FILE", "false"
7272
buildConfigField "int", "LOG_FILE_LEVEL", "$logLevelDebug"
73+
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "false"
7374
}
7475

7576
compileOptions {
@@ -133,7 +134,7 @@ android {
133134
signingConfig signingConfigs.release
134135
versionNameSuffix generateVersionNameSuffix(versionBuild, "beta")
135136
buildConfigField "boolean", "WRITE_LOG_FILE", "true"
136-
debuggable true
137+
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "true"
137138
}
138139

139140
sitl {
@@ -145,6 +146,7 @@ android {
145146

146147
release {
147148
signingConfig signingConfigs.release
149+
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "true"
148150
}
149151
}
150152

ServiceApp/src/org/droidplanner/services/android/DroidPlannerServicesApp.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33
import android.app.Application;
44

55
import com.crashlytics.android.Crashlytics;
6-
import io.fabric.sdk.android.Fabric;
7-
import timber.log.Timber;
86

97
import org.droidplanner.services.android.utils.LogToFileTree;
108
import org.droidplanner.services.android.utils.analytics.GAUtils;
119
import org.droidplanner.services.android.utils.file.IO.ExceptionWriter;
1210

11+
import io.fabric.sdk.android.Fabric;
12+
import timber.log.Timber;
13+
1314
public class DroidPlannerServicesApp extends Application {
1415

1516
private LogToFileTree logToFileTree;
1617

1718
@Override
1819
public void onCreate() {
1920
super.onCreate();
20-
Fabric.with(this, new Crashlytics());
2121

22-
if (BuildConfig.DEBUG) {
23-
if(BuildConfig.WRITE_LOG_FILE){
24-
logToFileTree = new LogToFileTree();
25-
Timber.plant(logToFileTree);
26-
}
27-
else {
28-
Timber.plant(new Timber.DebugTree());
29-
}
22+
if(BuildConfig.ENABLE_CRASHLYTICS) {
23+
Fabric.with(this, new Crashlytics());
24+
}
25+
26+
if (BuildConfig.WRITE_LOG_FILE) {
27+
logToFileTree = new LogToFileTree();
28+
Timber.plant(logToFileTree);
29+
} else if (BuildConfig.DEBUG) {
30+
Timber.plant(new Timber.DebugTree());
3031
}
3132

3233
final ExceptionWriter exceptionWriter = new ExceptionWriter(getApplicationContext());

ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbCDCConnection.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.concurrent.TimeUnit;
2020
import java.util.concurrent.atomic.AtomicReference;
2121

22+
import timber.log.Timber;
23+
2224
class UsbCDCConnection extends UsbConnection.UsbConnectionImpl {
2325
private static final String TAG = UsbCDCConnection.class.getSimpleName();
2426
private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
@@ -78,7 +80,11 @@ private void registerUsbPermissionBroadcastReceiver() {
7880
}
7981

8082
private void unregisterUsbPermissionBroadcastReceiver() {
81-
mContext.unregisterReceiver(broadcastReceiver);
83+
try {
84+
mContext.unregisterReceiver(broadcastReceiver);
85+
}catch(IllegalArgumentException e){
86+
Timber.e(e, "Receiver was not registered.");
87+
}
8288
}
8389

8490
private void removeWatchdog() {

ServiceApp/src/org/droidplanner/services/android/core/drone/DroneManager.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.droidplanner.services.android.core.drone.autopilot.px4.Px4Native;
6161
import org.droidplanner.services.android.core.drone.companion.solo.SoloComp;
6262
import org.droidplanner.services.android.core.drone.variables.HeartBeat;
63+
import org.droidplanner.services.android.core.drone.variables.StreamRates;
6364
import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
6465
import org.droidplanner.services.android.core.firmware.FirmwareType;
6566
import org.droidplanner.services.android.core.gcs.GCSHeartbeat;
@@ -77,6 +78,8 @@
7778
import org.droidplanner.services.android.utils.analytics.GAUtils;
7879
import org.droidplanner.services.android.utils.prefs.DroidPlannerPrefs;
7980

81+
import org.droidplanner.services.android.core.drone.profiles.Parameters;
82+
8083
import java.util.HashMap;
8184
import java.util.Map;
8285
import java.util.Set;
@@ -280,15 +283,26 @@ public void postDelayed(Runnable thread, long timeout) {
280283
break;
281284
}
282285

283-
this.drone.getStreamRates().setRates(dpPrefs.getRates());
284-
285286
this.followMe = new Follow(this, handler, new FusedLocation(context, handler));
286287
this.returnToMe = new ReturnToMe(this, new FusedLocation(context, handler,
287288
LocationRequest.PRIORITY_HIGH_ACCURACY, 1000L, 1000L, ReturnToMe.UPDATE_MINIMAL_DISPLACEMENT), this);
288289

290+
final StreamRates streamRates = drone.getStreamRates();
291+
if(streamRates != null) {
292+
streamRates.setRates(dpPrefs.getRates());
293+
}
294+
289295
drone.addDroneListener(this);
290-
drone.getParameters().setParameterListener(this);
291-
drone.getMagnetometerCalibration().setListener(this);
296+
297+
final Parameters parameters = drone.getParameters();
298+
if(parameters != null) {
299+
parameters.setParameterListener(this);
300+
}
301+
302+
final MagnetometerCalibrationImpl magnetometer = drone.getMagnetometerCalibration();
303+
if(magnetometer != null) {
304+
magnetometer.setListener(this);
305+
}
292306
}
293307

294308
public SoloComp getSoloComp() {
@@ -507,6 +521,8 @@ private void handleCommandAck(msg_command_ack ack) {
507521
@Override
508522
public void notifyReceivedData(MAVLinkPacket packet) {
509523
MAVLinkMessage receivedMsg = packet.unpack();
524+
if(receivedMsg == null)
525+
return;
510526

511527
if (receivedMsg.msgid == msg_command_ack.MAVLINK_MSG_ID_COMMAND_ACK) {
512528
final msg_command_ack commandAck = (msg_command_ack) receivedMsg;

ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilot.java

+2-10
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import org.droidplanner.services.android.core.drone.DroneInterfaces;
5858
import org.droidplanner.services.android.core.drone.LogMessageListener;
5959
import org.droidplanner.services.android.core.drone.Preferences;
60-
import org.droidplanner.services.android.core.drone.autopilot.CommonMavLinkDrone;
60+
import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
6161
import org.droidplanner.services.android.core.drone.profiles.Parameters;
6262
import org.droidplanner.services.android.core.drone.profiles.VehicleProfile;
6363
import org.droidplanner.services.android.core.drone.variables.ApmModes;
@@ -69,7 +69,6 @@
6969
import org.droidplanner.services.android.core.drone.variables.Magnetometer;
7070
import org.droidplanner.services.android.core.drone.variables.MissionStats;
7171
import org.droidplanner.services.android.core.drone.variables.RC;
72-
import org.droidplanner.services.android.core.drone.variables.StreamRates;
7372
import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
7473
import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
7574
import org.droidplanner.services.android.core.helpers.coordinates.Coord3D;
@@ -81,7 +80,7 @@
8180
/**
8281
* Base class for the ArduPilot autopilots
8382
*/
84-
public abstract class ArduPilot extends CommonMavLinkDrone {
83+
public abstract class ArduPilot extends GenericMavLinkDrone {
8584

8685
public static final int AUTOPILOT_COMPONENT_ID = 1;
8786
public static final int ARTOO_COMPONENT_ID = 0;
@@ -94,7 +93,6 @@ public abstract class ArduPilot extends CommonMavLinkDrone {
9493
private final Home home;
9594
private final Mission mission;
9695
private final MissionStats missionStats;
97-
private final StreamRates streamRates;
9896
private final GuidedPoint guidedPoint;
9997
private final AccelCalibration accelCalibrationSetup;
10098
private final WaypointManager waypointManager;
@@ -129,7 +127,6 @@ public ArduPilot(Context context, MAVLinkStreams.MAVLinkOutputStream mavClient,
129127
this.home = new Home(this);
130128
this.mission = new Mission(this);
131129
this.missionStats = new MissionStats(this);
132-
this.streamRates = new StreamRates(this);
133130
this.guidedPoint = new GuidedPoint(this, handler);
134131
this.accelCalibrationSetup = new AccelCalibration(this, handler);
135132
this.magCalibration = new MagnetometerCalibrationImpl(this);
@@ -235,11 +232,6 @@ public MissionStats getMissionStats() {
235232
return missionStats;
236233
}
237234

238-
@Override
239-
public StreamRates getStreamRates() {
240-
return streamRates;
241-
}
242-
243235
@Override
244236
public GuidedPoint getGuidedPoint() {
245237
return guidedPoint;

ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/CommonMavLinkDrone.java renamed to ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/generic/GenericMavLinkDrone.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.droidplanner.services.android.core.drone.autopilot;
1+
package org.droidplanner.services.android.core.drone.autopilot.generic;
22

33
import android.os.Bundle;
44
import android.text.TextUtils;
@@ -31,7 +31,9 @@
3131
import org.droidplanner.services.android.core.MAVLink.command.doCmd.MavLinkDoCmds;
3232
import org.droidplanner.services.android.core.drone.DroneEvents;
3333
import org.droidplanner.services.android.core.drone.DroneInterfaces;
34+
import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
3435
import org.droidplanner.services.android.core.drone.variables.State;
36+
import org.droidplanner.services.android.core.drone.variables.StreamRates;
3537
import org.droidplanner.services.android.core.drone.variables.Type;
3638
import org.droidplanner.services.android.core.model.AutopilotWarningParser;
3739
import org.droidplanner.services.android.utils.CommonApiUtils;
@@ -42,13 +44,14 @@
4244
*
4345
* Created by Fredia Huya-Kouadio on 9/10/15.
4446
*/
45-
public abstract class CommonMavLinkDrone implements MavLinkDrone {
47+
public abstract class GenericMavLinkDrone implements MavLinkDrone {
4648

4749
private final MAVLinkStreams.MAVLinkOutputStream MavClient;
4850

4951
private final DroneEvents events;
5052
protected final Type type;
5153
private final State state;
54+
private final StreamRates streamRates;
5255

5356
private final DroneInterfaces.AttributeEventListener attributeListener;
5457

@@ -59,11 +62,12 @@ public abstract class CommonMavLinkDrone implements MavLinkDrone {
5962
protected final Attitude attitude = new Attitude();
6063
protected final Vibration vibration = new Vibration();
6164

62-
protected CommonMavLinkDrone(DroneInterfaces.Handler handler, MAVLinkStreams.MAVLinkOutputStream mavClient, AutopilotWarningParser warningParser, DroneInterfaces.AttributeEventListener listener) {
65+
protected GenericMavLinkDrone(DroneInterfaces.Handler handler, MAVLinkStreams.MAVLinkOutputStream mavClient, AutopilotWarningParser warningParser, DroneInterfaces.AttributeEventListener listener) {
6366
this.MavClient = mavClient;
6467

6568
events = new DroneEvents(this, handler);
6669
this.type = new Type(this);
70+
this.streamRates = new StreamRates(this);
6771
this.state = new State(this, handler, warningParser);
6872

6973
this.attributeListener = listener;
@@ -84,6 +88,11 @@ public void addDroneListener(DroneInterfaces.OnDroneListener listener) {
8488
events.addDroneListener(listener);
8589
}
8690

91+
@Override
92+
public StreamRates getStreamRates() {
93+
return streamRates;
94+
}
95+
8796
@Override
8897
public void removeDroneListener(DroneInterfaces.OnDroneListener listener) {
8998
events.removeDroneListener(listener);

ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/px4/Px4Native.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package org.droidplanner.services.android.core.drone.autopilot.px4;
22

3-
import com.o3dr.services.android.lib.model.ICommandListener;
4-
import com.o3dr.services.android.lib.model.action.Action;
5-
63
import org.droidplanner.services.android.core.MAVLink.MAVLinkStreams;
74
import org.droidplanner.services.android.core.MAVLink.WaypointManager;
85
import org.droidplanner.services.android.core.drone.DroneInterfaces;
96
import org.droidplanner.services.android.core.drone.Preferences;
10-
import org.droidplanner.services.android.core.drone.autopilot.CommonMavLinkDrone;
7+
import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
118
import org.droidplanner.services.android.core.drone.profiles.Parameters;
129
import org.droidplanner.services.android.core.drone.profiles.VehicleProfile;
1310
import org.droidplanner.services.android.core.drone.variables.Camera;
@@ -16,7 +13,6 @@
1613
import org.droidplanner.services.android.core.drone.variables.Home;
1714
import org.droidplanner.services.android.core.drone.variables.Magnetometer;
1815
import org.droidplanner.services.android.core.drone.variables.MissionStats;
19-
import org.droidplanner.services.android.core.drone.variables.StreamRates;
2016
import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
2117
import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
2218
import org.droidplanner.services.android.core.firmware.FirmwareType;
@@ -26,7 +22,7 @@
2622
/**
2723
* Created by Fredia Huya-Kouadio on 9/10/15.
2824
*/
29-
public class Px4Native extends CommonMavLinkDrone {
25+
public class Px4Native extends GenericMavLinkDrone {
3026

3127
public Px4Native(DroneInterfaces.Handler handler, MAVLinkStreams.MAVLinkOutputStream mavClient, AutopilotWarningParser warningParser, DroneInterfaces.AttributeEventListener listener) {
3228
super(handler, mavClient, warningParser, listener);
@@ -97,11 +93,6 @@ public Mission getMission() {
9793
return null;
9894
}
9995

100-
@Override
101-
public StreamRates getStreamRates() {
102-
return null;
103-
}
104-
10596
@Override
10697
public MissionStats getMissionStats() {
10798
return null;

ServiceApp/src/org/droidplanner/services/android/core/gcs/GCSHeartbeat.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public GCSHeartbeat(MAVLinkClient mavClient, int freqHz) {
5858
*
5959
* @param active true to activate the heartbeat, false to deactivate it
6060
*/
61-
public void setActive(boolean active) {
61+
public synchronized void setActive(boolean active) {
6262
if (active) {
6363
if (heartbeatExecutor == null || heartbeatExecutor.isShutdown()) {
6464
heartbeatExecutor = Executors.newSingleThreadScheduledExecutor();

ServiceApp/src/org/droidplanner/services/android/ui/adapter/RecommendedAppsAdapter.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.content.Intent;
5+
import android.content.pm.PackageManager;
56
import android.graphics.Bitmap;
67
import android.graphics.BitmapFactory;
78
import android.net.Uri;
@@ -139,7 +140,8 @@ public void onBindViewHolder(ViewHolder viewHolder, int position) {
139140

140141
viewHolder.actionButtonContainer.setVisibility(View.VISIBLE);
141142

142-
Intent tmpIntent = context.getPackageManager().getLaunchIntentForPackage(appId);
143+
final PackageManager pm = context.getPackageManager();
144+
Intent tmpIntent = pm.getLaunchIntentForPackage(appId);
143145
if (tmpIntent != null) {
144146
//The app is installed on the device.
145147
viewHolder.actionButton.setText(R.string.label_action_button_open);
@@ -150,6 +152,12 @@ public void onBindViewHolder(ViewHolder viewHolder, int position) {
150152
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
151153
.setData(Uri.parse("market://details?id=" + appId));
152154

155+
if(pm.resolveActivity(tmpIntent, PackageManager.MATCH_DEFAULT_ONLY) == null){
156+
tmpIntent = new Intent(Intent.ACTION_VIEW)
157+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
158+
.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + appId));
159+
}
160+
153161
viewHolder.actionButton.setText(R.string.label_action_button_install);
154162
viewHolder.actionButton.setBackgroundResource(R.drawable.action_button_install_bg);
155163
}

0 commit comments

Comments
 (0)