Skip to content

Commit 66ccb35

Browse files
committed
Merge pull request #12 from DroidPlanner/droneapi_update
Droneapi update
2 parents 4f7da5d + e40cc70 commit 66ccb35

File tree

17 files changed

+288
-45
lines changed

17 files changed

+288
-45
lines changed

AidlLib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 14
99
targetSdkVersion 21
10-
versionCode 200016
11-
versionName '2.0.16'
10+
versionCode 200018
11+
versionName '2.0.18'
1212
}
1313

1414
defaultPublishConfig "release"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.o3dr.services.android.lib.model;
2+
3+
import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
4+
5+
/**
6+
* DroneAPI event listener. A valid instance must be provided at api registration.
7+
*/
8+
interface IApiListener {
9+
10+
/**
11+
* Ping the api listener to make sure it's still up and connected.
12+
*/
13+
boolean ping();
14+
15+
/**
16+
* Called when the connection attempt fails.
17+
* @param result Describe why the connection failed.
18+
*/
19+
oneway void onConnectionFailed(in ConnectionResult result);
20+
21+
/**
22+
* Retrieve the version code for the connected client.
23+
*/
24+
int getClientVersionCode();
25+
}

AidlLib/src/com/o3dr/services/android/lib/model/IDroidPlannerServices.aidl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package com.o3dr.services.android.lib.model;
33

44
import com.o3dr.services.android.lib.model.IDroneApi;
5+
import com.o3dr.services.android.lib.model.IApiListener;
56

67
/**
78
* Used to establish connection with a drone.
@@ -14,9 +15,11 @@ interface IDroidPlannerServices {
1415
boolean ping();
1516

1617
/**
18+
* TODO: left now for backward compatibility. To be removed in next version.
1719
* Acquire an handle to the droidplanner api.
1820
* @param appId application id for the application acquiring the drone api handle.
1921
* @return IDroneApi object used to interact with the drone.
22+
* @deprecated use {@link #registerDroneApi(IApiListener listener, String appId)} instead.
2023
*/
2124
IDroneApi acquireDroneApi(String appId);
2225

@@ -27,4 +30,16 @@ interface IDroidPlannerServices {
2730
*/
2831
void releaseDroneApi(IDroneApi droneApi);
2932

33+
/**
34+
* Retrieve the version code for the api.
35+
*/
36+
int getApiVersionCode();
37+
38+
/**
39+
* Acquire an handle to the droidplanner api.
40+
* @param listener listener for the DroneAPI events.
41+
* @param appId application id for the application acquiring the drone api handle.
42+
* @return IDroneApi object used to interact with the drone.
43+
*/
44+
IDroneApi registerDroneApi(IApiListener listener, String appId);
3045
}

AidlLib/src/com/o3dr/services/android/lib/model/IObserver.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ oneway interface IObserver {
1717
void onAttributeUpdated(String attributeEvent, in Bundle eventExtras);
1818

1919
/**
20+
* TODO: left now for backward compatibility. To be removed in next version.
2021
* Called when the connection attempt fails.
2122
* @param result Describe why the connection failed.
2223
*/

ClientLib/mobile/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22

33
ext {
44
PUBLISH_ARTIFACT_ID = '3dr-services-lib'
5-
PUBLISH_VERSION = '2.1.10'
5+
PUBLISH_VERSION = '2.1.14'
66
PROJECT_DESCRIPTION = "3DR Services client library"
77
PROJECT_LABELS = ['3DR', '3DR Services', 'DroneAPI', 'Android']
88
PROJECT_LICENSES = ['Apache-2.0']
@@ -15,7 +15,7 @@ android {
1515
defaultConfig {
1616
minSdkVersion 14
1717
targetSdkVersion 21
18-
versionCode 20110
18+
versionCode 20114
1919
versionName PUBLISH_VERSION
2020
}
2121

ClientLib/mobile/libs/AidlLib.jar

5.58 KB
Binary file not shown.

ClientLib/mobile/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
android:noHistory="true"
99
android:excludeFromRecents="true"
1010
android:launchMode="singleTask"/>
11+
12+
<activity
13+
android:name=".utils.UpdateServiceDialog"
14+
android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar.MinWidth"
15+
android:noHistory="true"
16+
android:excludeFromRecents="true"
17+
android:launchMode="singleTask"/>
1118
</application>
1219

1320
</manifest>

ClientLib/mobile/src/main/java/com/o3dr/android/client/Drone.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import android.os.SystemClock;
88
import android.util.Log;
99

10-
import com.MAVLink.Messages.MAVLinkMessage;
1110
import com.o3dr.android.client.interfaces.DroneListener;
1211
import com.o3dr.services.android.lib.coordinate.LatLong;
1312
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
@@ -17,8 +16,6 @@
1716
import com.o3dr.services.android.lib.drone.mission.Mission;
1817
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
1918
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
20-
import com.o3dr.services.android.lib.drone.mission.item.complex.StructureScanner;
21-
import com.o3dr.services.android.lib.drone.mission.item.complex.Survey;
2219
import com.o3dr.services.android.lib.drone.property.Altitude;
2320
import com.o3dr.services.android.lib.drone.property.Attitude;
2421
import com.o3dr.services.android.lib.drone.property.Battery;
@@ -65,6 +62,7 @@ public class Drone {
6562
private final Handler handler;
6663
private final ServiceManager serviceMgr;
6764
private final DroneObserver droneObserver;
65+
private final DroneApiListener apiListener;
6866
private IDroneApi droneApi;
6967

7068
private ConnectionParameter connectionParameter;
@@ -78,6 +76,7 @@ public class Drone {
7876
public Drone(ServiceManager serviceManager, Handler handler) {
7977
this.handler = handler;
8078
this.serviceMgr = serviceManager;
79+
this.apiListener = new DroneApiListener(this);
8180
this.droneObserver = new DroneObserver(this);
8281
}
8382

@@ -89,7 +88,8 @@ public void start() {
8988
return;
9089

9190
try {
92-
this.droneApi = serviceMgr.get3drServices().acquireDroneApi(serviceMgr.getApplicationId());
91+
this.droneApi = serviceMgr.get3drServices().registerDroneApi(this.apiListener,
92+
serviceMgr.getApplicationId());
9393
} catch (RemoteException e) {
9494
throw new IllegalStateException("Unable to retrieve a valid drone handle.");
9595
}
@@ -178,7 +178,7 @@ public long getFlightTime() {
178178
}
179179

180180
public Gps getGps() {
181-
Gps gps = getAttribute(AttributeType.GPS, Gps.class.getClassLoader());
181+
Gps gps = getAttribute(AttributeType.GPS, Gps.class.getClassLoader());
182182
return gps == null ? new Gps() : gps;
183183
}
184184

@@ -205,7 +205,7 @@ private <T extends Parcelable> T getAttribute(String type, ClassLoader classLoad
205205
T attribute = null;
206206
if (isStarted()) {
207207
Bundle carrier = getAttribute(type);
208-
if(carrier != null) {
208+
if (carrier != null) {
209209
carrier.setClassLoader(classLoader);
210210
attribute = carrier.getParcelable(type);
211211
}
@@ -311,12 +311,12 @@ public ConnectionParameter getConnectionParameter() {
311311
}
312312

313313
public <T extends MissionItem> void buildComplexMissionItem(MissionItem.ComplexItem<T>
314-
complexItem){
315-
if(isStarted()){
316-
try{
314+
complexItem) {
315+
if (isStarted()) {
316+
try {
317317
T missionItem = (T) complexItem;
318318
Bundle payload = missionItem.getType().storeMissionItem(missionItem);
319-
if(payload == null)
319+
if (payload == null)
320320
return;
321321

322322
droneApi.buildComplexMissionItem(payload);
@@ -345,8 +345,8 @@ private void addAttributesObserver(IObserver observer) {
345345
}
346346
}
347347

348-
public void addMavlinkObserver(MavlinkObserver observer){
349-
if(isStarted()){
348+
public void addMavlinkObserver(MavlinkObserver observer) {
349+
if (isStarted()) {
350350
try {
351351
droneApi.addMavlinkObserver(observer);
352352
} catch (RemoteException e) {
@@ -355,8 +355,8 @@ public void addMavlinkObserver(MavlinkObserver observer){
355355
}
356356
}
357357

358-
public void removeMavlinkObserver(MavlinkObserver observer){
359-
if(isStarted()){
358+
public void removeMavlinkObserver(MavlinkObserver observer) {
359+
if (isStarted()) {
360360
try {
361361
droneApi.removeMavlinkObserver(observer);
362362
} catch (RemoteException e) {
@@ -508,8 +508,8 @@ public void sendGuidedPoint(LatLong point, boolean force) {
508508
}
509509
}
510510

511-
public void sendMavlinkMessage(MavlinkMessageWrapper messageWrapper){
512-
if(messageWrapper != null && isStarted()){
511+
public void sendMavlinkMessage(MavlinkMessageWrapper messageWrapper) {
512+
if (messageWrapper != null && isStarted()) {
513513
try {
514514
droneApi.sendMavlinkMessage(messageWrapper);
515515
} catch (RemoteException e) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.o3dr.android.client;
2+
3+
import android.os.RemoteException;
4+
5+
import com.o3dr.services.android.lib.BuildConfig;
6+
import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
7+
import com.o3dr.services.android.lib.model.IApiListener;
8+
9+
/**
10+
* Created by fhuya on 12/15/14.
11+
*/
12+
public class DroneApiListener extends IApiListener.Stub {
13+
14+
private final Drone drone;
15+
16+
public DroneApiListener(Drone drone){
17+
this.drone = drone;
18+
}
19+
20+
@Override
21+
public boolean ping() throws RemoteException {
22+
return true;
23+
}
24+
25+
@Override
26+
public void onConnectionFailed(ConnectionResult connectionResult) throws RemoteException {
27+
drone.notifyDroneConnectionFailed(connectionResult);
28+
}
29+
30+
@Override
31+
public int getClientVersionCode() throws RemoteException {
32+
return BuildConfig.VERSION_CODE;
33+
}
34+
}

ClientLib/mobile/src/main/java/com/o3dr/android/client/DroneObserver.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ public DroneObserver(Drone drone) {
1818
}
1919

2020
@Override
21-
public void onConnectionFailed(ConnectionResult result) throws RemoteException {
22-
drone.notifyDroneConnectionFailed(result);
23-
}
21+
public void onConnectionFailed(ConnectionResult result) throws RemoteException {}
2422

2523
@Override
2624
public void onAttributeUpdated(String attributeEvent, Bundle eventExtras) throws

0 commit comments

Comments
 (0)